SL/TP identification of closed order

 

Hello,

As the topic's titles suggests, I am having trouble with a specific issue.

Given that I have the ticket number, how do I get a return true/false, 0/1, whatever.... to make code that acts accordingly, if the order has close by stoploss or takeprofit.


Anyone knows?


Thanks in advance,

PP

 
Pantelis Papaisidorou:

Given that I have the ticket number, how do I get a return true/false, 0/1, whatever.... to make code that acts accordingly, if the order has close by stoploss or takeprofit.

The only way that I am aware of is by reading the OrderComment().

It will have either sl or tp (usually [sl] or [tp], but I haven't checked all brokers) in the comment.

The problem is that the broker can change the comment, but I have never come across any broker that removes the sl or tp

 
  1. Reading the comment works only on those brokers that add that. Some do not.
  2. Select the order and see whether the close price is closer to the SL than the TP.
 
William Roeder:
  1. Reading the comment works only on those brokers that add that. Some do not.

I contacted the service desk years ago regarding this and they informed me that the platform automatically adds sl or tp to the order comment, so according to Metaquotes, it is not the broker that adds it.

 
Keith Watford: it is not the broker that adds it.

On my history the comment is unchanged. So it definitely does not work on MT4 demo.

History

The red highlighting on the SL/TP columns is done by the terminal.

Reason: