Not Allowing MT4 to execute Buy or Sell Codes

Back to topics list To post a new topic, please log in or register
avatar
83
BeLikeWater 2015.02.04 10:27
 

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.

Thank you

BeLikewater

avatar
2017
gooly 2015.02.04 10:45 #
 
Check the open positions: OrdersTotal() and the Magic-number: it's your reference of the orders. In the editor's reference.
avatar
Moderator
3418
GumRai 2015.02.04 10:57 #
 

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 

avatar
736
honest_knave 2015.02.04 11:07 #
 

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.

avatar
83
BeLikeWater 2015.02.04 11:19 #
 

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.


Thank you!

avatar
49
gadget 2015.02.06 11:28 #
 
And on the same logic, use stops and takes with caution. I discovered this when after an interesting reading I replaced my bound orders, by unbound ones plus a parallel EA doing the profit and loss cleaning. From that very moment all trades were magically taken by O*** (broker's name hidden) immediately, like in priority.....
Back to topics list  

To add comments, please log in or register