How to display a counter?

MovingAverage = MA(Close,20);
Event = Close > MovingAverage;
Counter = Cum(Event);

How do I display the final value of Counter for a specific time period? It seems like a Scan or Backtest is required to specify a time period. Can I run a scan and display the value of Counter?

The following code worked when run as an Exploration.

MovingAverage = MA(Close,20);
Event = Close > MovingAverage;
RangeBar = Status("barinrange");
Counter = Cum(IIf(RangeBar, Event, 0));
Filter = Status("lastbarinrange");
AddColumn(Counter, "Counter", 1.0 );

instead of IIF(),
you can do

Counter = Cum( RangeBar AND Event);
1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.