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.