Re: Counting bars since a specific event
- There are two things you could try to employ:
1. Count bars from the beginning:
def currBar = TotalSum(1);
2. Use "freeze" command to preserve this count when the event
triggers. The difference between the two could give you "BarsSince"
--- In TOS_thinkscript@yahoogroups.com, "Erik" <erikc@...> wrote:
> Anyone know how to count the number of bars in ThinkScript from an
> Specifically, what I'm trying to do is trigger a buy signal from 3
> higher closing bars. Easy enough, but I don't want them to have to
> be all in a row. I want to allow the stock to chop around a while,
> and still fire a signal on the 3rd high close.
> Also, any price below the low of the first bar in the sequence
> reset everything, and start counting over.
> There seems to be a requirement of an "ELSE" parameter in an IF
> statement with ThinkScript. So after the first higher close sets
> appropriate trigger price/stopout price, the next bar (if it
> make another higher high) will reset the thing, because my IF close
> close statement will be false, and the ELSE kicks in, resetting
> to zero.
> If I could reference "close[NumberOfBars]" via a counter of some
> sort, I could reference back to the first bar, no matter how long
> Alternatively, if I could say "IF blah-blah, ELSE don't do a damn
> thing", that would also work.
> Any thoughts? It certainly feels like I'm missing something very,
> very simple, but I'm going nuts here.