AccountFreeMarginCheck returns -1.#INF

 

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?

 
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 */}