Reproducing MQL4 iBarShift Behavior in MQL5
Summary
The document discusses replacing MQL4’s iBarShift function in MQL5. It says MQL5 provides lower-level functions for implementing the same operation and reviews four community versions written as alternatives. According to the author, those versions return incorrect results when the requested time does not match a candle’s opening time, so they do not fully reproduce MQL4 behavior.
The author describes testing the alternatives for accuracy and speed, then developing a replacement and providing a benchmark script. The document gives no benchmark measurements or implementation details in the text, so readers cannot compare performance or assess the replacement’s exact behavior from this description alone. It also notes that iBarShift may not be the best fit for every MQL5 task; the appropriate approach depends on the algorithm. A later revision addressed a bug involving requests for times later than the most recent bar’s start.
Key ideas
- The document focuses on reproducing MQL4 iBarShift behavior in MQL5.
- The author reports that four existing alternatives mishandle requested times that do not match candle opening times.
- The author says they tested accuracy and speed and created a replacement with a benchmark script.
- The text provides no benchmark results or implementation details for evaluating the replacement.
- The best method for locating bars may depend on the algorithm.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.