order closed by system?
tiger:
Can someone help me here please? I have some flags set in my EA which need to be cleared every time an order is closed. But I don't know how to catch the signal when an order is closed by system, not my EA. Anyone had the same experience?
Thanks, Tiger
Can someone help me here please? I have some flags set in my EA which need to be cleared every time an order is closed. But I don't know how to catch the signal when an order is closed by system, not my EA. Anyone had the same experience?
Thanks, Tiger
I use this code to send email notification when orders are closed by the server at StopLoss or TakeProfit. I'm not sure if it works OK when multiple orders of same symbol are open at same time.
Hope it is useful.
Wackena
int total = OrdersTotal(); for(int cnt=0;cnt<total;cnt++){ OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol() == Symbol() ) { int ticket=OrderTicket(); } } if(ticket>0) { OrderSelect(ticket, SELECT_BY_TICKET, MODE_HISTORY); if (OrderSymbol()==Symbol() ) { if (OrderType()==OP_BUY && OrderClosePrice()==OrderStopLoss()) { // Buy StopLoss SendMail(); } if (OrderType()==OP_SELL && OrderClosePrice()==OrderStopLoss()) { // Sell StopLoss SendMail(); } if (OrderType()==OP_BUY && OrderClosePrice()==OrderTakeProfit()) { // Buy TakeProfit SendMail(); } if (OrderType()==OP_SELL && OrderClosePrice()==OrderTakeProfit()) { // Sell TakeProfit SendMail(); } ticket=0; } }
Thanks, Tiger