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

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;
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rbeckmann05, Yesterday, 06:48 PM
        1 response
        12 views
        0 likes
        Last Post bltdavid  
        Started by llanqui, Today, 03:53 AM
        0 responses
        6 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        10 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        15 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        11 views
        0 likes
        Last Post carnitron  
        Working...
        X