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
The solution came immediately.
double GetMarginRequired( const string Symb )
{
MqlTick Tick;
return(SymbolInfoTick(Symb, Tick) ? Tick.ask * SymbolInfoDouble(Symb, SYMBOL_TRADE_TICK_VALUE) * SymbolInfoDouble(Symb, SYMBOL_TRADE_CONTRACT_SIZE) *
SymbolInfoDouble(Symb, SYMBOL_POINT) / (SymbolInfoDouble(Symb, SYMBOL_TRADE_TICK_SIZE) * AccountInfoInteger(ACCOUNT_LEVERAGE)) : 0);
}
Great, it remains to bring the margin in the currency of the deposit, because the margin, for example, for AUDCAD with the currency of the deposit USD should be in USD.
Great, the only thing left is to bring the margin in the currency of deposit, because the margin, for example for AUDCAD with the currency of deposit USD should be in USD.
This is what was done.
Everything works great in forex, but the only remaining question is "why half as much, and how to fix it?"
All works great in forex, but the last question remains: "Why is it half as much, and how to fix it?
Faced with the fact that on SGDJPY the margin is times different on FIBOGroup-MT5 Server and MetaQuotes-Demo. This suggests that MT5 itself calculates the margin with errors. And since it is so, there is no benchmark for comparison. That is why it is impossible to say for sure if this is my error or that of the developers. I think there is an error in both cases. The problem is the lack of correct information.
My two servers show correctly, with one exception - highlighted in red
How do I find out the property highlighted in red?
Thank you!
I have two servers showing correctly, with one exception - highlighted in red
How to know the property in red?
double GetMarginRequired( const string Symb )
{
MqlTick Tick;
double MarginInit, MarginMain;
return((SymbolInfoTick(Symb, Tick) && SymbolInfoMarginRate(Symb, ORDER_TYPE_BUY, MarginInit, MarginMain)) ? MarginInit * Tick.ask *
SymbolInfoDouble(Symb, SYMBOL_TRADE_TICK_VALUE) / (SymbolInfoDouble(Symb, SYMBOL_TRADE_TICK_SIZE) * AccountInfoInteger(ACCOUNT_LEVERAGE)) : 0);
}
You have to clearly understand that in MT5 there may be very different margin requirements in different directions. That is, a single MT4 variant may not work. On Forex, of course, this will not be the case. But you have to remember. Therefore, in the general case it should be written like this
bool MyOrderCalcMargin( const ENUM_ORDER_TYPE action, const string symbol, const double volume, const double price, double &margin )
{
double MarginInit, MarginMain;
const bool Res = SymbolInfoMarginRate(symbol, action, MarginInit, MarginMain);
margin = Res ? MarginInit * price * volume * SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE) /
(SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_SIZE) * AccountInfoInteger(ACCOUNT_LEVERAGE)) : 0;
return(Res);
}
That's what was done.
MT5 joke on FIBOGroup-MT5 Server SGDJPY
In this situation MyOrderCalcMargin counts correctly, but the regular OrderCalcMargin does not!
MT5 prank on FIBOGroup-MT5 Server SGDJPY
In this situation MyOrderCalcMargin counts correctly, but the regular OrderCalcMargin does not!