Can somebody give code formulas how to calculate
Margin and Leverage.
Maximum leverage is not calculated, it is given by the broker (note: some brokers have floating leverage and in that case u should consult the broker for how to calculate it). Maximum leverage can be read via a call to AccountLeverage().
For detailed example of Margin calculation see the article 'Forex Trading ABC' -> https://www.mql5.com/en/articles/1453. Note that some brokers use a different method of calculating margin requirements... See info here -> https://www.mql5.com/en/forum/125085.
Edit: corrected - I was referring to maximum leverage and not 'actual' leverage.
Leverage is not calculated, it is given by the broker (note: some brokers have floating leverage and in that case u should consult the broker for how to calculate it). Leverage can be read via a call to AccountLeverage().
Unless the OP is referring to actual leverage as opposed to maximum leverage...
CB
Unless the OP is referring to actual leverage as opposed to maximum leverage...
Brygada - do you still require to know how to calculate actual leverage?
CB
Can somebody give code formulas how to calculate
Margin and Leverage.
Thanks.
The code is contained in the file attached to post https://www.mql5.com/en/forum/126450/page5#331819
Some rough guide explanation to using it is contained in post https://www.mql5.com/en/forum/126450/page6#332640
If you have any specific questions I'd be happy to answer them. Margin as well as leverage per symbol is computed programmatically.
So far I have
double LotSize = MarketInfo(Symbol(),MODE_LOTSIZE); double Margin = LotSize/Bid/AccountLeverage();
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can somebody give code formulas how to calculate
Margin and Leverage.
Thanks.