Hi,
I have a problem while using lean indicators ... they don't match with metatrader indicators
I want to compare indicators values using Lean vs using Metatrader
I started with Moving average(1), and moving average(5) , they are matched in lean and metatrader
I had to put EURUSD.csv downloaded from FXCM for time frames (Day-H1) then formatted it in order to enable Lean read it .. also, it is GMT -5 in both metatrader and Lean
Please see Excel image for comparison : https://ibb.co/cNW96K6
The problem is Moving averages are matched But RSI and MACD are not the same ...
I have saved the values on day open in excel for both metatrader and Lean
Any help would be appreciated
Eman Samy
using System; using QuantConnect.Data.Market; using QuantConnect.Indicators; namespace QuantConnect.Algorithm.CSharp { public class ForexRSICrossAlgorithm : QCAlgorithm { private string _symbol = "EURUSD"; private DateTime _previous; private RelativeStrengthIndex RSI_; private MovingAverageConvergenceDivergence _macd; private SimpleMovingAverage _fast_MA; private SimpleMovingAverage _slow_MA; int RSI_per = 14; int fast_period = 1; int slow_period = 5; public override void Initialize() { SetStartDate(2017, 02, 01); SetEndDate(2020, 05, 01); AddForex(_symbol, Resolution.Daily, Market.FXCM); RSI_ = RSI(_symbol, RSI_per, MovingAverageType.Simple, Resolution.Daily); _macd = MACD(_symbol, 12, 26, 9, MovingAverageType.Exponential, Resolution.Daily); _fast_MA = SMA(_symbol, fast_period, Resolution.Daily); _slow_MA = SMA(_symbol, slow_period, Resolution.Daily); var dailyHistory = History(30, Resolution.Daily); } public void OnData(TradeBars data) { // a couple things to notice in this method: // 1. We never need to 'update' our indicators with the data, the engine takes care of this for us // 2. We can use indicators directly in math expressions // 3. We can easily plot many indicators at the same time // wait for our slow ema to fully initialize if (!RSI_.IsReady) return; if (!_macd.Signal.IsReady) return; if (!_slow_MA.IsReady) return; // only once per day if (_previous.Date == Time.Date) return; // define a small tolerance on our checks to avoid bouncing var holdings = Portfolio[_symbol].Quantity; Log(" ,"+Time.Date + ","+_fast_MA + "," + _slow_MA + "," + RSI_ + "," + _macd + "," + _macd.Signal); _previous = Time; } } }
The code used in Lean
Shile Wen
Hi Eman,
What moving average types does MetaTrader use for RSI and MACD? However, for now, feel free to try out our complete list of MovingAverageTypes for the indicators.
Best,
Shile Wen
Mony Samy
Hi Shile Wen
This is Eman Samy.. but with another account by mistake
Thank you for your reply and your help
I found there are "Eleven type" of moving average types ..
For RSI .. Wilder moving average is the nearest value compared to metatrader result
For MACD and MACD Signal .. Exponential moving average is the nearest ..
Althogh the are not the same, but have the nearset values compared to other MA types
Thanks again
Eman Samy
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!