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

incorrect EMA value when coding DiNapoli MACD

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

    incorrect EMA value when coding DiNapoli MACD

    Hi,
    I am afraid I need help.

    I am attempting to code the MACD indicator from Joe DiNapoli (see attached MSWord document- slightly different from the standard MACD as uses periods which are not integers for the Exponential Moving Averages (he uses 8.3896, 17.5185, etc).
    The periods are actually more easily expressed when converted as smoothing factors (the conversion formula being
    smoothing factor SF is SF = 1 / (Period+1)). I have used the smoothing factors in my code rather than the periods.


    NB: I checked the NT forum: there are a couple of threads on DiNapoli but -from the comments- the confidence level that the code provided uses the accurate parameters seems low.


    I attach the code I ended up writing.
    • The code compiles and plots w/o problem
    • But my 2 intermediate exponential moving averages (EMA1 and EMA2) are calculating wrong values and therefore the plot is wrong
      • I printed them in the output window and the value seems to increase consistently over time bearing no resemblance with the price action (and EMA1 and EMA2 being moving averages, they should be correlated to the price)
      • The values are also vastly different when compared to NT7 default EMA indicator using neighboring integer values of 8 and 17 instead of the exact 8.3896 and 17.5185
      • Therefore, I am pretty sure I made an error in my code (I am new to NT and C#)


    Would anyone see where I got my code wrong?

    Any and all help is appreciated
    Many thanks,

    Kind Regards
    Attached Files

    #2
    Hello jerome_h,

    Welcome to the NinjaTrader forums and thank you for sharing the details of your project.

    Hopefully other community members can take a look and offer input here. As discussed by email, you can always consider a NinjaScript consultant to code this for you.
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by WHICKED, Today, 12:45 PM
    2 responses
    18 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by GussJ, 03-04-2020, 03:11 PM
    15 responses
    3,274 views
    0 likes
    Last Post xiinteractive  
    Started by Tim-c, Today, 02:10 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    3 views
    0 likes
    Last Post Taddypole  
    Started by chbruno, 04-24-2024, 04:10 PM
    4 responses
    51 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Working...
    X