Mean Reversion EA

 

I have built a very basic reversion ea but have a zero divide error can anyone see where i might have gone wrong. I have been looking at this for days trying to spot the error.

Any help in spotting the error would be greatly appriciated.

Thanks

Files:
z1.mq4  13 kb
zscore6.mq4  3 kb
 

Put code in to check/print your variable values

extern bool DEBUGGING = true

...

if(DEBUGGING && variableName == 0) Print("CodePoint 1 -- This variable is now ", variableName);

... more code

if(DEBUGGING && variableName == 0) Print("CodePoint 2 -- This variable is now ", variableName);

... more code

if(DEBUGGING && variableName == 0) Print("CodePoint 3 -- This variable is now ", variableName);

...

You'll find it.

 
phy:

Put code in to check/print your variable values

extern bool DEBUGGING = true

...

if(DEBUGGING && variableName == 0) Print("CodePoint 1 -- This variable is now ", variableName);

... more code

if(DEBUGGING && variableName == 0) Print("CodePoint 2 -- This variable is now ", variableName);

... more code

if(DEBUGGING && variableName == 0) Print("CodePoint 3 -- This variable is now ", variableName);

...

You'll find it.

Could you please show me an example of what and where it should go. I think i know but i don't want to make things worse
 

The example is above

put in your own names of the variables that are the divisor, and print BEFORE the division occurs

 
Z1.mq4 only has a single division, which uses SL, and which gets sulky if SL is 0.
Reason: