I am working on a strategy and I have added a second time frame using the same instrument as the primary data series.
I just want to plot both charts, the primary and the second data series.
This is my code by the second data series ALWAYS plots as 0.
public class TestPlotSeconDataSeries : Strategy { private Series<double> secondarySeries; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @""; Name = "TestPlotSeconDataSeries"; Calculate = Calculate.OnBarClose; EntriesPerDirection = 1; EntryHandling = EntryHandling.AllEntries; IsExitOnSessionCloseStrategy = true; ExitOnSessionCloseSeconds = 30; IsFillLimitOnTouch = false; MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix; OrderFillResolution = OrderFillResolution.Standard; Slippage = 0; StartBehavior = StartBehavior.WaitUntilFlat; TimeInForce = TimeInForce.Gtc; TraceOrders = false; RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose; StopTargetHandling = StopTargetHandling.PerEntryExecution; BarsRequiredToTrade = 20; // Disable this property for performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information IsInstantiatedOnEachOptimizationIteration = true; AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Line, "Plot"); } else if (State == State.Configure) { // Adding second date series //AddDataSeries(Data.BarsPeriodType.Tick, 1); AddDataSeries(Data.BarsPeriodType.Minute, 1); } else if (State == State.DataLoaded) { secondarySeries = new Series<double>(BarsArray[1]); } } protected override void OnBarUpdate() { if (CurrentBars[0] < 1 || CurrentBars[1] < 2) return; //Add your custom strategy logic here. if(BarsInProgress == 0) Value[0] = secondarySeries[0]; } }
Comment