Consecutive days Rate this Topic:
 Previous Topic · Next Topic Watch this topic · Print this topic ·
flan4
 Posted : Wednesday, August 11, 2010 6:43:40 PM
Registered User
Joined: 3/12/2005
Posts: 123
If I wanted to create a condition that identifies "today is the second consecutive day in which price has not traded above the previous day’s close", would I have to create it in realcode?  If so, any help creating it would be greatly appreciated.  Thanks.
StockGuy
 Posted : Wednesday, August 11, 2010 11:51:30 PM

Joined: 9/30/2004
Posts: 9,187
On a Daily chart, create a RealCode condition using the following formula:

If price.high < price.Close(1) then pass

Then right click on the condition and select Edit.  Set it to passing 2 of the last 2 bars.
flan4
 Posted : Thursday, August 12, 2010 1:11:29 AM
Registered User
Joined: 3/12/2005
Posts: 123
StockGuy,

Thank you, I'll give it a try.  How would you code consecutive higher or lower closes?  For example, 5 higher consecutive closes.  Thnaks again.
Bruce_L
 Posted : Thursday, August 12, 2010 7:55:35 AM

Worden Trainer

Joined: 10/7/2004
Posts: 65,138
flan4,
A higher Close would be:

If Price.Last > Price.Last(1) Then Pass

While a lower Close would be:

If Price.Last < Price.Last(1) Then Pass

In both cases, you could set it to passing 5 of the last 5 bars to create a version that checks for five consecutive instances.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
flan4
 Posted : Thursday, August 12, 2010 7:59:29 AM
Registered User
Joined: 3/12/2005
Posts: 123
Thanks Bruce
Bruce_L
 Posted : Thursday, August 12, 2010 8:01:48 AM

Worden Trainer

Joined: 10/7/2004
Posts: 65,138
flan4,
You're welcome. Our pleasure.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
flan4
 Posted : Thursday, August 12, 2010 9:09:25 PM
Registered User
Joined: 3/12/2005
Posts: 123
Bruce,

In the spirit of learning, in the first phase of creating my condition, and after naming my new condition, the following "header" came up before i copied and pasted the above provided code:

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Today 2nd consecutive day Price not traded above previous day’s close
'|*** Example: if price.percentChange > 1 then pass
'|******************************************************************

The 3rd line is what I named the condition.  What is the purpose of the 4th line, "example"?  Is that a necessary line for my code to work?  What if I deleted it, would it matter?

Do I need such headers to create a realcode?  I.e. what if I deleted the entire header?

Does it matter on which line I copy my code?

Thanks
Kuf
 Posted : Friday, August 13, 2010 12:04:50 PM

Joined: 9/18/2004
Posts: 3,522
You don't need the headers at all, they're there in case you want to copy/paste them somewhere else. They can be removed if you do not want them at all.

Ken Gilb (Kuf)
Chief Software Engineer - Worden Brothers Inc.
Try/Catch - My RealCode Blog
flan4
 Posted : Friday, September 17, 2010 6:41:30 PM
Registered User
Joined: 3/12/2005
Posts: 123
Regarding 5 consecutive closes above, let's say you set up a scan that has you selling short on the close of the 5th consecutive higher close, and you're buying-to-cover on the following day's close, will stockfinder get confused or create errors when you have a stretch of 11 consecutive higher closes?  I've been working with customer service regarding some odd results (when I drag "trade signals" to the chart, the trade signals are plotted incorrectly).  In other words, do you have to add any code, or do anything, to account for "overlap"?  Hope this makes sense.  Thanks.
Bruce_L
 Posted : Monday, September 20, 2010 9:57:36 AM

Worden Trainer

Joined: 10/7/2004
Posts: 65,138
A Condition to check for something happening 5 consecutive Bars will also be met when that same something has happened on 11 consecutive Bars as something that has met a Condition for 11 out of 11 Bars has also met that same Condition for 5 out 5 Bars.

If you want a Rule to return True for exactly 5 consecutive Bars, then you would need to check for the Condition being True for 5 out of the last 5 Bars but not True 5-Bars Ago. It is probably easier to manually do this in your RealCode than to use the x of y  Bars feature built into RealCode Conditions.

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Up Exactly 5 Bars
'|******************************************************************
Static Count As Integer
If isFirstBar Then
Count = 0
Else If Price.Last > Price.Last(1) Then
Count += 1
Else
Count = 0
End If
If Count = 5 Then Pass

This wouldn't reset because of any Trades happening within BackScanner however (and I would not have suggestions that would do so that do not pretty much require recreating the entire BackScan within your RealCode).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
flan4
 Posted : Monday, September 20, 2010 10:16:50 PM
Registered User
Joined: 3/12/2005
Posts: 123

Thanks Bruce.

Bruce_L
 Posted : Tuesday, September 21, 2010 9:37:09 AM

Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
flan4
 Posted : Saturday, October 30, 2010 6:04:13 PM
Registered User
Joined: 3/12/2005
Posts: 123
Bruce,

I've been trying to create a backscan that would buy the first down close after a string of consecutive up closes, but have been unsuccessful.  I would like to use the condition you created:

Static Count As Integer
If isFirstBar Then
Count = 0
Else If Price.Last > Price.Last(1) Then
Count += 1
Else
Count = 0
End If
If Count = 5 Then Pass

Typically, one would create a combo condition and set the y of the x of y bar 1 day greater for this type of test?

Thanks
Bruce_L
 Posted : Monday, November 1, 2010 9:52:09 AM

Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Setting the Up Exactly 5 Bars RealCode Condition to Passing 1 of the Last 2 and something like:

If Price.Last < Price.Last(1) Then Pass

To Passing 1 of the Last 1 before Dragging and Dropping them onto each other to create a Combo Condition certainly seems to work for me.

I get Trades in BackScanner and they seem to correspond correctly with the Chart.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
flan4
 Posted : Monday, November 1, 2010 9:43:23 PM
Registered User
Joined: 3/12/2005
Posts: 123
Thanks Bruce, they seem to correspond correctly for me too!
Bruce_L
 Posted : Tuesday, November 2, 2010 10:19:26 AM

Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

 Forum Jump Customer Training & Support - Ask a Trainer - TC2000 version 12/18 - Ask a Trainer - TC2000 version 7 - Ask a Trainer - StockFinder 5.0 - PCFs, EasyScan and Custom Indicators General Discussions - Stock and Market Talk - TC2000 version 12 or 18 - TC2000 version 7 - StockFinder 5.0 - RealCode for StockFinder 5.0 Tutorial Videos - TC2000 version 12 tutorial videos - TC2000 version 7 tutorial videos You cannot post new topics in this forum. You cannot reply to topics in this forum. You cannot delete your posts in this forum. You cannot edit your posts in this forum. You cannot create polls in this forum. You cannot vote in polls in this forum.