Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    576 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X