Download MetaTrader 5

How can I get symbol's margin percentage?

To add comments, please log in or register
Xiangdong Guo
4204
Xiangdong Guo  
MQL4/5 adds new "symbol margin percentage" property, but how can I get this value?
Vladimir Karputov
Moderator
73680
Vladimir Karputov  
Xiangdong Guo:
MQL4/5 adds new "symbol margin percentage" property, but how can I get this value?

Use

SymbolInfoDouble

SymbolInfoDouble Returns the corresponding property of a specified symbol. There are 2 variants of the function. 1. Immediately returns the property value. double SymbolInfoDouble ( string name, // symbol ENUM_SYMBOL_INFO_DOUBLE prop_id // identifier of the property ); 2. Returns true or false depending on whether a function is successfully performed. In case of success, the value of the property is placed into a recipient variable, passed by reference by the last parameter. bool SymbolInfoDouble ( string name, // symbol ENUM_SYMBOL_INFO_DOUBLE prop_id, // identifier of the property double& double_var // here we accept the property value ); Parameters name [in] Symbol name. prop_id [in] Identifier of a symbol property. The value can be one of the values of the ENUM_SYMBOL_INFO_DOUBLE enumeration. double_var [out] Variable of double type receiving the value of the requested property. Return Value The value of double type. In case of execution failure, information about the error can...

Documentation | 2015.12.03 11:38

Xiangdong Guo
4204
Xiangdong Guo  
Karputov Vladimir:

Use

Thanks for your reply.

But actually, I didn't find SYMBOL_MARGIN_PERCENTAGE enum.

Vladimir Karputov
Moderator
73680
Vladimir Karputov  
Xiangdong Guo:
MQL4/5 adds new "symbol margin percentage" property, but how can I get this value?
No such property. The margin is calculated in money, not as a percentage.
Xiangdong Guo
4204
Xiangdong Guo  
Karputov Vladimir:
No such property. The margin is calculated in money, not as a percentage.

Looks like you miss the new property of symbol.

Please open Market Watch -> Right click forex symbol -> Specification, then you will find "Margin percentage".

 

Vladimir Karputov
Moderator
73680
Vladimir Karputov  
Xiangdong Guo:

Looks like you miss the new property of symbol.

Please open Market Watch -> Right click forex symbol -> Specification, then you will find "Margin percentage".

 

I do not know where you got this picture. In MetaTrader 5 has no such options :)
Mohammad Soubra
32062
Mohammad Soubra  
Vladimir Karputov:
I do not know where you got this picture. In MetaTrader 5 has no such options :)
It is in MT4
Stanislav Korotky
22533
Stanislav Korotky  
Xiangdong Guo:
MQL4/5 adds new "symbol margin percentage" property, but how can I get this value?

It looks like this property can not be accessed directly by far, and the only workaround is indirect - reverse calculation. For example, according to CFD margin formula for 1 lot:

Margin (amount) = Contract size * Open market price

On the other hand, the margin for 1 lot can be reteieved as:

Margin (builtin) = MarketInfo(Symbol(), MODE_MARGINREQUIRED)

Hence, the percentage can be found via division:

Margin (percentage) = Margin (builtin) / Margin (amount) * 100

To add comments, please log in or register