Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network. Improve your rating!
Steven Van Ingelgem
836
Steven Van Ingelgem 2016.01.31 09:54 

Hello all,

 

The question is simple, the answer is absolutely not:
How can I calculate the margin with respect for hedging?


For example this is what I havefor EURUSD:

Symbol_EURUSD_Digits=5
Symbol_EURUSD_ExpirationMode=0
Symbol_EURUSD_ExpirationTime=0
Symbol_EURUSD_FillingMode=0
Symbol_EURUSD_OrderMode=0
Symbol_EURUSD_Selected=1
Symbol_EURUSD_SessionBuyOrders=0
Symbol_EURUSD_SessionDeals=0
Symbol_EURUSD_SessionSellOrders=0
Symbol_EURUSD_Spread=3
Symbol_EURUSD_SpreadFloat=1
Symbol_EURUSD_StartTime=0
Symbol_EURUSD_SwapMode=0
Symbol_EURUSD_SwapRolloverDays=3
Symbol_EURUSD_TicksBookDepth=0
Symbol_EURUSD_Time=1453841771
Symbol_EURUSD_TradeCalcMode=0
Symbol_EURUSD_TradeFreezeLevel=0
Symbol_EURUSD_TradeStopLevel=0
Symbol_EURUSD_Visible=1
Symbol_EURUSD_Volume=0
Symbol_EURUSD_VolumeHigh=0
Symbol_EURUSD_VolumeLow=0
Symbol_EURUSD_TradeMode=4
Symbol_EURUSD_TradeExeMode=2
Symbol_EURUSD_Ask=1.0844700000
Symbol_EURUSD_AskHigh=0.0000000000
Symbol_EURUSD_AskLow=0.0000000000
Symbol_EURUSD_Bid=1.0844400000
Symbol_EURUSD_BidHigh=0.0000000000
Symbol_EURUSD_BidLow=0.0000000000
Symbol_EURUSD_Last=0.0000000000
Symbol_EURUSD_LastHigh=0.0000000000
Symbol_EURUSD_LastLow=0.0000000000
Symbol_EURUSD_MarginInitial=0.0000000000
Symbol_EURUSD_MarginLimit=0.0000000000
Symbol_EURUSD_MarginLong=0.0000000000
Symbol_EURUSD_MarginMaintenance=0.0000000000
Symbol_EURUSD_MarginShort=0.0000000000
Symbol_EURUSD_MarginStop=0.0000000000
Symbol_EURUSD_MarginStopLimit=0.0000000000
Symbol_EURUSD_Point=0.0000100000
Symbol_EURUSD_Session_AW=0.0000000000
Symbol_EURUSD_Session_BuyOrdersVolume=0.0000000000
Symbol_EURUSD_Session_Close=0.0000000000
Symbol_EURUSD_Session_Interest=0.0000000000
Symbol_EURUSD_Session_Open=0.0000000000
Symbol_EURUSD_Session_PriceLimitMax=0.0000000000
Symbol_EURUSD_Session_PriceLimitMin=0.0000000000
Symbol_EURUSD_Session_PriceSettlement=0.0000000000
Symbol_EURUSD_Session_SellOrdersVolume=0.0000000000
Symbol_EURUSD_Session_Turnover=0.0000000000
Symbol_EURUSD_Session_Volume=0.0000000000
Symbol_EURUSD_SwapLong=-1.6000000000
Symbol_EURUSD_SwapShort=-0.1000000000
Symbol_EURUSD_Trade_ContractSize=100000.0000000000
Symbol_EURUSD_Trade_TickSize=0.0000100000
Symbol_EURUSD_Trade_TickValue=1.0000000000
Symbol_EURUSD_Trade_TickValueLoss=0.0000000000
Symbol_EURUSD_Trade_TickValueProfit=0.0000000000
Symbol_EURUSD_VolumeLimit=0.0000000000
Symbol_EURUSD_VolumeMax=100.0000000000
Symbol_EURUSD_VolumeMin=0.0100000000
Symbol_EURUSD_VolumeStep=0.0100000000
Symbol_EURUSD_Bank=
Symbol_EURUSD_CurrencyBase=EUR
Symbol_EURUSD_CurrencyMargin=EUR
Symbol_EURUSD_CurrencyProfit=USD
Symbol_EURUSD_Description=Euro vs US Dollar
Symbol_EURUSD_IsIn=
Symbol_EURUSD_Path=Forex\EURUSD
Symbol_EURUSD_SwapEnable=-1
Symbol_EURUSD_MarginCalcMode=0
Symbol_EURUSD_MarginHedged=0.0000000000

And this is what I have forUSDCNH?

Symbol_USDCNH_Digits=5
Symbol_USDCNH_ExpirationMode=0
Symbol_USDCNH_ExpirationTime=0
Symbol_USDCNH_FillingMode=0
Symbol_USDCNH_OrderMode=0
Symbol_USDCNH_Selected=1
Symbol_USDCNH_SessionBuyOrders=0
Symbol_USDCNH_SessionDeals=0
Symbol_USDCNH_SessionSellOrders=0
Symbol_USDCNH_Spread=136
Symbol_USDCNH_SpreadFloat=1
Symbol_USDCNH_StartTime=0
Symbol_USDCNH_SwapMode=0
Symbol_USDCNH_SwapRolloverDays=3
Symbol_USDCNH_TicksBookDepth=0
Symbol_USDCNH_Time=1453841758
Symbol_USDCNH_TradeCalcMode=0
Symbol_USDCNH_TradeFreezeLevel=0
Symbol_USDCNH_TradeStopLevel=0
Symbol_USDCNH_Visible=1
Symbol_USDCNH_Volume=0
Symbol_USDCNH_VolumeHigh=0
Symbol_USDCNH_VolumeLow=0
Symbol_USDCNH_TradeMode=4
Symbol_USDCNH_TradeExeMode=2
Symbol_USDCNH_Ask=6.6090100000
Symbol_USDCNH_AskHigh=0.0000000000
Symbol_USDCNH_AskLow=0.0000000000
Symbol_USDCNH_Bid=6.6076500000
Symbol_USDCNH_BidHigh=0.0000000000
Symbol_USDCNH_BidLow=0.0000000000
Symbol_USDCNH_Last=0.0000000000
Symbol_USDCNH_LastHigh=0.0000000000
Symbol_USDCNH_LastLow=0.0000000000
Symbol_USDCNH_MarginInitial=100000.0000000000
Symbol_USDCNH_MarginLimit=0.0000000000
Symbol_USDCNH_MarginLong=0.0000000000
Symbol_USDCNH_MarginMaintenance=0.0000000000
Symbol_USDCNH_MarginShort=0.0000000000
Symbol_USDCNH_MarginStop=0.0000000000
Symbol_USDCNH_MarginStopLimit=0.0000000000
Symbol_USDCNH_Point=0.0000100000
Symbol_USDCNH_Session_AW=0.0000000000
Symbol_USDCNH_Session_BuyOrdersVolume=0.0000000000
Symbol_USDCNH_Session_Close=0.0000000000
Symbol_USDCNH_Session_Interest=0.0000000000
Symbol_USDCNH_Session_Open=0.0000000000
Symbol_USDCNH_Session_PriceLimitMax=0.0000000000
Symbol_USDCNH_Session_PriceLimitMin=0.0000000000
Symbol_USDCNH_Session_PriceSettlement=0.0000000000
Symbol_USDCNH_Session_SellOrdersVolume=0.0000000000
Symbol_USDCNH_Session_Turnover=0.0000000000
Symbol_USDCNH_Session_Volume=0.0000000000
Symbol_USDCNH_SwapLong=-27.9000000000
Symbol_USDCNH_SwapShort=19.7000000000
Symbol_USDCNH_Trade_ContractSize=100000.0000000000
Symbol_USDCNH_Trade_TickSize=0.0000100000
Symbol_USDCNH_Trade_TickValue=0.1513397350
Symbol_USDCNH_Trade_TickValueLoss=0.0000000000
Symbol_USDCNH_Trade_TickValueProfit=0.0000000000
Symbol_USDCNH_VolumeLimit=0.0000000000
Symbol_USDCNH_VolumeMax=100.0000000000
Symbol_USDCNH_VolumeMin=0.0100000000
Symbol_USDCNH_VolumeStep=0.0100000000
Symbol_USDCNH_Bank=
Symbol_USDCNH_CurrencyBase=USD
Symbol_USDCNH_CurrencyMargin=USD
Symbol_USDCNH_CurrencyProfit=CNH
Symbol_USDCNH_Description=US Dollar vs Chinese Yuan
Symbol_USDCNH_IsIn=
Symbol_USDCNH_Path=Forex\USDCNH
Symbol_USDCNH_SwapEnable=-1
Symbol_USDCNH_MarginCalcMode=0
Symbol_USDCNH_MarginHedged=50000.0000000000

 

For example assume I have the following informations:

Account in USD, Leverage 1:500

Open positions:
EURUSD BUY 1.00 @ 1.08000
EURUSD SELL 1.00 @ 1.07500
EURUSD SELL 0.50 @ 1.07800
USDCNH BUY 1.00 @ 6.61000
USDCNH SELL 0.33 @ 6.73000

What is the margin? (Could you please note all the steps so I understand it?)
(calculations for margin of 1 currency in 1 direction is not an issue, it's the hedging part I don't get).


 

Thanks! 

 

Xiangdong Guo
3671
Xiangdong Guo 2016.01.31 15:22  

On MT5 platform, it doesn't support hedge.

On MT4 platform:

if symbol's SYMBOL_MARGIN_HEDGED = 0, after buy&sell 1 lot EURUSD, account margin required = 0;

if symbol's SYMBOL_MARGIN_HEDGED = 50, after buy&sell 1 lot EURUSD, account margin required = 1 lot * 50%.

Steven Van Ingelgem
836
Steven Van Ingelgem 2016.01.31 20:02  
Xiangdong Guo:

On MT5 platform, it doesn't support hedge.

On MT4 platform:

if symbol's SYMBOL_MARGIN_HEDGED = 0, after buy&sell 1 lot EURUSD, account margin required = 0;

if symbol's SYMBOL_MARGIN_HEDGED = 50, after buy&sell 1 lot EURUSD, account margin required = 1 lot * 50%.

Thanks. I thought as much, but how is the complete margin calculated (as per my example)?

Xiangdong Guo
3671
Xiangdong Guo 2016.01.31 21:13  
Steven Van Ingelgem:

Thanks. I thought as much, but how is the complete margin calculated (as per my example)?

Universal formula:

margin_initial * price / leverage;

But broker usually sets difference leverage for difference symbol, so use below method to get margin required.

 

On MT4:

call MarketInfo(symbol, MODE_MARGINREQUIRED);

 

On MT5:

#include <Trade\AccountInfo.mqh>

CAccountInfo account;

call account.MarginCheck(...);

Steven Van Ingelgem
836
Steven Van Ingelgem 2016.02.01 07:15  

I know this as well.

What I want to know is how to manually calculate hedged positions.

Rodrigo da Silva Boa
7086
Rodrigo da Silva Boa 2016.02.02 01:05  
Steven Van Ingelgem :


Depending on the currency pairs of your broker you will be able to hedge in MT5 yes !!!

Try using EURUSD / EURUSD.c / EURUSD.z / EURUSD.m.

Are the same currency, it depends only on whether it is available in your broker.

/
To add comments, please log in or register