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_REASON | Reason description |
---|---|
... | ... |
DEAL_REASON_SL | The operation was executed as a result of Stop Loss activation |
DEAL_REASON_TP | The operation was executed as a result of Take Profit activation |
... | ... |
It can be checked in OnTradeTransaction.
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.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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