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

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
    Brandon H.NinjaTrader Customer Service

    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
        Brandon H.NinjaTrader Customer Service

        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 fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          8 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          160 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          9 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X