Hi,
My EA has a function that does Take profit and a certain points stop loss which is passed in OrderSend. So in my OrderSend for example, TakeProfit = 0, StopLoss = 50. Now I want to identify if a particular order was closed due to take profit function or stoploss triggered. How can I check this? Please assist. Thanks.
do you have mq4 file ??
The order is send by:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-100*Point,0,"Buy Initiate",1111,0,Green);
and closed with:
if (High[0] >= MaCurrent) { OrderClose(OrderTicket(),OrderLots(),Bid,3,Black); // close position return(0); // exit }
So now, the order gets closed either with the OrderClose() or hitting Stop Loss(Ask-100*Point). I need to identify which of these caused the order to close.
The order is send by:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-100*Point,0,"Buy Initiate",1111,0,Green);
and closed with:
if (High[0] >= MaCurrent)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Black); // close position
return(0); // exit
}
So now, the order gets closed either with the OrderClose() or hitting Stop Loss(Ask-100*Point). I need to identify which of these caused the order to close.
your ordermagicnumber is 1111
your ordersymbol Symbol()
if at bar 0 the number of trades are less then at opening of the bar or moment number of open trades become smaller
check if the trades closed in ordershistory are with your ordersymbol and ordermagicnumber and with orderclosetime >= Time[0]
then you can check if OrderStopLoss() == OrderClosePrice() or do some other checking
for giving code use SRC button see and replace How to use the SRC button.
check this out.
Done raptor. Was my first query on the forum. Apologies. And Thanks pro.


- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
My EA has a function that does Take profit and a certain points stop loss which is passed in OrderSend. So in my OrderSend for example, TakeProfit = 0, StopLoss = 50. Now I want to identify if a particular order was closed due to take profit function or stoploss triggered. How can I check this? Please assist. Thanks.