Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EMA of the Difference between 2 EMA's

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

    EMA of the Difference between 2 EMA's

    I am trying to smooth the difference of 2 EMA's but can't come up with syntax to allow that to compile:
    Here is the sample code:

    private double high3052;
    private double low3052;
    private double highlowdiff;
    private EMA SmoothDiff;​


    high3052 = EMA(High, 305)[0];
    low3052 = EMA(Low, 305)[0];
    highlowdiff = high3052 - low3052;​

    then I want to do this:
    SmoothDiff = EMA(highlowdiff, 305);

    I get usable values in high3052 and low 3052. highlowdiff is also a usable value. I just can't figure out how to smooth it with an EMA.
    I have tried putting it in a series, plotting it, etc. Any direction you could give would be helpful.




    #2
    Hello cpabiz20k,

    Thanks for your post.

    I see you have posted in the NinjaTrader 7 section of the Forums. To clarify, are you creating an indicator in NinjaTrader 7 or NinjaTrader 8?

    EMA() requires passing in an IDataSeries input and an int period.

    Generally, to smooth a price value you would need to do some form of averaging such as a moving average.

    As a simple way to approach this, you could use an included indicator like the SMA or EMA on the existing plot you have:​

    If you want to pass highlowdiff into EMA() you would need to make this a custom DataSeries object and assign high3052 - low3052 to the custom DataSeries object.

    Then, you could pass highlowdiff into the IDataSeries input argument for EMA().

    An example of this could be seen on this forum thread: https://forum.ninjatrader.com/forum/...00#post1039800

    See the help guide documentation below for more information.

    NT7 DataSeries Class: https://ninjatrader.com/support/help...ries_class.htm
    EMA() https://ninjatrader.com/support/help...onential_e.htm
    <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


      #3
      Thanks for responding Brandon - I goofed up and put this in the 7 forum. I am doing this in 8. Are there any differences in what I should be doing in 8 vs the response for 7?

      Comment


        #4
        Hello cpabiz20k,

        Thanks for your notes.

        I have moved this forum thread to the NinjaTrader Desktop > Indicator Development section of the Forums since you meant to post this question for NinjaTrader 8.

        The same concept would apply in NinjaTrader 8. You would need to do some form of averaging such as a moving average.

        In NinjaTrader 8 the EMA() and SMA() also require that you pass in a Series input value into the methods so you would need to make highlowdiff a custom Series<double> object, assign the calculation to the Series<double> object, and then pass that object into the EMA() or SMA() methods.

        See the NinjaTrader 8 help guide documentation for more information.

        Series<T>: https://ninjatrader.com/support/help...t8/seriest.htm
        EMA(): https://ninjatrader.com/support/help...onential_e.htm
        SMA(): https://ninjatrader.com/support/help...simple_sma.htm
        <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


          #5
          Thanks for your help - once I added the dateseries into the configure section as in your example provided, it worked!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          601 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          347 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          559 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          558 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X