int mgc=87697;
int total=OrdersTotal();
bool cancelorder=false;
for(cnt=0;cnt<total;cnt++) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if((OrderMagicNumber()==mgc) && (OrderType()==OP_BUY || OrderType()==OP_SELL)) cancelorder=true;
}
if(cancelorder) {
for(cnt=0;cnt<total;cnt++) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if((OrderMagicNumber()==mgc) && (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP)) OrderDelete(OrderTicket());
}
}
THANKS!!!
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
Hi,
I need some help.
I designed a simple Breakoutsystem, which generates two orders like the following:
Ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,kauf_stopp_preis,3,kauf_stopp_preis-anfangs_stopp,kauf_stopp_preis +TakeProfit*Point,NULL,Magic1,TradeTime+EndHour*60*60,Blue); //TradeTime+EndHour*60*60
Ticket = OrderSend(Symbol(),OP_SELLSTOP,Lots,verkauf_stopp_preis,3,verkauf_stopp_preis+anfangs_stopp,verkauf_stopp_preis-TakeProfit*Point,NULL,Magic2,TradeTime+EndHour*60*60,Red); //TradeTime+EndHour*60*60
So there are two order to get stopped into the market.
If one of them gets executet, the other order must bedeleted.
Can I delete an order by using the MagicNumber?
If that works, can somebody tell me the code???
Thanks