public class Test Dataseries : Indicator { private SMA MA_1_20, MA_5_20, MA_60_20, MA_240_89; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "Test Dataseries"; Calculate = Calculate.OnPriceChange; IsOverlay = true; AddPlot(Brushes.Yellow, "SMA_1_20"); //[0] AddPlot(Brushes.Orange, "SMA_5_20"); //[1] AddPlot(Brushes.Blue, "SMA_60_20"); //[2] AddPlot(Brushes.Cyan, "SMA_240_89"); //[3] } else if (State == State.Configure) { AddDataSeries(Data.BarsPeriodType.Minute, 5); AddDataSeries(Data.BarsPeriodType.Minute, 60); AddDataSeries(Data.BarsPeriodType.Minute, 240); } else if (State == State.DataLoaded) { MA_1_20 = SMA(Close, 20); MA_5_20 = SMA(Closes[1], 20); MA_60_20 = SMA(Closes[2], 20); MA_240_89 = SMA(Closes[3], 20); } } protected override void OnBarUpdate() { if (BarsInProgress != 0) return; // Debug statement to check the status of each data series for (int i = 0; i <= 3; i++) { Print("Data Series [" + i + "] CurrentBars: " + (CurrentBars.Length > i ? CurrentBars[i].ToString() : "Not Initialized")); } // Check if all data series have received at least one bar update if (CurrentBars[0] < 2 || CurrentBars[1] < 1 || CurrentBars[2] < 1 || CurrentBars[3] < 1) return; Values[0][0] = MA_1_20[0]; Values[1][0] = MA_5_20[0]; Values[2][0] = MA_60_20[0]; Values[3][0] = MA_240_89[0]; Print (" "); } }
Data Series [0] CurrentBars: 20377
Data Series [1] CurrentBars: -1
Data Series [2] CurrentBars: -1
Data Series [3] CurrentBars: -1
Data Series [0] CurrentBars: 20377
Data Series [1] CurrentBars: -1
Data Series [2] CurrentBars: -1
Data Series [3] CurrentBars: -1
Data Series [0] CurrentBars: 20377
Data Series [1] CurrentBars: -1
Data Series [2] CurrentBars: -1
Data Series [3] CurrentBars: -1
How can I fix it so, that all 4 plots are visible in the chart?
Thank you!!!
Comment