How to get "a position Maximum Net Profit until now"?

Created at 14 Jan 2022, 23:06
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!
MI

Mia999

Joined 13.11.2021

How to get "a position Maximum Net Profit until now"?
14 Jan 2022, 23:06


Hi,

Is there a way to monitor a position net profit variation through time?

For example, I'm trying to create a rule where:

if (((the position Maximum Net Profit until now) - (the position actual Net Profit)) > (3 * ATR * volumeInUnits))

 ---> ClosePosition

The goal is to protect / materialize a position's unrealized profit (what's left of it)  in case of a price change not otherwise covered by another ClosePosition rule.

I don't find a way to get a value for "the position Maximum Net Profit until now".

Any thought that might help?

Thanks


@Mia999
Replies

amusleh
17 Jan 2022, 09:32

Hi,

The API doesn't record each change on a position profit, it only gives you the current net profit as doing so will increase significantly the system resource usage.

But you can do it by your self, just subscribe to each position symbol OnTick event, when symbol price changes record that symbol positions net profit on a collection by using Position ID, and time, with amount of Net profit.

Later you can use that collection to get the Net profit of a position by using time.


@amusleh