Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Slope of EMA

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

    Slope of EMA

    I am trying to use the slope of the EMA line as a condition in an order script. Basically I want to know if the EMA has peaked between current bar and, say, second prior bar and is now on a negative slope. I've tried basic stuff like:

    bool slopeEma = EMA(9)[0] - EMA(9)[2] < 0

    Doesn't work though. Is it possible to calculate what I am trying to get?

    #2
    Hello bgump55,

    Thanks for your post.

    The Slope() method could be used to get the slope of an indicator plot.

    You could consider saving the Slope() value of the EMA to a custom Series<double> object named something like "EMASlope" if you want to compare the current Slope value to the previous Slope value.

    For example, EMASlope[0] > EMASlope[1] would compare the current value to the previous value.

    See this help guide page for more information about Slope() and sample code: https://ninjatrader.com/support/help.../nt8/slope.htm

    See this help guide page for more information about custom Series objects: https://ninjatrader.com/support/help...t8/seriest.htm
    Last edited by NinjaTrader_BrandonH; 02-04-2024, 06:21 PM.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    87 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    118 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X