Skip to main content


Showing posts from May, 2017

MQL5 indicator artifacts issue

MQL5 indicator buffer random values During my coding of an indicator random values would end up in the index buffer if one would switch time frames. It took me a few hours to figure out that if I didn't explicitly set an empty value this would cause this to happen - so the solution is to always set a value during your OnCalculate() loop both for your empty bars and not. /* OnCalculate =========== Called only in custom indicators when it's necessary to calculate the indicator values by the Calculate event. */ int OnCalculate(const int iRatesTotal, const int iPreviousCalculated ,const datetime &time[] ,const double &aOpen[] ,const double &aHigh[] ,const double &aLow[] ,const double &aClose[] ,const long &tick_volume[] ,const long &volume[] ,const int &spread[]) { Print(">>> OnCalculate(): `iRatesTotal=" + iRatesTotal + "`, `iPreviousCalculated=" + iPreviousCalculated + "`"); //int