check what generated the close of position

 

Hello,

A novice question:

I do not know how to verify/check if a position was closed by "touching" of StopLoss price. I mean that the position was opened with a StopLoss>0; also I coded some other conditions to close the position. How can I distinguish that the position was closed by StopLoss "touching" and not by the others conditions.

Thanks in advance for suggestions!

 
tenlau:

Hello,

A novice question:

I do not know how to verify/check if a position was closed by "touching" of StopLoss price. I mean that the position was opened with a StopLoss>0; also I coded some other conditions to close the position. How can I distinguish that the position was closed by StopLoss "touching" and not by the others conditions.

Thanks in advance for suggestions!

You have to use OnTradeTransaction() event handler, see this topic.
Reason: