Hello,
I'm running a basic grid strategy and I've set up a minimum equity vs balance so it closes and runs minimum lot sizes if it goes below a reserve
but when i get a few good trades in a row my lot size gets so high i'm returning error 134 because its too high for the margin. What i've done is
write a function to close all open trades and increase my reserve. I've got all that figured out but where i run into trouble is not
triggering my EquityReset function until i return an error 134. I'm sure there is a way i just can't find it in the book or with a basic
search. Doubtless i'm just not using the correct terminology as i'm fairly new to writing my own EA's. In the past I've payed others to do
it but i really want to be able to write my own for testing.
TLDR; How can i run my EquityReset function only if MT4 returns an error 134 or otherwise indicates a failure to submit an order due to low margin
without causing it to run during normal operations?
Thanks in advance as always !!!
- Delete an object from only 1 of the open pairs, not all of them...
- error 134 : not enough money
- Strategy test ending early/skipping time
dkamerond:
Hello,
I'm running a basic grid strategy and I've set up a minimum equity vs balance so it closes and runs minimum lot sizes if it goes below a
reserve but when i get a few good trades in a row my lot size gets so high i'm returning
error
134 because its too high for the margin. What i've done is write a function to close all open trades and increase my
reserve. I've got all that figured out but where i run into trouble is not triggering my EquityReset function until i return an error
134. I'm sure there is a way i just can't find it in the book or with a basic search. Doubtless i'm just not using the correct
terminology as i'm fairly new to writing my own EA's. In the past I've payed others to do it but i really want to be able to write my own
for testing.
TLDR; How can i run my EquityReset function only if MT4 returns an error 134 or otherwise indicates a failure to submit an order due to low
margin without causing it to run during normal operations?
Thanks in advance as always !!!
if(_LastError == ERR_NOT_ENOUGH_MONEY){ // EquityReset }
If correctly understood that you want, then this condition you will help

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