Closing and Deleting orders without using Loop
That is just too little information because you might have to change the structure of the EA, but...look at the Moving Average EA delivered with your default MT4 and look at the code to steal some bits...
I just to give you a clue:
Everytime you open an order do this:
...[opening conditions]... ...if(OpenPositions==0) { Ordersend(...); OpenPositions++; } ...[closing conditions]... ...if([closing conditions]) { OrderClose(...); Openpositions--; }Hope it helps
Try this:
Condition #1 ..... TRUE OrderSend (.................) Condition #2 ....... TRUE OrderSelect(0,SELECT_BY_POS); if(OrderType()>1)OrderDelete(OrderTicket()); else { if(OrderType()==0)OrderClose(OrderTicket(),OrderLots,Bid...); else OrderClose(OrderTicket(),OrderLots,Ask...); } ...
That is just too little information because you might have to change the structure of the EA, but...look at the Moving Average EA delivered with your default MT4 and look at the code to steal some bits...
I just to give you a clue:
Everytime you open an order do this:
I will try what you suggested.
let me explain what I am trying to do with more details...
I place a "Stop buy" when candle 1 (the previous candle) penetrates the MA.
If the price returns back and touches the MA without activating the "Stop Buy", then I need to delete the order.
If the price returns back and touches the MA and the order has been activated without reaching the TP, then I need to close the order.
Hope this information is usefull...
Hi everyone,
My problem is that I need to close/delete orders if the price reaches the MA
i.e.
Condition #1 ..... TRUE
OrderSend (.................)
Condition #2 ....... TRUE
OrderDelete () / OrderClose
No new order can be excuted if the first one is not closed/deleted
Hope it's clear ...