eabase / mt4pycon

The MT4 Python Connector
MIT License
23 stars 8 forks source link

con2mtapi fails when candle data not yet loaded and available #4

Open eabase opened 3 years ago

eabase commented 3 years ago

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 commented 3 years ago

Just for reference:

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.)