Calculating lot size based on Risk
I am currently testing an EA which I have converted from MQL4 code to new MQL5 code. Things generally work but the lot size calculation (based on a fixed risk percentage) is off:
When my EA runs, I get this output:
However, when running in a Demo account against US30, the margin for the opened position (11 Lots) is 1240 EUR (approx 1400 USD).
The logic my function is using seems quite simple/basic and I'm not seeing where it would be going wrong. Could anybody give me a hint as to what's causing this problem/discrepancy?
Thanks a lot
If anybody has any ideas, I'd appreciate a hint. I've been looking at this for hours and can't find the problem (it's probably something stupid) but I'm stuck :-(
Code looks ok. Sounds like you're testing on two different accounts. Post some logs/screenshots.
I am currently testing an EA which I have converted from MQL4 code to new MQL5 code. Things generally work but the lot size calculation (based on a fixed risk percentage) is off:
When my EA runs, I get this output:
However, when running in a Demo account against US30, the margin for the opened position (11 Lots) is 1240 EUR (approx 1400 USD).
The logic my function is using seems quite simple/basic and I'm not seeing where it would be going wrong. Could anybody give me a hint as to what's causing this problem/discrepancy?
Thanks a lot