Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating slope on 9ema across last 3 candles

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

    Calculating slope on 9ema across last 3 candles

    slope = EMA(9)[0] - EMA(9)[2];
    slope = slope / 3;​

    Is that correct? TY!

    #2
    Hello cay7man,

    Are you trying to use the Slope function or recreate the math described in the slope functions help guide page?

    If you are trying to recreate what the slope calculation does the slope uses the following math:

    (series[endBarsAgo] - series[startBarsAgo]) / (startBarsAgo - endBarsAgo)

    Which would be

    double slope = (EMA(9)[0] - EMA(9)[2]) / (2 - 0);

    or more simply

    double slope = (EMA(9)[0] - EMA(9)[2]) / 2;

    Comment


      #3
      I'm not using the slope function. As in subject, I want slope of last 3 candles. In the formula above why divide by 2? TY!

      Comment


        #4
        Hello cay7man,

        I don't know what math you are trying to do with what you posted, if that is some kind of slope math you found online you can try that and see if the result is what you want. The only Slope in NinjaTrader is the Slope function which is the equation I posted in post 2. If you are trying to use that functions math then the division would be by 2 based on the code you provided using 2 bars ago. the start bars ago and end bars ago are used for the division. 2 minus 0 is 2 so the division would be by 2 to match the code you provided and the slope functions math.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        47 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        23 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        33 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        50 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Working...
        X