New EA based on the !xMeter - page 37

 

Zero divide error

venox250:
That's the problem... I did have some "zero divide" errors but couldn't track them and they didn't appear for the last 4 weeks. If you could track it down it would be nice (though it requires some MQL4 knowledge and is risky on a live account).

To fix it You should restart the EA (remove and reattach with same settings). If You get zero divide again than You shouldn't be using xMeter for a while and have to manage that open position manually.

Hope restarting will solve Your problem.

Mr. Venox,

This error caused as the expert calculate the strengh of the "coin" - you have an expresion which divide the HIGH and the LOW. if (HIGH - LOW)=0 then you get it.

You have to put IF, that checks that (HIGH-LOW) is not equal to zero.

Good luck.

 
crossy:
Mr. Venox,

This error caused as the expert calculate the strengh of the "coin" - you have an expresion which divide the HIGH and the LOW. if (HIGH - LOW)=0 then you get it.

You have to put IF, that checks that (HIGH-LOW) is not equal to zero.

Good luck.

Could You, please, insert a code snippet here from the EA or tell me which line(s) do You refer to?

If You mention this part of the code:

aRange = MathMax((aHigh - aLow) / point, 1); //--- Calculate range aRatio = (aAsk - aLow) / aRange / point; //--- Calculate pair's ratio and inverse ratio

then here the divisor is guaranteed to be non-zero. Also all the further divisions seems "protected" to me (but obviously there must be one which isn't). If You found it, please tell me exactly where it is.

Thanks

 

Yes

venox250:
Could You, please, insert a code snippet here from the EA or tell me which line(s) do You refer to?

If You mention this part of the code:

aRange = MathMax((aHigh - aLow) / point, 1); //--- Calculate range aRatio = (aAsk - aLow) / aRange / point; //--- Calculate pair's ratio and inverse ratio

then here the divisor is guaranteed to be non-zero. Also all the further divisions seems "protected" to me (but obviously there must be one which isn't). If You found it, please tell me exactly where it is.

Thanks

The origion code is:

aRange = MathMax((aHigh - aLow) / point, 1); //--- Calculate range

aRatio = (aAsk - aLow) / aRange / point; //--- Calculate pair's ratio and inverse ratio

Between add the line:

if(aRange != 0.0)

that's it.

Good luck

 
crossy:
The origion code is:

aRange = MathMax((aHigh - aLow) / point, 1); //--- Calculate range

aRatio = (aAsk - aLow) / aRange / point; //--- Calculate pair's ratio and inverse ratio

Between add the line:

if(aRange != 0.0)

that's it.

Good luck

Man, I don't think we should argue on this The aRange[] variable is guaranteed to be >= 1 due to the MathMax(..., 1) function call. So Your 'if' condition is redundant and will never be false.

By the way, thanks for trying to help.

 
venox250:
Man, I don't think we should argue on this The aRange[] variable is guaranteed to be >= 1 due to the MathMax(..., 1) function call. So Your 'if' condition is redundant and will never be false. By the way, thanks for trying to help.

You are the MAN. ou right!!!, But, you know, since I did it I have never got this error again..! (???). Try it, too.

 

I had to FXF into suffix. Now I have display and everything looks OK but no trades in two days?

 
crossy:
You are the MAN. ou right!!!, But, you know, since I did it I have never got this error again..! (???). Try it, too.

This made me think... If what You tell is true (I mean: that 'if' solved the issue) then the only reason can be that the element of the array does not exist sometimes. The aRange[] array is a dynamic array and sometimes it might have less elements than it is necessary. In this case MQL simply returns the default value (which is 0 for number types) when referring to the unexisting element.

I will check the code to see if the allocated number of items might be less than necessary in some cases.

Thanks for the tip

 
pmacel:
I had to FXF into suffix. Now I have display and everything looks OK but no trades in two days?

Check the 'experts' tab. As a first guess I think that Your SpreadLimit setting doesn't allow trading on any pair. However, the EA might have bugs when using suffixed symbols (I didn't test this case).

 

Could you check on that suffix. It is trading OK on Alpari but not Forex.com. Forex.com is using FXF.

 
pmacel:
Could you check on that suffix. It is trading OK on Alpari but not Forex.com. Forex.com is using FXF.

Do You have any messages in the experts tab of Your MetaTrader? This is too less information to me to start debugging.

Reason: