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

Compare EMA of price with EMA of "price´s" cum delta

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

    Compare EMA of price with EMA of "price´s" cum delta

    Hello,

    does anybody can help me, how can I compare e.g. e-mini NQ´s EMA with EMA of NQ´s cumulative delta? Of course, how to write it as a script...

    Thank you

    #2
    Hello emuns,

    Thank you for your post.

    Here's an example of an indicator that would compare the EMA of an instrument to the EMA of that instrument's cumulative delta:

    Code:
            private EMA EMA1;
            private OrderFlowCumulativeDelta OrderFlowCumulativeDelta1;
            private EMA EMA2;
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Enter the description for your new custom Indicator here.";
                    Name                                        = "EMADelta";
                    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;
                    EMA1Period                    = 10;
                    AddPlot(Brushes.OrangeRed, "EMA1");
                    AddPlot(Brushes.DarkTurquoise, "EMACumDelta");
                }
                else if (State == State.Configure)
                {
                    // A 1 tick data series must be added to the OnStateChange() as the OF Cumulative Delta indicator runs off of tick data
                     AddDataSeries(Data.BarsPeriodType.Tick, 1);
                }
                else if (State == State.DataLoaded)
                {
                    EMA1                = EMA(Close, EMA1Period);
                    OrderFlowCumulativeDelta1                = OrderFlowCumulativeDelta(Close, NinjaTrader.NinjaScript.Indicators.CumulativeDeltaType.BidAsk, NinjaTrader.NinjaScript.Indicators.CumulativeDeltaPeriod.Session, 0);
                    EMA2                = EMA(OrderFlowCumulativeDelta1.DeltaClose, EMA1Period);
                }
            }
    
            protected override void OnBarUpdate()
            {
                if (BarsInProgress != 0)
                    return;
    
                if (CurrentBars[0] < 1)
                return;
    
                if (BarsInProgress == 0)
                {
                    if (EMA1[0] > EMA2[0])
                    {
                    }
                }
                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
            [NinjaScriptProperty]
            [Range(1, int.MaxValue)]
            [Display(Name="EMA1Period", Description="EMA Period", Order=1, GroupName="Parameters")]
            public int EMA1Period
            { get; set; }
    
            #endregion
    We have a number of resources you may find helpful, so here are some that may help you as you learn to create NinjaScript indicators and strategies:

    A link to our Help Guide can be found below: https://ninjatrader.com/support/help...injascript.htm

    I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript: https://ninjatrader.com/support/help..._resources.htm

    You will find Reference Samples online as well as some Tips and Tricks for both indicators and strategies:
    Click here to see our NinjaScript Reference Samples: https://ninjatrader.com/support/help...ce_samples.htm
    Click here to see our NinjaScript Tips: https://ninjatrader.com/support/help...en-us/tips.htm

    These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

    There is also a growing library of user submitted custom indicators (100+) that can be downloaded from the NinjaTrader Ecosystem User App Share page: https://ninjatraderecosystem.com/user-app-share/

    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    Last edited by NinjaTrader_Kate; 04-29-2019, 11:59 AM.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello Kate,

      thank you very much for your help. I just wonder why you compare "close" and "open" in your script...? I mean this part:

      EMA1 = EMA(Close, EMA1Period);
      OrderFlowCumulativeDelta1 = OrderFlowCumulativeDelta(Close, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Type.BidAsk, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Period.Session, 0);
      EMA2 = EMA(OrderFlowCumulativeDelta1.DeltaOpen, EMA1Period);

      Thank you again,
      emuns

      Comment


        #4
        Hello emuns,

        Thank you for your reply.

        That was a typo on my part, should be .DeltaClose. I've updated my original reply.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        11 responses
        39 views
        0 likes
        Last Post cmtjoancolmenero  
        Started by FrazMann, Today, 11:21 AM
        0 responses
        5 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        26 views
        0 likes
        Last Post DayTradingDEMON  
        Started by George21, Today, 10:07 AM
        1 response
        22 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X