mt4pycon icon indicating copy to clipboard operation
mt4pycon copied to clipboard

con2mtapi fails when candle data not yet loaded and available

Open eabase opened this issue 4 years ago • 1 comments

When running the script for the first time on a certain symbol and timeframe, the candle data will not be available in the MT4 terminal buffer, so the script will fail.

The solution is to just run it again and MT4 will most likely have already downloaded the new data. However, I have not been able to resolve this issue.

eabase avatar Nov 14 '20 10:11 eabase

Just for reference:

  • https://www.mql5.com/en/forum/86576/page2
  • https://www.mql5.com/en/forum/158938/page3
  • https://www.mql5.com/en/forum/160249
  • https://www.mql5.com/en/forum/167505

From here:

If data (symbol name and/or timeframe differ from the current ones) are requested from another chart, the situation is possible that the corresponding chart was not opened in the client terminal and the necessary data must be requested from the server. In this case, error ERR_HISTORY_WILL_UPDATED (4066 - the requested history data are under updating) will be placed in the last_error variable, and one will has to re-request

So:

ArrayCopyRates will return an error if there is no history at all (ERR_NO_HISTORY_DATA = 4073.) Repeated calls also fail until the download is complete. When there is history but not up to date, ArrayCopyRates returns valid AND also sets _LastError to ERR_HISTORY_WILL_UPDATED (= 4066.)

eabase avatar Dec 03 '20 22:12 eabase