Need help Closing orders with an EA
|
|||
|
I ran into a problem that I dont know how to solve. My program has a few open orders and closes them all together but sometimes I think that some of the orders are not filled therefore it keeps waiting till they are filled and that locks up my program. What have you guys found to be the best way to close all open orders? Thank you kindly for your help.
here is the code: int OrdersTotalLong() { int order_total = 0; for (int i = 0; i < OrdersTotal(); i++) { OrderSelect(i,SELECT_BY_POS, MODE_TRADES); if (OrderType() == OP_BUY) order_total++; } return(order_total); } int MaxLongOrder() { int order = 0; double lotsbuyed = 0; for (int i = 0; i < OrdersTotal(); i++) { OrderSelect(i,SELECT_BY_POS, MODE_TRADES); if ((OrderType() == OP_BUY) && (OrderLots() > lotsbuyed)) { lotsbuyed = OrderLots(); order = i; } } return(order); } int CloseLong() { while (OrdersTotalLong() > 0) //until there's no Orders open (close all) { if (OrderSelect(MaxLongOrder(), SELECT_BY_POS, MODE_TRADES) == false) continue; OrderClose(OrderTicket(),OrderLots(), Bid, 3, Green); } } return(0); } |
![]() |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| place 2 pending orders | pgtips | MetaTrader and ZeroCode | 1 | 11-15-2007 03:15 PM |
| Merging orders | TraderSeven | MetaTrader and ZeroCode | 7 | 12-10-2005 01:19 AM |
| Closing trades at end of candle | TraderSeven | MetaTrader and ZeroCode | 2 | 09-22-2005 02:53 PM |
| Closing with RSI | TurboTrader24 | MetaTrader and ZeroCode | 1 | 09-07-2005 03:50 AM |
| Closing Pending Orders | Rastarr | MetaTrader and ZeroCode | 0 | 06-07-2005 11:52 PM |
All times are GMT. The time now is 10:19 PM.
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Registered members have access to special online forex currency trading tools, software, mt4 expert advisors and indicators. Register now







Linear Mode


