I expect from MetaQuotes Software Corp. team, add new Account Properties (like: expanding of AccountInfoInteger() or AccountInfoDouble()) concerning the detail info about Leverage for each Symbol. EA traders need it very much, because of new ESMA rules. Now the Identifier (ACCOUNT_LEVERAGE_ of ENUM_ACCOUNT_INFO_INTEGER in AccountInfoInteger() is useless.
Old Forex Trader
A better solution would be a new property for SymbolInfoInteger function. E.G. SYMBOL_LEVERAGE then you can find out leverage for each symbol by SymbolInfoInteger(_Symbol, SYMBOL_LEVERAGE).
Yes, you are right but the final solution will depend on MetaQuotes Software Corp. team. How do we ask them in this matter? Do they read these comments?
I'm pretty sure they don't read this topic. Maybe posting in Russian forum would help but I don't believe in it much.
This is my code to calculate symbol leverage
string symbolLeverage = "Symbol leverage = "+DoubleToStr(MathRound((Close/MarketInfo(Symbol(),MODE_TICKSIZE)*MarketInfo(Symbol(),MODE_TICKVALUE))/MarketInfo(Symbol(),MODE_MARGINREQUIRED)),0)+":1";
This code is valid only for some symbols (forex) and some accounts (account currencies).
See the code in my post: https://www.mql5.com/en/forum/271388/page2#comment_8372541
Yes, I saw it. What is the reason to use a finite list of possible leverage values? You cannot predict all available values for all brokers. Here is the list for IC Markets for example.
As for incorrect TICK_VALUE - this should be reported to broker rather than fixed by workarounds in the code.
My code is working fine so far even for non forex symbols. But I did not try all brokers nor did I test it on broker with wrong TICK_VALUE.
What is the reason to use a finite list of possible leverage values?
The reason is using with ESMA broker. But you can easily change the list for your own purpose or use the GetSymbolLeverage() function instead of the GetPossibleSymbolLeverage() function.
You are right but I tried it without success :-(
My code is working fine so far even for non forex symbols.
It depends on the margin calculation mode. Some brokers also use "Forex" calculation for some non-forex symbols.
As I said my solution works well for my purpose but I know it isn't a general solution the same as yours.
It works correctly for CFD calculation mode, at least on the symbols I tested it with. But I don't rely on it, just used it for information some time ago.
But I don't rely on it, just used it for information some time ago.
I am used to don't rely on anything :D
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