It first calculates a percentage of ACCOUNT_MARGIN_FREE by dividing it with 8000.
Then it calculates min and max value to keep it between the bandwidth.
Then it normalizes to a 2 digit double and returns the result.
It's one of the ways to get to a dynamic lot size, if the account grows, lotsize is going to increase, and if it shrinks, lotsize will also lower.
Like an automatic gearbox.
Another thing I was wondering is how leverage is calculated. Is this something the EA does, or does the broker set the leverage? When I run a back-test my profit level stays the same no matter what I set the leverage to.
theDUDE:
Another thing I was wondering is how leverage is calculated. Is this something the EA does, or does the broker set the leverage? When I run a back-test my profit level stays the same no matter what I set the leverage to.
Another thing I was wondering is how leverage is calculated. Is this something the EA does, or does the broker set the leverage? When I run a back-test my profit level stays the same no matter what I set the leverage to.
Leverage is set by the broker. You can eventually request them to change it.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
}
I'm just trying to figure out what exactly is happening in the above code segment.
Why is the free margin divided by 8000?
Is line two calculating the maximum amount of "0.1" lots to a maximum of 15?
Why is my lot size 0.1?