question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with reults of rma moving average

See original GitHub issue

Describe the bug ta.rma() should behave exactly like ta.ema() - with the only difference being the weighting factor. Implementation of ta.rma() in pandas_ta calculates the starting value differently than the implementation of ta.ema() specifically, the first value in the ta.rma() result should be a SMA() average of the period. If the first value is different, the whole series is different…

To Reproduce

df = pd.DataFrame({'close': [1.0,0,-1,0,2,-3,4,5,-8,7,8,9,10,-5,10,0]})
df["rma"]=df.ta.rma(close=df["close"], length=4)
df["ema"]=df.ta.ema(close=df["close"], length=4)

the first value that is not a NaN should be the same for both rma() and ema() - but it is not…

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
mihakraljcommented, Oct 3, 2021

Sounds good. 😊 I did find this discrepancy by getting different data from ATR (average true range) compared to the official example by J. Wilder (the author of both ATR and RMA). Let’s keep the library as it is then, if all other rma-derived indicators are satisfactory for library users. I would not mess with adding another parametric option to make the indicator following the author’s original formula, let’s keep the current simplified version.

1reaction
mihakraljcommented, Apr 21, 2022

Yup, can confirm that you found the data bug in a 42-years old book! 😃 Below is the calc of TR and ATR for the same raw data from the book using my C# lib:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is EMA? How to Use Exponential Moving Average With ...
An exponential moving average (EMA) is a type of moving average that places a greater weight and significance on the most recent data...
Read more >
What Is EMA?- Exponential Moving Average - Fidelity
Exponential Moving Average (EMA) measures trend directions over a period of time. EMA applies more weight to data that is more current and...
Read more >
Here's Why The Exponential Moving Average Will Give You ...
Exponential Moving Average (EMA) technical analysis indicator gives more weight to current prices than past prices and reacts quicker to ...
Read more >
Exponential Moving Average (EMA)
The Exponential Moving Average (EMA) is a technical indicator used in trading practices that shows how the price of an asset or security...
Read more >
Exponential Moving Average | How To Read And Use EMA
EMA reduces the effect of the noise by cutting the time lag of the data. This is because EMA may exclude past prices,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found