This is a calculation for FOREX. The rest - by analogy.
Great, now we just need to bring margin in the currency of deposit, because the margin, for example, for AUDCAD with the currency of deposit USD should be in USD.
Alexey Volchanskiy: 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.
Alexey Volchanskiy: 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.
SymbolInfoDouble(Symb, SYMBOL_TRADE_TICK_VALUE ) seems to be in the function just for this... to bring lots to the currency of deposit
All works great in forex, but the last question remains: "Why is it half as much, and how to fix it?
I have encountered the fact that the margin on SGDJPY is several 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.
fxsaber: 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?
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
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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!