Tracking net profit for ReversePosition

Created at 01 Oct 2019, 10:29
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
NO

noppanon

Joined 17.05.2017

Tracking net profit for ReversePosition
01 Oct 2019, 10:29


Hi there,

   When Bot call ReversePosition, the same position will switch the trade type from Buy to Sell or Sell to Buy. The History will records the net profit. And the reverse position will have it own net profit, not carry the previouse position.

   But how can I tracking the net profit of previous position? Because Only OnPositionModify event is triggered. I don't know that it was trigger by reverse or volume or TP/SL. 

 

Please advise

 

Noppanon


@noppanon
Replies

PanagiotisCharalampous
02 Oct 2019, 08:33

Hi Noppanon,

You can track the closed deal in the History property.

Best Regards,

Panagiotis


@PanagiotisCharalampous

noppanon
02 Oct 2019, 10:51

Hi Panagiotis,

   Thank you for your suggestion. However, how can I identify which trade in the History is the one which is closed? I found that Position.Id (the trade before close) and HistoryTrade.ClosingDelId are not matched.

regards,

Noppanon


@noppanon

PanagiotisCharalampous
02 Oct 2019, 10:56

Hi Noppanon,

Use the PositionId property of the HistoricalTrade.

Best Regards,

Panagiotis


@PanagiotisCharalampous

noppanon
02 Oct 2019, 11:03

Hi Panagiotis,

   Thank you for you advice.

regards,

Noppanon


@noppanon