Forum on trading, automated trading systems and testing trading strategies
SymbolInfoMarginRate - I can't understand it
fxsaber, 2023.07.18 22:28
double GetMarginRequired2( const string Symb ) { const double MinVolume = ::SymbolInfoDouble(Symb, SYMBOL_VOLUME_MIN); double Margin; return(::OrderCalcMargin(ORDER_TYPE_BUY, Symb, MinVolume, ::SymbolInfoDouble(Symb, SYMBOL_ASK), Margin) ? (MinVolume ? Margin / MinVolume : 0) : 0); } double GetMarginRequired( const string Symb ) { MqlTick Tick; double MarginInitRate, MarginMainRate, MarginInfo; return(((::SymbolInfoInteger(Symb, SYMBOL_TRADE_CALC_MODE) == SYMBOL_CALC_MODE_FOREX) && ::SymbolInfoTick(Symb, Tick) && ::SymbolInfoMarginRate(Symb, ORDER_TYPE_BUY, MarginInitRate, MarginMainRate) && MarginInitRate && (bool)(MarginInfo = ::MathMax(::SymbolInfoDouble(Symb, SYMBOL_MARGIN_INITIAL), ::SymbolInfoDouble(Symb, SYMBOL_MARGIN_HEDGED)))) ? MarginInitRate * Tick.ask * ::SymbolInfoDouble(Symb, SYMBOL_TRADE_TICK_VALUE) * (MarginInfo / ::SymbolInfoDouble(Symb, SYMBOL_TRADE_CONTRACT_SIZE)) / (::SymbolInfoDouble(Symb, SYMBOL_TRADE_TICK_SIZE) * ::AccountInfoInteger(ACCOUNT_LEVERAGE)) : GetMarginRequired2(Symb)); }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Good day everyone.
Please how do I calculate margin required for MQL5
Thanks