is it possible to use stored indicator instances on secondary time frames, or must the indicator be instantiated with each on-bar-update? If you could review the attached and let me know if I've done something wrong, I would greatly appreciate it.
Example attached. Strategy adds a secondary time frame of one minute. I create two instances of SMA(50), one on primary series (plot SMA0) and one on secondary series plot SMA1) . For demonstration purposes I also add plot SMA2 and SMA3 which are a SMA(50) instantiated on bar update for each series. So, 4 plots in total. Red, orange, yellow, green.
When activating the strategy on a 5-minute chart, I would expect Red and Yellow to plot together (tracking SMA 50 primary series) , and Orange and Green to plot together (tracking SMA 50 on secondary series). But the result is that only the green plot which is not using a stored indicator-instance plots the correct secondary-bar-series value.
I've attached a screenshot with the data box showing that plot SMA1 (which I want to show the same value as SMA3) is instead using the primary dataseries and getting the same values as those plots instead.
snippet:
//…... AddPlot(Brushes.Red, "SMA0"); AddPlot(Brushes.Orange, "SMA1"); AddPlot(Brushes.Yellow, "SMA2"); AddPlot(Brushes.Green, "SMA3"); } else if (State == State.Configure) { AddDataSeries(Data.BarsPeriodType.Minute, 1); sma0 = SMA(50); // an SMA using the primary bar series sma1 = SMA(BarsArray[1], 50); // an SMA using the 1-minute bar series? } } protected override void OnBarUpdate() { //Add your custom strategy logic here. if (BarsInProgress == 0) { if (CurrentBar > 50 && sma0.IsValidDataPoint(0)) SMA0[0] = sma0[0]; //set red plot using primary bar series if (CurrentBar > 50 && sma1.IsValidDataPoint(0)) SMA1[0] = sma1[0]; //set orange plot using bar series 1 if (SMA(50).IsValidDataPoint(0) && CurrentBar > 50) SMA2[0] = SMA(50)[0]; // set yellow plot using primary bar series } if (BarsInProgress == 1) { if (SMA(50).IsValidDataPoint(0) && CurrentBar > 50) SMA3[0] = SMA(50)[0]; // set green plot using bar series 1 } }
Comment