Yashar Seyyedin #:
The fact that you set risk=2% does not necessarily mean the lot size is small. Sometimes the stop loss is so close that smallest choice of risk can lead to large lots(that are not allowed on your account).
The fact that you set risk=2% does not necessarily mean the lot size is small. Sometimes the stop loss is so close that smallest choice of risk can lead to large lots(that are not allowed on your account).
thanks for your reply. but my point is i think there is something wrong with my code in producing lot size and i need help with that. the code is supposed to give me a lot size based on risk percentage AND stop loss, but it calculates a wrong lot size hence failure in order execution for me. Mentioning my risk being fixed at 2% just means that the number can be hard coded for this part and I am seeking if there is a better solution.
Hi
You should use real value of tick:
MarketInfo(Symbol(), MODE_TICKVALUE)/(MarketInfo(Symbol(), MODE_TICKSIZE)
not only tick_value – hence you have a a proper divider. And you should also divide by decimal pip value (not simply multiply by 10).
Best Regards

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
Hello, I am learning to code and came across these 2 functions that calculate the optimal lot size for the order. I tried both of them however, they are both giving me a bigger than supposed lot size sometimes (e.g. returns a 1.5 lot size for a $1000 account) so it's causing an error 134 all the time. My risk percentage is always fixed to 2% for now for this strategy.
Thanks in advance!