I am trying to use OrderFlowCumulativeDelta in a strategy I am experimenting with, I also want to add the delta as an indicator directly from the strategy. "AddChartIndicator" does not seem to do the trick, below is a sample of the code I will mostly use this strategy in a 2000 tick chart.
private OrderFlowCumulativeDelta cumulativeDelta; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Provide trade entry signal using multiple order flow indicators"; Name = "OrderFlowTrader"; Calculate = Calculate.OnEachTick; EntriesPerDirection = 1; EntryHandling = EntryHandling.AllEntries; IsExitOnSessionCloseStrategy = true; ExitOnSessionCloseSeconds = 300; IsFillLimitOnTouch = false; MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix; OrderFillResolution = OrderFillResolution.Standard; Slippage = 1; StartBehavior = StartBehavior.WaitUntilFlat; TimeInForce = TimeInForce.Day; 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; } else if (State == State.Configure) { AddDataSeries(BarsPeriodType.Tick, 1); } else if (State == State.DataLoaded) { cumulativeDelta = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0); AddChartIndicator(cumulativeDelta); } } protected override void OnBarUpdate() { if (BarsInProgress == 1) { cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1); return; } }
Comment