Download MetaTrader 5
To add comments, please log in or register
Find out how to use widgets at MQL5.community
fx_maddin
110
fx_maddin 2014.11.21 09:47 

Hi,

yesterday, I got a strange error.

After lot calculation, I normalize and make a AccountFreeMarginCheck.

    double LotStep = MarketInfo(Symbol(),MODE_LOTSTEP);
    double Lot = 2.13138833; // I get this value from calculations

    double myLot = MathRound(Lot/LotStep) * LotStep;

    double AFMC = AccountFreeMarginCheck(Symbol(),OP_BUY,myLot);
    if (AFMC<=0) {
        Print("AccountFreeMarginCheck = " + AFMC);
    } else {
        Print("OK");
        //OrderSend(....);
    }


This works many weeks and suddenly I got this error:

AccountFreeMarginCheck = -1.#INF


I had a balance of 203759.99 and a FreeMargin of 201978.87.

It is not reproducable. What can I do to avoid this kind of error?

Alain Verleyen
Moderator
28699
Alain Verleyen 2014.11.22 12:49  
fx_maddin:

Hi,

yesterday, I got a strange error.

After lot calculation, I normalize and make a AccountFreeMarginCheck.


This works many weeks and suddenly I got this error:


I had a balance of 203759.99 and a FreeMargin of 201978.87.

It is not reproducable. What can I do to avoid this kind of error?

if(!MathIsValidNumber(AFMC)) { /* Process error */}
/
To add comments, please log in or register