I keep getting divide by 0 please help
Hi community! I have coded this system and i keep having the error of zero divide in 'my code name'
could you please review my coding, what is the problem here?
Could be helpful if you specify which line produces the error.
I personally check the value of divisor before the divition operation . I do that almost always, unless I am sure that it is imposible that divisor be eual to zero.
As far as I can see, This is the only piece in your code that may result as zero :
double Slpips = MathAbs((entryprice - SL)/pipsCurrency());
You should make sure that entryprice and SL are not equal.
Because it is going to be the divisor in this line:
double positionsize = ((risk/tickvalue) / MathAbs(Slpips*pipsCurrency()) / (Lotsize)) ;
Also, you do not need to calculate the spread, you can just call SymbolInfoInteger using SYMBOL_SPREAD.
- docs.mql4.com
Hi community! I have coded this system and i keep having the error of zero divide in 'my code name'
could you please review my coding, what is the problem here?