• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 saeed, Today, 12:32 PM
        3 responses
        19 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by motog4, Today, 11:42 AM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by derivtrader, Today, 11:20 AM
        5 responses
        26 views
        0 likes
        Last Post derivtrader  
        Started by TAJTrades, Today, 10:34 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by timcjpfx, Today, 10:20 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X