How to count the number of trades that hit your stop loss or take profit target

Chris70  

one way you could do it (assuming you know the ticket number of the deal): via HistoryDealGetInteger(ticketnumber,DEAL_REASON) with the different return options enlisted in ENUM_DEAL_REASON

https://www.mql5.com/en/docs/constants/tradingconstants/dealproperties#enum_deal_reason

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
  • www.mql5.com
A deal is the reflection of the fact of a trade operation execution based on an order that contains a trade request. Each trade is described by properties that allow to obtain information about it. In order to read values of properties, functions of the Identifier of a position, in the opening, modification or closing of which this deal...
Reason: