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);