Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Gaby V.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Jonafare, 12-06-2012, 03:48 PM
    5 responses
    3,985 views
    0 likes
    Last Post rene69851  
    Started by Fitspressorest, Today, 01:38 PM
    0 responses
    2 views
    0 likes
    Last Post Fitspressorest  
    Started by Jonker, Today, 01:19 PM
    0 responses
    2 views
    0 likes
    Last Post Jonker
    by Jonker
     
    Started by futtrader, Today, 01:16 PM
    0 responses
    7 views
    0 likes
    Last Post futtrader  
    Started by Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,792 views
    0 likes
    Last Post aligator  
    Working...
    X