How to run a function in response to an error 134?

To add comments, please log in or register
dkamerond
200
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 !!!
Pavel Shutovskiy
76575
Pavel Shutovskiy  
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

To add comments, please log in or register