Margin Calculation ? - page 2

 
Alain Verleyen #:

Or type 0.5

That is next level...
 

I have a problem with the followng contract.

US2YR

If I Print MARGINREQUIRED I see 92.15 but if I try to open 1 Lot the required margin is around 2K Euros. 

Could you help me to calculate the required margin for a given size? 

I tried the following 

Required Margin = Volume * Contract Size * Open Price * Margin %

but I seem it doens't work (may be for CFD leverage?)

 
Alberto Tortella #:

I have a problem with the followng contract.


If I Print MARGINREQUIRED I see 92.15 but if I try to open 1 Lot the required margin is around 2K Euros. 

Could you help me to calculate the required margin for a given size? 

I tried the following 

Required Margin = Volume * Contract Size * Open Price * Margin %

but I seem it doens't work (may be for CFD leverage?)

In your formula, you are missing leverage.

Take a look at th documentation.

https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_calc_mode

I know, it's mql5, but the formulas are still applicable.
 

I tried to sold 0.45 lots of the contract and I saw the required margin was Euro 404.

Using the following formula 

Margin: (Lots * ContractSize * MarketPrice) / Leverage * Margin_Rate

I obtain ((0.45 *100 * 101.187/100) / 100 * 100%) / EURUSD = 41.39

Where is my error?

 
Alberto Tortella #:

I tried to sold 0.45 lots of the contract and I saw the required margin was Euro 404.

Using the following formula 

Margin: (Lots * ContractSize * MarketPrice) / Leverage * Margin_Rate

I obtain ((0.45 *100 * 101.187/100) / 100 * 100%) / EURUSD = 41.39

Where is my error?

I guess your leverage is not 100 on this symbol. You need to check with your broker.

Some symbols do not use the account leverage, but have a different leverage.

Usually these are reflected in the symbols specifications. But I cannot see if there is more on the bottom of your screenshot.

Anyways, if not, you are screwed as your broker does not provide all details to your symbol.

I suggest you call them and ask how it's calculated. I had to do so as well to find out how it works.

They should be able to tell you how it works. I came across some brokers, who do not provide all details in metatrader...

I don't use them as a consequence.


Edit:
My guess would be, the symbols leverage is 10 and not 100.
 

Is there a way to recall the margin % from code?

For some contracts it's available under Margin rate, at the bottom of the window. So if Margin rate is 5, I need to divide by 20.


 
Alberto Tortella #:

Is there a way to recall the margin % from code?

For some contracts it's available under Margin rate, at the bottom of the window. So if Margin rate is 5, I need to divide by 20.


Yes, SymbolInfoDouble with SYMBOL_MARGIN_INITIAL
Reason: