Leverage for each symbol - page 4

 
Petr Nosek:

These results are from your code at my broker. And similar it is at my other brokers. Of course, only at some symbols.

Crude Oil (it should be 10:1):

Symbol leverage [CL_ecn] = 0:1

DAX (it should be 20:1):

Symbol leverage [DAX_ecn] = 1:1


Yes, you are right. I tested it today on Tickmill - they have incorrect TICK_VALUE for PLN accounts and I got wrong results on indices. Thanks for sharing :)

 

Hello,


I have sent to MetaQuotes Software Corp  the following e-mail. I hope to receive answer in this matter.

Dear MetaQuotes Software Corp. Team,


  From 2018,  new rules of leverages have become applicable in Europe (EU) accordingly with ESMA 's directive. I mean that today in Forex market , the brokers can use different leverages, e.g. 1:20; 1: 30: 1: 10 1: 100 etc for each pair of currencies . Therefore in MQL5 Identifier ACCOUNT_LEVERAGE of ENUM_ACCOUNT_INFO_INTEGER to AccountInfoInteger () function is totally useless in EU area.
 When can we expect adding new identifier like SYMBOL_LEVERAGE (or another name) of ENUM_SYMBOL_INFO_INTEGER to SymbolInfoInteger () function like: SymbolInfoInteger (_Symbol, SYMBOL_LEVERAGE). The leverage for each Forex symbol should be counted in the account currency of course. This function will be very useful because broker:
1. uses diffrent levareges for each symbol
2. sometimes also uses dynamic leverage

Best Regards,
Olf-Forex Trader
 
Old Forex -Trader:

Hello,


I have sent to MetaQuotes Software Corp  the following e-mail. I hope to receive answer in this matter.

Dear MetaQuotes Software Corp. Team,


  From 2018,  new rules of leverages have become applicable in Europe (EU) accordingly with ESMA 's directive. I mean that today in Forex market , the brokers can use different leverages, e.g. 1:20; 1: 30: 1: 10 1: 100 etc for each pair of currencies . Therefore in MQL5 Identifier ACCOUNT_LEVERAGE of ENUM_ACCOUNT_INFO_INTEGER to AccountInfoInteger () function is totally useless in EU area.
 When can we expect adding new identifier like SYMBOL_LEVERAGE (or another name) of ENUM_SYMBOL_INFO_INTEGER to SymbolInfoInteger () function like: SymbolInfoInteger (_Symbol, SYMBOL_LEVERAGE). The leverage for each Forex symbol should be counted in the account currency of course. This function will be very useful because broker:
1. uses diffrent levareges for each symbol
2. sometimes also uses dynamic leverage

Best Regards,
Olf-Forex Trader

I'm really curious if they answer to you. If so I would like to see the answer. Thank in advance.

 

Hello,

I have sent the following e-mail to XM broker:


Dear XM Team,


During testing XM MT5 demo-Hedge account i have noticed discrepancies in accessible information using MT5 script as below:
1. USDTRY:
Acc. to function SymbolInfoInteger(USDTRY,SYMBOL_TRADE_CALC_MODE) the CALC_MODE=[5]=MODE_FOREX (Forex no leverage). It means that for USDTRY mode Forex was set with no Leverage. Acc. to  function OrderCalcMargin(ORDER_TYPE_BUY,USDTRY,1,SymbolInfoDouble(USDTRY,SYMBOL_BID),CalcMarginBuy)  the result for 1 lot was 5000$, like for Leverage 1:20. It was confirmed by experiment with trade 0,1 lot the margin required 500$.

2. The same problems concern the following currency pairs: EURTRY; EURDKK; EURHKD; GBPDKK; USDRUB; USDDKK; USDHKD; EURRUB; USDCNH; 

I have checked only Forex currencies pairs, because for multi-currency  trading,  I search and choose  first which currency pairs has got CALC_MODE=[0]=MODE_FOREX (Forex with leverage), because I am not interested with Forex currency pairs with no Leverage.

Example with USDTRY that one function shows (Forex no leverage) which means leverage 1:1 but in real/demo  trading USDTRY  it was set as Forex with leverage 1:20.

This mistakes (broker server side) influence on working in totally different way the  automated trading using EA (Expert Adviser).
See also forum MT5 concerning almost  the same mistakes from other brokers :         https://www.mql5.com/en/forum/63625


Best Regards,
Old-Forex Trader


I have received below answer:


Dear Valued Client,


We thank you for choosing XM as your trusted broker.

Regarding your concern, the relevant department has informed me that in order to comply with the ESMA regulations we have set a fixed margin rate. In order to accomplish this the calculation mode must be set to Forex No Leverage. And after that we set the required margin rate.

Unfortunately this is the only way.

Should you have any further questions, please do not hesitate to contact us.

Wishing you a great day and successful trading!


...........

Customer Care Officer


 
I've got a solution!
input int SymbolLeverage = 20;  
// or input your specific symbol leverage for EA calculations 
 

I've calculated symbol leverage in this way:

int CalculateSymbolLeverage(const string symbol)
  {
  
   int leverage=-1;
   double margin=0.0;
   double lots=1.0;
   
   if(OrderCalcMargin(ORDER_TYPE_BUY,symbol,lots,SymbolInfoDouble(symbol,SYMBOL_ASK),margin) && margin > 0)
     {
      double tickValue = SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_VALUE);
      double tickSize = SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_SIZE);
      double lotValue = tickValue * SymbolInfoDouble(symbol,SYMBOL_ASK) / tickSize;
      leverage=(int)MathRound(lotValue/margin);
     }
   
   return leverage;
  }
Regards

 

I have just posted an interactive script that list all market and symbol attributes includiing leverage calculated as such :

Bid * ContractSize * rate (Symbol Profit Currency / Account Currrency ) / Margin Required

MetaTrader Trading Platform Screenshots

AUDUSD, H1, 2021.11.01

Raw Trading Ltd, MetaTrader 4, Real

Symbol info for mt4

AUDUSD, H1, 2021.11.01, Raw Trading Ltd, MetaTrader 4, Real


 
Rafael Sierra Clemente #:

I've calculated symbol leverage in this way:

Regards

Thanks so much for the code. That function works like a magic. Now I am able to find the leverage of different asset classes accurately. 

Reason: