Forex
Google

Go Back   Forex Trading > Discussion Areas > Metatrader 4
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-02-2006, 12:35 PM
Altern8 Altern8 is offline
Junior Member
 
Join Date: Nov 2005
Posts: 24
Altern8 is on a distinguished road
how to delete a pending orders

Hi,

Happy new Year everyone.

Can someone give me a snippet of code, that will delete a un-used buystop/sellstop order?

For example, the ea I use, places a buystop order and a sellstop order, 10 pips away from the current price. If one of the orders(buy or sell stop) is filled, I want the other un-used order to be deleted.

Can anyone help me?

Thanks

Altern8
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-02-2006, 02:10 PM
fxid10t's Avatar
fxid10t fxid10t is offline
Member
 
Join Date: Sep 2005
Location: MidAtlantic USA
Posts: 72
fxid10t is on a distinguished road
Code:
   for(int c=0;c<OrdersTotal();c++) {
      OrderSelect(c,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) {
        if(OrderType()==Op_BuyStop) int b=OrderTicket();
        if(OrderType()==Op_SellStop) int s=OrderTicket(); } }
   
OrderSelect(b,SELECT_BY_TICKET);
      if(OrderType()==Op_Buy) {OrderDelete(s);s=0;}
OrderSelect(s,SELECT_BY_TICKET);
      if(OrderType()==Op_Sell) {OrderDelete(b);b=0;}
integers b & s should be assigned ticket numbers when placing the buy and sell stop orders, and need code to reassign ticket number values when re-initializing the ea. When the buy or sell order is closed, one should probably use OrderCloseTime()>0 to reset b or s to zero, similar to the following:

Code:
OrderSelect(b,SELECT_BY_TICKET);
      if(OrderCloseTime()>0) {b=0;}
OrderSelect(s,SELECT_BY_TICKET);
      if(OrderCloseTime()>0) {s=0;}
hope this helps somewhat
__________________
"You should not have a favourite weapon. To become over-familiar with one weapon is as much a fault as not knowing it sufficiently well. You should not copy others, but use weapons which you can handle properly. It is bad for commanders and troopers to have likes and dislikes. These are things you must learn thoroughly." Miyamoto Musashi
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
MT4 pending orders fx_geezer Metatrader 4 5 06-15-2007 09:36 PM
modify orders and close pending orders bkgridley Questions 8 05-23-2007 09:49 PM
Closing Pending Orders bkgridley Expert Advisors - Metatrader 4 1 05-11-2007 05:47 AM
this EA delete all pendind orders hedge4x Expert Advisors - Metatrader 4 3 01-24-2007 07:50 PM
Pending orders TheExponential Questions 4 11-25-2005 12:36 AM


All times are GMT. The time now is 12:15 AM.