Backtest: position.NetProfit at close not matching History.Last().NetProfit

Created at 18 Feb 2024, 22:57
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!
NC

ncel01

Joined 19.03.2020

Backtest: position.NetProfit at close not matching History.Last().NetProfit
18 Feb 2024, 22:57


Hello,

I noticed that, when backtstesting, position.NetProfit values ( inside Positions_Closed() ) are not matching with those in the history table ( History.NetProfit ).

I checked this with 2 different brokers. Same outcome.
Instrument: US500


@ncel01
Replies

PanagiotisCharalampous
19 Feb 2024, 06:36

Hi ncel01,

Can you share an example cBot that allows us to reproduce this?

Best regards,

Panagiotis


@PanagiotisCharalampous

ncel01
19 Feb 2024, 08:23

RE: Backtest: position.NetProfit at close not matching History.Last().NetProfit

PanagiotisCharalampous said: 

Hi ncel01,

Can you share an example cBot that allows us to reproduce this?

Best regards,

Panagiotis

Hi Panagiotis,

Can you please first try to check this by just adding a Print(o.Position.NetProfit) inside Positions_Closed()?

I need to create a whole cBot sample for this. I'll do it in case the above is not working with you.

Just let me know.

 


@ncel01

PanagiotisCharalampous
19 Feb 2024, 10:34

RE: RE: Backtest: position.NetProfit at close not matching History.Last().NetProfit

ncel01 said: 

PanagiotisCharalampous said: 

Hi ncel01,

Can you share an example cBot that allows us to reproduce this?

Best regards,

Panagiotis

Hi Panagiotis,

Can you please first try to check this by just adding a Print(o.Position.NetProfit) inside Positions_Closed()?

I need to create a whole cBot sample for this. I'll do it in case the above is not working with you.

Just let me know.

 

Works fine for me


@PanagiotisCharalampous

ncel01
19 Feb 2024, 11:00

RE: RE: RE: Backtest: position.NetProfit at close not matching History.Last().NetProfit

PanagiotisCharalampous said: 

ncel01 said: 

PanagiotisCharalampous said: 

Hi ncel01,

Can you share an example cBot that allows us to reproduce this?

Best regards,

Panagiotis

Hi Panagiotis,

Can you please first try to check this by just adding a Print(o.Position.NetProfit) inside Positions_Closed()?

I need to create a whole cBot sample for this. I'll do it in case the above is not working with you.

Just let me know.

 

Works fine for me

Panagiotis,

Please use an index as well and let me know.

I've noticed in the past that, unlike forex, similar issues applied to indices.


@ncel01

PanagiotisCharalampous
20 Feb 2024, 07:00

Hi ncel01,

Understood. The root cause of the problem is the same as in the other thread. It will be resolved in an upcoming update.

Best regards,

Panagiotis


@PanagiotisCharalampous

ncel01
20 Feb 2024, 08:09

RE: Backtest: position.NetProfit at close not matching History.Last().NetProfit

PanagiotisCharalampous said: 

Hi ncel01,

Understood. The root cause of the problem is the same as in the other thread. It will be resolved in an upcoming update.

Best regards,

Panagiotis

Hi Panagiotis,

That's what I thought.

Thanks for confirming!


@ncel01