Weird behavior here.
The previous call, when run in back tests, returns a buffer with n elements, where the first of these elements is the low of bar at initialTime. However, the same call in a demo live account returns n - 1 elements, where the low of the bar at initialTime is not included.
Am I missing something here?
MT5 version is 5.00 build 1596 (26 Apr 2017)
Answering to my own question: Yes, I missed something.
The difference between running this code on backtests and on a live account is the precise timestamp (with precision of seconds) related to "initialTime". In my code "initialTime" is the time when a position is opened. On backtests this timestamp is always at the candle's first second (i.e. some hour:some minute:zero seconds). On a live account this is not the case, so the time when positions are opened are not likely to be at the first second (i.e. some hour:some minute:some non zero seconds).
According to the docs of CopyLow (https://www.mql5.com/en/docs/series/copylow):
"The interval is set and counted up to seconds. It means, the open time of any bar, for which value is returned ... is always within the requested interval."
Thus, this is why the candle where the position was opened was not being counted by Bars. The fix was to "reset" the seconds portion of the timestamp to zero seconds.
- www.mql5.com
lorenooliveira: The fix was to "reset" the seconds portion of the timestamp to zero seconds.
| The fix is to use the start of the bar.t -= t % _Period; Not seconds (think TFs larger then M1.)
|
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Weird behavior here.
The previous call, when run in back tests, returns a buffer with n elements, where the first of these elements is the low of bar at initialTime. However, the same call in a demo live account returns n - 1 elements, where the low of the bar at initialTime is not included.
Am I missing something here?
MT5 version is 5.00 build 1596 (26 Apr 2017)