Back

MACD value from indicator VS calculated by ema12 - ema 16

Hi, I notice there is difference between macd value form indicator and the value calculated by ema12 - ema26.

Heres part of the log:
2020-05-22 15:40:00 --------2020-05-22 15:40:00--------
2020-05-22 15:40:00 macd : -0.008374069561719998
2020-05-22 15:40:00 calculated mamcd : -0.008374069561718045
2020-05-22 15:41:00 --------2020-05-22 15:41:00--------
2020-05-22 15:41:00 macd : -0.006118039300951868
2020-05-22 15:41:00 calculated mamcd : -0.006118039300943678
2020-05-22 15:42:00 --------2020-05-22 15:42:00--------
2020-05-22 15:42:00 macd : -0.0052779239764075845
2020-05-22 15:42:00 calculated mamcd : -0.005277923976407806
2020-05-22 15:43:00 --------2020-05-22 15:43:00--------
2020-05-22 15:43:00 macd : -0.010223384346335481
2020-05-22 15:43:00 calculated mamcd : -0.01022338434633241
2020-05-22 15:44:00 --------2020-05-22 15:44:00--------
2020-05-22 15:44:00 macd : -0.011109732108001662
2020-05-22 15:44:00 calculated mamcd : -0.011109732108003811

Although the difference is so small that it probably wont affect our algorithm, it is still a nice thing to know why there is a difference? Does anyone have any idea?

Update Backtest








0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Tai Man Chan,

The MACD's value and the one we calculate with the EMAs differ because the former is computed in C# while the latter in Python. These languages use different precision/rounding, so we see some discrepancies. We can resolve this by rounding both values to <=13 decimal places.

round(self.macd.Current.Value, 13)
round(self.ema12.Current.Value - self.ema26.Current.Value, 13)

Best,
Derek Melchin

1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Thank you so much

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed