Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help Please: Indicator To Plot Different Symbol's Delta

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help Please: Indicator To Plot Different Symbol's Delta

    Hello,

    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?

    Code:
    #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
    ​
    Thanks!

    #2
    Hello jeh007258,

    Thank you for your post.

    As far as performance, I don't see anything in the code that is particularly complex or resource intensive. It may that your current PC has low resources. Are you able to test on a different PC, with no other charts or workspaces open?

    I would like to note that you do need to call update from BarsInProgress 1. This is demonstrated in a code snippet from the Help Guide page for OFCD:



    Please let us know if you have any further questions.

    Comment


      #3
      NinjaTrader_Gaby thank you. BarsInProgress did the trick

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      595 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      343 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      556 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      554 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X