Where to implement MarginCheck

 

Hello dear programmers,


I have a question, where is good place in code to input :

http://docs.mql4.com/account/accountfreemargincheck



Is it just before send trade or at beginning of code?

AccountFreeMarginCheck - MQL4 Documentation
  • docs.mql4.com
AccountFreeMarginCheck - MQL4 Documentation
 
ADRIAN MATUSIAK:

Hello dear programmers,

I have a question, where is good place in code to input :

http://docs.mql4.com/account/accountfreemargincheck

Is it just before send trade or at beginning of code?

In order to make your trading reliable and robust to undesirable situations, I recommend to put it just before the OrderSend function

(digging into code of my own expert...)

if (Situation == TREND_MINIMUM)
{
 if ( (AccountFreeMarginCheck (Bond_Name, OP_BUY, Pos_Size_Lots) <= 0.0)
        || (GetLastError () == ERR_NOT_ENOUGH_MONEY) )
     {
        Action_Done = TRADING_ERROR_NOT_ENOUGH_MONEY;
        return (Action_Done);
     }
 
Sergiy Podolyak:

In order to make your trading reliable and robust to undesirable situations, I recommend to put it just before the OrderSend function

(digging into code of my own expert...)

Ok, managed to do :)