iBarShift - MetaTrader 5 Library | MT5 EA Download - MetaTrader 5 Resources

There are a lot of users who searched for functions like iBarShift in MQL4.
But this function is not included in MQL5, mainly because MQL5 provides all the necessary basic, low-level functions to handle such operations in the library.
As an alternative, some programmers provide their versions of MQL5. I found 4 different versions of Yuanfang , Compster (from the code base), DC 2008 (from the famous article Migration from mql4 to mql5 ) or Marketer (Russian forum).
It is worth noting that I found flaws in all four versions, in the sense that they do not completely reproduce MQL4 iBarShift(). In fact, all versions return wrong values when the datetime given as input parameter does not match the opening of the candle.
So I decided to do some tests on the accuracy and speed of these different features and of course develop my version. You can find the new version library that comes with it and a small script for benchmarking your functions.

As a side note, iBarShift() is not always the best way to implement certain tasks in MQL5. Depending on your algorithm, there could be a better way .
Edited: October 3, 2014. Release of version 1.02 (fixed bug where request time was better than last bar start time).
Attachment download
📎 ibarshift.mqh (3.24 KB)
📎 testbarshift.mq5 (9.01 KB)
Source: MQL5 #1864
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •