Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddPlot Cumulative Delta

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

    AddPlot Cumulative Delta

    Hello i want to plot DeltaClose / DeltaOpen. My Script so far.. It isnt plotting.


    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class CumDelta : Indicator
    {
    private OrderFlowCumulativeDelta cumulativeDelta;




    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "CumDelta";
    Calculate = Calculate.OnEachTick;
    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.Blue, "Delta");

    }
    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Tick, 1);
    }

    // else if (State == State.DataLoaded)
    // {
    // cumulativeDelta = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAs k, CumulativeDeltaPeriod.Session, 0);

    // }

    }

    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    {

    }

    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < 5 || CurrentBars[1] < 5)
    return;
    if (BarsInProgress == 0)
    return;



    if (IsFirstTickOfBar)
    {

    double DeltaClose = OrderFlowCumulativeDelta(BarsArray[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).DeltaClose[0];
    double DeltaOpen = OrderFlowCumulativeDelta(BarsArray[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).DeltaOpen[0];



    double DeltaVelocity = DeltaOpen / DeltaClose;
    Delta[0] = DeltaVelocity;


    }

    else if (BarsInProgress == 1)
    {
    // We have to update the secondary series of the cached indicator to make sure the values we get in BarsInProgress == 0 are in sync
    OrderFlowCumulativeDelta(BarsArray[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).Update(OrderFlowCumulativeDelta(BarsArray[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0).BarsArray[1].Count - 1, 1);
    }



    }


    region Properties

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> Delta
    {
    get { return Values[0]; }
    }
    #endregion
    }
    }

    #2
    Hello Lopat,

    Thank you for your post.

    I have tested your script out, and it is plotting as expected for me.

    If the indicator is applied to a chart, is there data with new bars appearing on the chart it is applied to?

    Do you have historical tick data available? Please try opening a tick chart to confirm.

    Try testing the SMA indicator included with NinjaTrader on the same chart. Is this indicator plotting (This would confirm for us data is available and the issue is not with the script).

    I look forward to your response.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    628 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    359 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    562 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X