How to check reason SL or TP from deal

 

I want to check weather the deal in history is SL or TP. How do I track the deal from the order number that assigned when place order (name: ticket01).

I understand that 'HistoryDealGetTicket' parameter is 'Number of a deal in the list of deals'. But what is that?

      ulong deal = HistoryDealGetTicket(HistorySelectByPosition(ticket01));

      int reason = HistoryDealGetInteger(deal,DEAL_REASON);

I am very new to coding in general and here, Thank you for every suggestion and answer!

 
kotto_98:

I want to check weather the deal in history is SL or TP. How do I track the deal from the order number that assigned when place order (name: ticket01).

I understand that 'HistoryDealGetTicket' parameter is 'Number of a deal in the list of deals'. But what is that?

      ulong deal = HistoryDealGetTicket(HistorySelectByPosition(ticket01));

      int reason = HistoryDealGetInteger(deal,DEAL_REASON);

I am very new to coding in general and here, Thank you for every suggestion and answer!

Have a look at the deal tracking code directly below:

//--- select the total number of deals and orders

in:

Code Base

Show Positions on Custom Chart (or standard chart) for MT5

Ryan L Johnson, 2025.06.02 14:02

This indicator is a utility that shows labelled trade levels on any chart. If you want to replace your native trade levels on a native chart, then turn off "Show trade levels" in your F8 Chart Properties and attach this indicator. If you want to show trade levels on a Custom Chart (where native trade levels cannot be shown), then simply attach this indicator. BaseSymbol - specify the Symbol from which the trade level data will be pulled--handy for unique Custom Symbols. TextBarsBack - specify the number of bars back in history from the current bar where the level labels will be drawn. Note: Although magic number is referenced in the code, it is not presently included in the trade lines. If you're running multiple EA's on the same Symbol, you can edit the code to show magic numbers and then run multiple instances of the indicator on one chart. You can also edit the font sizes and text spacing in the object properties as needed for different display resolutions.