Duration
Author: topcat77
Creation Date: 7/27/2009 5:14 PM
profile picture

topcat77

#1
I would like to create a data series that simply logs the number of cumulative up (or down) days for an indicator. For example, if at eod today the lower Bollinger Band has closed lower each day for the past 4 days the series will show "-4" ; and, of cource, it would have shown -3,-2,-1 reading backwards from today; if tomorrow it closes up, the dataseries will say "+1" and so on
( the duration series could be used for other indicators too eg Rsi)
If there is something like this aready avalialable, or if somebody has created code for the idea please could you point me in its direction. ( I can't work out how to insert an "if" statement in creating a data series) Thank You
profile picture

Cone

#2
See CumUp, CumDown.
profile picture

topcat77

#3
??
In CumUp, to "test whether a specific number of consecutive bars have elapsed where prices are greater than their value a certain number of bars ago" the indicator asks for that specific number. The duration series I am looking for is open ended in that it seeks to count how many bars of cumup have ocurred - which may be 1 or any number greater than 1 - (rather than a specified number). How could Cumup be used for this purpose?
profile picture

Eugene

#4
Something like this?
CODE:
Please log in to see this code.
profile picture

topcat77

#5
Brilliant, Thank you v m
a little different from what I had in mind ( . . . . .but maybe even more interesting)
profile picture

Eugene

#6
You're welcome.