Closed position, touched takeprofit or stoploss?

 

Good day traders, when i place orders i also place the takeprofit and the stoploss, I can also 

determine if the transaction has been closed by:

if (myPositions.Select (_Symbol) == false)

But I do not know how to determine if the price has touched my takeprofit or stoploss, since I ask 

the question at the beginning of each candle and because the price has touched a limit in some time 

of the previous candle, and until I ask the question from above the price could have turned around 

and touch the other limit.

Any advice, function, class or suggestion, help me determine if I touch stoploss or takeprofit

Thank you

Renato                               

 
RenatoMasias:

Good day traders, when i place orders i also place the takeprofit and the stoploss, I can also 

determine if the transaction has been closed by:

if (myPositions.Select (_Symbol) == false)

But I do not know how to determine if the price has touched my takeprofit or stoploss, since I ask 

the question at the beginning of each candle and because the price has touched a limit in some time 

of the previous candle, and until I ask the question from above the price could have turned around 

and touch the other limit.

Any advice, function, class or suggestion, help me determine if I touch stoploss or takeprofit

Thank you

Renato                               

Use the ENUM_DEAL_REASON property. Code example: Stop Loss Take Profit 

The excellent enumeration ENUM_DEAL_REASON was added in build 1625:

ENUM_DEAL_REASONReason description
......
DEAL_REASON_SLThe operation was executed as a result of Stop Loss activation
DEAL_REASON_TPThe operation was executed as a result of Take Profit activation
......

It can be checked in OnTradeTransaction.

 
thanks friend
 

When i enter a void OnTradeTransaction?, i no see call a this function in the example.

I only need a flag for touch SL o TP, but i see more of 100 lines for this.

Reason: