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 CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    58 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    34 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    195 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    361 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    281 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X