MQL4 - automated forex trading   /  

Forum

order closed by system?

Back to topics list To post a new topic, please log in or register

avatar
1
tiger 2007.07.13 15:50 
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
article

Practical Application of Cluster Indicators in FOREX

Cluster indicators are sets of indicators that divide currency pairs into separate currencies. Indicators allow to trace the relative currency fluctuation, determine the potential of forming new currency trends, receive trade signals and follow medium-term and long-term positions.


avatar
277
wackena 2007.07.15 20:52 
tiger wrote:
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;
}
}

avatar
Moderator
33780
Rosh 2007.07.16 12:58 
See sample on And you milk escaped ...
Translated from Russian by GoogleTrans
Back to topics list  

To add comments, please log in or register