I tried:
class MyStrategy {
void OnStateChange() {
if (State == State.Configure) {
AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Day, Value = 1 }, 0, "Default 24 x 7", false); //my empty bars object
}
}
void OnBarChange(){
if (BarsInProgress == 0){
Bars myBars = BarsArray[1];
//logic to add bars
myBars.Add( ...);
myBars.Update( ... );
//use in indicator
SMA sma = SMA(myBars, 14);
//more logic ...
}
}
}
Also it appears myBars.CurrentBar increases for each OnBarChange, even if I don't manually add any bars to myBars.
What is the best practice to generate an in-memory array at runtime, like a Bars object, that can be used by various indicators?
note: I don't know the final count of generated bars ahead of time.
Thank you!

Comment