Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question about EMA Calculation.

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

    Question about EMA Calculation.

    Hello. I am trying to adapt a pinescript code for NT8. I am having a rather incomprehensible difficulty with EMAs. Indeed, although the bar data are identical, the ema function of pinescript and that of ninjatrader do not return the same result.
    So my stupid question: are there several ways to calculate an EMA? Does each platform have its own?
    For example, here are the differences between TradingView (TW) and NinjaTRADER 8 (NT8): And this difference goes well beyond the rounding of decimals.
    Code:
    TW: 20409.74 NT8: 20410.55
    TW: 20356.14 NT8: 20356.79
    TW: 20310.51 NT8: 20311.03
    TW: 20321.41 NT8: 20321.83
    TW: 20441.98 NT8: 20442.31​

    Please help me understand

    #2
    Finally, I don't know if the EMAs are calculated differently but comparing the logs allowed me to see that the open data are the same but a "weirdness" in TRdaingView.

    TradingView :
    Code:
    2024-10-15T00:00:00.000+02:00 ;Open : 20637.5 ;EMA(9) : 20345.0939209805
    2024-10-16T00:00:00.000+02:00 ;Open : 20340 ;EMA(9) : 20344.0751367844
    2024-10-17T00:00:00.000+02:00 ;Open : 20332 ;EMA(9) : 20341.6601094275
    2024-10-18T00:00:00.000+02:00 ;Open: 20385.5 ;EMA(9): 20350.428087542
    2024-10-21T00:00:00.000+02:00 ;Open: 20495.75 ;EMA(9): 20379.4924700336
    2024-10-22T00:00:00.000+02:00 ;Open: 20518.25 ;EMA(9): 20407.2439760269
    2024-10-23T00:00:00.000+02:00 ;Open: 20522.75 ;EMA(9): 20430.3451808215
    2024-10-24T00:00:00.000+02:00 ;Open: 20299.5 ;EMA(9): 20404.1761446572
    2024-10-25T00:00:00.000+02:00 ;Open: 20385 ;EMA(9): 20400.3409157258
    2024-10-27T23:00:00.000+01:00 ;Open: 20524 ;EMA(9): 20425.0727325806
    2024-10-28T23:00:00.000+01:00 ;Open: 20508 ;EMA(9) : 20441.6581860645 **** NOT ON CHART ***
    2024-10-29T23:00:00.000+01:00 ;Open : 20725 ;EMA(9) : 20498.3265488516
    2024-10-30T23:00:00.000+01:00 ;Open : 20486 ;EMA(9) : 20495.8612390813
    2024-10-31T23:00:00.000+01:00 ;Open : 20065.25 ;EMA(9) : 20409.738991265
    2024-11-01 **** NOT IN LOG BUT ON THE CHART ***
    2024-11-04T00:00:00.000+01:00 ;Open: 20141.75 ;EMA(9): 20356.141193012
    2024-11-05T00:00:00.000+01:00 ;Open: 20128 ;EMA(9): 20310.5129544096
    2024-11-06T00:00:00.000+01:00 ;Open: 20365 ;EMA(9): 20321.4103635277
    2024-11-07T00:00:00.000+01:00 ;Open: 20924.25 ;EMA(9): 20441.9782908222
    2024-11-08T00:00:00.000+01:00 ;Open: 21225 ;EMA(9): 20598.5826326577​
    NinjaTrader :
    Code:
    2024-10-15 23:00:00;OPen: 20637.5;EMA(9): 20343.5763065492
    2024-10-16 23:00:00;OPen: 20340;EMA(9): 20344.7610452393
    2024-10-17 23:00:00;OPen: 20332;EMA(9): 20349.4088361915
    2024-10-18 23:00:00;OPen: 20385.5;EMA(9): 20376.2270689532
    2024-10-21 23:00:00;OPen: 20495.75;EMA(9): 20404.8816551625
    2024-10-22 23:00:00;OPen: 20539;EMA(9): 20432.30532413
    2024-10-23 23:00:00;OPen: 20522.75;EMA(9): 20389.944259304
    2024-10-24 23:00:00;OPen: 20299.5;EMA(9): 20388.0054074432
    2024-10-25 23:00:00;OPen: 20385;EMA(9): 20410.1543259546
    2024-10-28 22:00:00;OPen: 20524;EMA(9): 20427.5234607637
    2024-10-29 22:00:00;OPen: 20508;EMA(9): 20481.3187686109
    2024-10-30 22:00:00;OPen: 20725;EMA(9): 20492.0050148887
    2024-10-31 22:00:00;OPen: 20486;EMA(9): 20397.954011911
    2024-11-01 22:00:00;OPen: 20065.25;EMA(9): 20349.0132095288
    2024-11-04 23:00:00;OPen: 20141.75;EMA(9): 20296.410567623
    2024-11-05 23:00:00;OPen: 20128;EMA(9): 20305.4784540984
    2024-11-06 23:00:00;OPen: 20365;EMA(9): 20423.1827632787
    2024-11-07 23:00:00;OPen: 20924.25;EMA(9): 20583.496210623​

    Comment


      #3
      Hello noabai,

      Thank you for your post.

      While our team can't comment on how other platforms calculate their EMA, you can see the open-source code for NinjaTrader's EMA in the NinjaScript Editor.

      If you have questions about TradingView's EMA, I suggest you reach out to them directly for clarification on how it is calculated.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 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
      546 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X