positionprofit and portfolio backtester

Questions about MultiCharts and user contributed studies.
Phenydor
Posts: 2
Joined: 19 Jul 2016
Has thanked: 1 time

positionprofit and portfolio backtester

Postby Phenydor » 05 Mar 2017

Hi,

Does the positionprofit function work when using the portfolio backtester. I'm trying this test strategy below:

Code: Select all

if barnumber = 1 then buy next bar at market;
if barnumber = 10 then sell next bar at market;

print( "PositionProfit = ", positionprofit, "     OpenPositionProfit = ", openpositionprofit, "     BarNumber = ", barnumber );


When I run this, I can see openpositionprofit is showing values from bars 1 through 10. However, positionprofit is always being output as 0.

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: positionprofit and portfolio backtester

Postby Angelina MultiСharts » 07 Mar 2017

Hello Phenydor,

We are analyzing this case. I will get back to you with the answer.
These users thanked the author Angelina MultiСharts for the post:
Phenydor

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: positionprofit and portfolio backtester

Postby Angelina MultiСharts » 10 Mar 2017

Hello Phenydor,

Positionprofit returns total realized profit or loss for the specified closed position. When you do not specify PosBack value, it looks at the current position by default, therefore returning the value for the current position.
As current position is always open and your script doesn't produce partial fills, positionprofit will always return 0.
These users thanked the author Angelina MultiСharts for the post:
johnnykf88

Phenydor
Posts: 2
Joined: 19 Jul 2016
Has thanked: 1 time

Re: positionprofit and portfolio backtester

Postby Phenydor » 10 Mar 2017

Angelina MultiСharts wrote:Hello Phenydor,

Positionprofit returns total realized profit or loss for the specified closed position. When you do not specify PosBack value, it looks at the current position by default, therefore returning the value for the current position.


Ahh gotcha ... I didn't realize the positionprofit only returns realized profits and not unrealized profits (I suppose that's what gives openpositionprofit a purpose :P)

johnnykf88
Posts: 5
Joined: 07 Mar 2017
Has thanked: 2 times
Been thanked: 1 time

Re: positionprofit and portfolio backtester

Postby johnnykf88 » 29 Aug 2017

Angelina MultiСharts wrote:Positionprofit returns total realized profit or loss for the specified closed position. When you do not specify PosBack value, it looks at the current position by default, therefore returning the value for the current position.
As current position is always open and your script doesn't produce partial fills, positionprofit will always return 0.


Thanks Angelina :) , your explanation is much clearer than that in the wiki https://www.multicharts.com/trading-software/index.php/PositionProfit where the examples doesn't help to identify its difference from openpositionprofit.

So could you please tell what's the difference between positionprofit and positionprofit_checked keywords?
i did try these 2 in my script for checking the profit of the current position, they both showed '0' while openpositionprofit showed the unrealized profit in the current position.

Thanks.

User avatar
Henry MultiСharts
Posts: 8516
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2735 times

Re: positionprofit and portfolio backtester

Postby Henry MultiСharts » 31 Aug 2017

johnnykf88 wrote:So could you please tell what's the difference between positionprofit and positionprofit_checked keywords?
These commands work with the Realized PnL only, so you need to have at least a partially filled order in the current position for it to return any value. The only difference is the following: If PosBack value is greater that the real number of previously opened positions, PositionProfit_Checked will generate an error.

johnnykf88 wrote:i did try these 2 in my script for checking the profit of the current position, they both showed '0' while openpositionprofit showed the unrealized profit in the current position.
That's expected. OpenPositionProfit is specifically designed to show the unrealized profit for the current position, while positionprofit and positionprofit_checked work with the realized PnL.
These users thanked the author Henry MultiСharts for the post:
johnnykf88


Return to “MultiCharts”