zero divide - page 2

 
FYI, this does not happen in previous version of MT4/MQL4. I use similar indicator in the previous version. Perhaps last version call the function in different way.
 
simpleton:

According to the documentation MarketInfo() CANNOT return 0 for the particular parameter.

The fact it does means the quality of MT4 implementation is quite poor.

What if MarketInfo() returns a non-zero but still wrong value?

Do programmers need to calculate the same value MarketInfo() should return themselves and then check whether MarketInfo() returned a proper value and they can trust it or not?

The system functions must strictly adhere their contracts. If documentation says MarketInfo() does not return zero (for a particular parameter) then there is NO division by zero in "1 / MarketInfo()" expression. But you implicitly stated that there is.

This is definitely the bug of MarketInfo(). And therefore a workaround is needed.

Except your are interpreting the documentation. Nowhere it's written that MarketInfo() can't return 0. And the fact is it returns sometimes a zero.

By the way, this is senseless discussion. When are you dividing in your code, it's up to you to be sure you can't have a divide by zero.

 
belido:
FYI, this does not happen in previous version of MT4/MQL4. I use similar indicator in the previous version. Perhaps last version call the function in different way.
If you are thinking there is a bug, please report it to the ServiceDesk.
 
angevoyageur:

Except your are interpreting the documentation. Nowhere it's written that MarketInfo() can't return 0. And the fact is it returns sometimes a zero.

By the way, this is senseless discussion. When are you dividing in your code, it's up to you to be sure you can't have a divide by zero.

Offer your interpretation of the documentation in that particular case.

What are the conditions that might be in order for MarketInfo() to return zero when it is called to get "Margin to maintain open orders calculated for 1 lot"?

I see only those unreal ones as zero lot size and/or infinite leverage. These conditions do not exist in reality.

Can you offer the real conditions when MarketInfo() might return zero in case when it is called to get "Margin to maintain open orders calculated for 1 lot"?

 
simpleton:

Offer your interpretation of the documentation in that particular case.

What are the conditions that might be in order for MarketInfo() to return zero when it is called to get "Margin to maintain open orders calculated for 1 lot"?

I see only those unreal ones as zero lot size and/or infinite leverage. These conditions do not exist in reality.

Can you offer the real conditions when MarketInfo() might return zero in case when it is called to get "Margin to maintain open orders calculated for 1 lot"?

Simply when it's not available.

Forum on trading, automated trading systems and testing trading strategies

zero divide

angevoyageur, 2014.06.13 19:01

If you are thinking there is a bug, please report it to the ServiceDesk.

 
angevoyageur:

Simply when it's not available.


There is nothing about unavailability in the documentation. The case you provided is not a real condition, when MarketInfo() might return zero. If it returns zero voluntarily contrary to the documentation then it is definitely a bug.

If there are cases during the MT4 terminal process life cycle when MarketInfo() cannot immediately return the requested value because the desired information is still not available in the system then either the system should postpone returning control back to its caller until needed data became available or the documentation should specify that MarketInfo() may fail and how its caller might detect whether it is failed or not in every particular case. Currently, neither takes place.

So, currently there is no division by zero in "1 / MarketInfo()" expression for the particular case.

There is the system design bug instead. And as you can see it needs some kind of workaround.

 
simpleton:

There is nothing about unavailability in the documentation. .........

Interesting. Hope someone at MQL will fix it.
 

Now I got margin required from MarketInfo() for EURSEK is 5.

If it's a wrong data returned, how to fix it?