| / | Forum |
|
chehab
2007.08.28 00:24
we would like to hv somebody telling us on how to close several opened trades at
one shot and not to close them individually or one by one.
|
|
Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization This article dwells on implementation algorithm of simplest trading systems. The article will be useful for beginning traders and EA writers. |
|
wackena
2007.08.28 11:02
Try this: The attached script file should close all orders at same time. Place it in script folder and compile. Just drag to chart screen when needed. I haven't tested it. Hope it works. Another way is to code it inside EA to CloseAllTrades when called. if(x==?) CloseAllTrades(); // insert a call in int start() section of EA. // insert this following code after // int start() { // } section of EA. void CloseAllTrades() { for (int i=0; i<OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol()==Symbol()) { if (OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,5,Violet); if (OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,5,Violet); if (OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT || OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT) OrderDelete(OrderTicket()); } } } } |