Download MetaTrader 5

Where to implement MarginCheck

To add comments, please log in or register
Do you need a programmer? Make an order to let the developer find you!
ADRIAN MATUSIAK
1160
ADRIAN MATUSIAK 2015.09.04 10:50 

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
Sergiy Podolyak
1845
Sergiy Podolyak 2015.09.04 11:16  
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);
     }
ADRIAN MATUSIAK
1160
ADRIAN MATUSIAK 2015.09.04 22:02  
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 :)
To add comments, please log in or register