Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network. Millions of traders are waiting for this!
Irwan Adnan
808
Irwan Adnan 2014.10.30 03:41 
Hi, can someone tell me how to get Margin Required in MQL5. I ve try SymbolInfoDouble(Symbol(), SYMBOL_MARGIN_INITIAL) but I get 0.0
Alain Verleyen
Moderator
28701
Alain Verleyen 2014.10.30 17:22  
belido:
Hi, can someone tell me how to get Margin Required in MQL5. I ve try SymbolInfoDouble(Symbol(), SYMBOL_MARGIN_INITIAL) but I get 0.0

Did you check error number ? GetLastError().

Which symbol is it ?

Irwan Adnan
808
Irwan Adnan 2014.11.20 11:35  
angevoyageur:

Did you check error number ? GetLastError().

Which symbol is it ?

Sorry friend, I missed this topic. I am looking for equivalent of MarketInfo(symbol(),MARGIN_REQUIRED) in MQL5. I know it can be calculated but if it is already there it is better. The aforemention function I have tried it with no error and for all symbol. Perhaps I use wrong  function? Thanks.
Alain Verleyen
Moderator
28701
Alain Verleyen 2014.11.20 17:11  
belido:
Sorry friend, I missed this topic. I am looking for equivalent of MarketInfo(symbol(),MARGIN_REQUIRED) in MQL5. I know it can be calculated but if it is already there it is better. The aforemention function I have tried it with no error and for all symbol. Perhaps I use wrong  function? Thanks.

I don't know why these values return 0.0.

Anyway you can probably get what you need with :

   MqlTick tick;
   double margin;
   if(!SymbolInfoTick(Symbol(),tick) || !OrderCalcMargin(ORDER_TYPE_BUY,Symbol(),1.0,tick.ask,margin)) return;
   printf("Margin =%f,margin);
Irwan Adnan
808
Irwan Adnan 2014.11.20 17:47  
angevoyageur:

I don't know why these values return 0.0.

Anyway you can probably get what you need with :

Ok, will try it. Thanks.
/
To add comments, please log in or register