doing different activities depending TP or SL accrued

 

hi every one.

how to tell if a position closed by TP or by SL was opened by EA?

i have an open position  by  using OrderSend(). depend on TP or SL happen, i want to call FunctionA() (When TP  ) and Function2() (when SL happen).


thanks.

 
Aimak:

You can use OrderComment() to search for [tp] or [sl] in the comment of orders from history


thanks.

is there any way to use Ontrade()?

how can i have the accurate time of closing by TP or SL?

 

mohsen bahrami:

how to tell if a position closed by TP or by SL was opened by EA? i have an open position  by  using OrderSend(). depend on TP or SL happen, i want to call FunctionA() (When TP  ) and Function2() (when SL happen).

is there any way to use Ontrade()? how can i have the accurate time of closing by TP or SL?

Here is the link of a similar thread on the forum that can help you answer your query:
 
Aimak: You can use OrderComment() to search for [tp] or [sl] in the comment of orders from history
Not all brokers modify comments that way. Not a good idea to use comments, brokers can change comments, including complete replacement.
Reason: