I'm successfully using the below indicator script on an NQ chart while additionally having an ES 1 tick chart open. The code works fine for a short period of time but then typically freezes up within the hour and I'll have to reboot the system. What's intended to be accomplished using OnBarUpdate is to plot ES's cumulative delta in the form of a line on another instrument (NQ, YM, ETY, etc.(. Can you please advise if there's a way to better capture plotting this which isn't as system intensive?
#region Using declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.SuperDom; using NinjaTrader.Gui.Tools; using NinjaTrader.Data; using NinjaTrader.NinjaScript; using NinjaTrader.Core.FloatingPoint; using NinjaTrader.NinjaScript.DrawingTools; #endregion //This namespace holds Indicators in this folder and is required. Do not change it. namespace NinjaTrader.NinjaScript.Indicators { public class TickCloseNQCurrentBarESNormalize : Indicator { protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "TickCloseNQCurrentBarESNormalize"; Calculate = Calculate.OnBarClose; IsOverlay = false; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; AddPlot(Brushes.DarkGreen, "Line"); IsAutoScale = false; IsOverlay = false; IsSuspendedWhileInactive = true; IsChartOnly = true; BarsRequiredToPlot = 20; } else if (State == State.Configure) { AddDataSeries("ES 06-24", Data.BarsPeriodType.Tick, 1, Data.MarketDataType.Last); } } protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < BarsRequiredToPlot ||CurrentBars[1] < BarsRequiredToPlot ) return; Value[0] = OrderFlowCumulativeDelta(BarsArray[1], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).DeltaClose[0]; } public Series<double> Upper { get { return Values[0]; } } } } #region NinjaScript generated code. Neither change nor remove. namespace NinjaTrader.NinjaScript.Indicators { public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase { private TickCloseNQCurrentBarESNormalize[] cacheTickCloseNQCurrentBarESNormalize; public TickCloseNQCurrentBarESNormalize TickCloseNQCurrentBarESNormalize() { return TickCloseNQCurrentBarESNormalize(Input); } public TickCloseNQCurrentBarESNormalize TickCloseNQCurrentBarESNormalize(ISeries<double> input) { if (cacheTickCloseNQCurrentBarESNormalize != null) for (int idx = 0; idx < cacheTickCloseNQCurrentBarESNormalize.Length; idx++) if (cacheTickCloseNQCurrentBarESNormalize[idx] != null && cacheTickCloseNQCurrentBarESNormalize[idx].EqualsInput(input)) return cacheTickCloseNQCurrentBarESNormalize[idx]; return CacheIndicator<TickCloseNQCurrentBarESNormalize>(new TickCloseNQCurrentBarESNormalize(), input, ref cacheTickCloseNQCurrentBarESNormalize); } } } namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns { public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase { public Indicators.TickCloseNQCurrentBarESNormalize TickCloseNQCurrentBarESNormalize() { return indicator.TickCloseNQCurrentBarESNormalize(Input); } public Indicators.TickCloseNQCurrentBarESNormalize TickCloseNQCurrentBarESNormalize(ISeries<double> input ) { return indicator.TickCloseNQCurrentBarESNormalize(input); } } } namespace NinjaTrader.NinjaScript.Strategies { public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase { public Indicators.TickCloseNQCurrentBarESNormalize TickCloseNQCurrentBarESNormalize() { return indicator.TickCloseNQCurrentBarESNormalize(Input); } public Indicators.TickCloseNQCurrentBarESNormalize TickCloseNQCurrentBarESNormalize(ISeries<double> input ) { return indicator.TickCloseNQCurrentBarESNormalize(input); } } } #endregion
Comment