Hello there Im developing an EA, that needes to be able to trade x position for every side as maximun. To make it easier lets say X is = 1. Meaning Only one buy market or sell market order can be activated at the same time. Not more than one for every directiom. Ok then this EA use a lot of buy stops Order and sell stops, the logic will be very difficult to implement if any time 1 sell is activated we have to close all the sell stop entry orders, and reactivate then
when the sell market order is closed. My question is, Is there a way to tell the EA to ignore all SELL stops Entry orders for example when there is already 1 sell market open?. Meaning that if the price goes to a sell stop order, just cancel it instead of sending it to the MT4 server.
You could copy all SellStop orders details into an array when the code places them.
Then check and if you have an open sell trade, delete the stoporders
then when the sell order is closed, get the details from the array and re-send the SellStop orders (if they are still relevant)
Or instead of placing the stop orders record the details in an array
Your code could check for when price hits a level and open the trade
Obviously, only check if there is not a current open order
I'm tempted to agree with GumRai... don't use stop orders. To paraphrase WHRoeder, pending orders are for humans. Let the EA manage the trades.
Your terminal is going to have to be running anyway in order to intercept your pending orders and cancel them as required.
Thank guys for your logic answer, I will apply those. But I suppose biy hearing your answer that there is no other way than to code the solution, I was looking a quick fix in mt4 language, like a function or something. that check the instruction before sending for the server.
And yes I will move to only market orders it seems.
To add comments, please log in or register