New article Events in МetaТrader 4 has been published:
Author: Andrey Khatimlianskii
Interesting article Andre. Your method of obtaining closed reason is by inspection
of order comment.
Is this 100% generic solution that will apply to brokers where I can trade using
This is important to know otherwise failure is likely.
If cannot warranty that order comment will be modified and thus your method is used
then is there method which uses closed order data fields: profit, openPrice,closePrice,
Thank you Andre.
It is better to analyse a OrderClosePrice():
if ( MathAbs( OrderClosePrice() - OrderStopLoss() ) < Point ) // closed by SL
if ( MathAbs( OrderClosePrice() - OrderTakeProfit() ) < Point ) // closed by TP
Hi, is it possible to retrieve the Order information (i.e. ticket number, closed price ...) when an event is triggered?
CheckEvents( MagicNumber );
if ( (orderInfo = eventBuyClosed_SL) > 0 )
Alert( Symbol(), ": Buy position was closed by StopLoss!", orderInfo.ticket, orderInfo.closedPrice ... );
Awsome article, Thank you sir!