Streak indicator?

Also, is there some type of function that will return how many days in a row that a series has gone down (or up)? If not, is there a way to handle that in P123? Thanks.

Loopsum will do it for you. It counts and sum’s the number of instances of a pre-defined event over X trial length.

Loopsum(“close(CTR)>close(CTR+1)”,10)>=8 for example (check the syntax in the help section). Requires that stocks have risen 8 of past 10 days (close to close).

Thanks Tom, but if I’m understanding this right, it doesn’t stop the loop once the condition isn’t met? So if there were two up closes in a row, and the third one wasn’t up, in your example it would still keep counting all the way up to 10. So looks like I’d need to sum LoopSum() > 1 + LoopSum() >2 + LoopSum() > 3, etc. as a Boolean type of sum. Still trying to get the hang of this.

Thanks for your help.

–Tom C

If you only want to buy a stock if it’s up 10 days in a row use “Loopsum(“close(CTR)>close(CTR+1)”,10)>=10” at the end of the equation. If you only want it if it’s up 50 days in a row, change the ,50 and =50. It’s pretty flexible.

Not sure exactly what you want?

Actually, what I needed was to assign 1 if it was one in a row, 2 for two in a row, etc. (up to 10) so i could have a variable to use in a ranking. The LoopSum was very helpful though. In case someone else needs it, here’s what I ended up doing in a custom variable (this one was for down closes).

(Close(0) <= Close(1)) + (Loopsum(“close(CTR)<=close(CTR+1)”,2)>=2) + (Loopsum(“close(CTR)<=close(CTR+1)”,3)>=3) + (Loopsum(“close(CTR)<=close(CTR+1)”,4)>=4) + (Loopsum(“close(CTR)<=close(CTR+1)”,5)>=5) + (Loopsum(“close(CTR)<=close(CTR+1)”,6)>=6) + (Loopsum(“close(CTR)<=close(CTR+1)”,7)>=7) + (Loopsum(“close(CTR)<=close(CTR+1)”,8)>=8) + (Loopsum(“close(CTR)<=close(CTR+1)”,9)>=9) + (Loopsum(“close(CTR)<=close(CTR+1)”,10)>=10)

Very much appreciate your help Tom on this.

–Tom C

There's a new function LoopStreak now. See announcements or reference.