You don't need to calculate it, the platform will tell you exactly.
Print("Margin to open: " + DoubleToStr(MarketInfo(Symbol(),MODE_MARGININIT)/AccountLeverage(),2))
fx1.net:
is the margin requirement by 1:100 leverage account (10k USD) different between brokers? I see on fxcm 1600$ / lot and on fxdd is 540$ / lot (1 lot = 100.000 ). Can i somehow calculate margin requirement for 1 lot per broker?
is the margin requirement by 1:100 leverage account (10k USD) different between brokers? I see on fxcm 1600$ / lot and on fxdd is 540$ / lot (1 lot = 100.000 ). Can i somehow calculate margin requirement for 1 lot per broker?
Margin requirement for 1 lot is given by MarketInfo(symbol,MODE_MARGINREQUIRED). Calculating this value seems to be different among some brokers (specifically ones that use a bridge).
The majority of brokers use this calculation (taken from the article 'Forex Trading ABC' -> https://www.mql5.com/en/articles/1453):
double MarginCalculate(string symbol, double volume) { string first = StringSubstr(symbol,0,3); // the first symbol, for example, EUR string second = StringSubstr(symbol,3,3); // the second symbol, for example, USD string currency = AccountCurrency(); // deposit currency, for example, USD double leverage = AccountLeverage(); // leverage, for example, 100 // contract size, for example, 100000 double contract = MarketInfo(symbol, MODE_LOTSIZE); double bid = MarketInfo(symbol, MODE_BID); // Bid price //---- allow only standard forex symbols like XXXYYY if(StringLen(symbol) != 6) { Print("MarginCalculate: '",symbol,"' must be standard forex symbol XXXYYY"); return(0.0); } //---- check for data availability if(bid <= 0 || contract <= 0) { Print("MarginCalculate: no market information for '",symbol,"'"); return(0.0); } //---- check the simplest variations - without cross currencies if(first == currency) return(contract*volume / leverage); // USDxxx if(second == currency) return(contract*bid*volume / leverage); // xxxUSD //---- check normal cross currencies, search for direct conversion through deposit currency string base = currency + first; // USDxxx if(MarketInfo(base, MODE_BID) > 0) return(contract / MarketInfo(base, MODE_BID)*volume / leverage); //---- try vice versa base = first + currency; // xxxUSD if(MarketInfo(base, MODE_BID) > 0) return(contract*MarketInfo(base, MODE_BID)*volume / leverage); //---- direct conversion is impossible Print("MarginCalculate: can not convert '",symbol,"'"); return(0.0); }
But some brokers do not factor 'bid' price when calculating (regardless of symbol):
double MarginCalculate(string symbol, double volume) { double leverage = AccountLeverage(); double contract = MarketInfo(symbol, MODE_LOTSIZE); return(contract*volume / leverage); }
Note that MODE_MARGINREQUIRED is 'static' in Tester and that both methods of calculation cannot be used in Tester (they rely on MarketInfo() of other symbols...).
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
is the margin requirement by 1:100 leverage account (10k USD) different between brokers? I see on fxcm 1600$ / lot and on fxdd is 540$ / lot (1 lot = 100.000 ). Can i somehow calculate margin requirement for 1 lot per broker?