Zero divide after EA / MT4 restart
-
Hello,
I am testing an EA to ensure it can cope with an MT4 restart.
After a restart I am getting zero divide errors.
The first is in a custom mql block at the point:- MarketInfo(Symbol(),MODE_TICKVALUE)
It finds the correct value when run normally but after a restart it returns zero. (I have got it to write to the log on restart).If I remove that piece of code it then gets stuck on an internal function LotStep.
lowerlots = MathRound(lowerlots/LotStep)*LotStep;
which can be traced back to:-
double LotStep = SymbolInfoDouble(symbol, SYMBOL_VOLUME_STEP);
Again it is the SYMBOL_VOLUME_STEP that is returning a zero.
Any ideas why this would work on first load but not after a restart ?
Many thanks
-
you can avoid this issue with adding if else statement ...
double LotStep = SymbolInfoDouble(symbol, SYMBOL_VOLUME_STEP);
if (LotStep != 0)
{ lowerlots = MathRound(lowerlots/LotStep)*LotStep; }
else { lowerlots = some_default_value; ) -
Works great, many thanks.