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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X