I'm using Position.AveragePrice for serveral actions in a strategy.
Now I realised some stange behavior I cannot find an answer for.
So in the following chart I visualised the current Position.AveragePrice automatically as a thin white dotted line.
There are several position updates that should lead into Position.AveragePrice updates.
One initial short with quantity 4 (average price is updating, fine)
Then a BuyToCover with quantity 3 (average price is not updating, why?)
Then an additional short (average price is updating, fine)
Then a BuyToCover with quantity 1 (average price is updating, fine)
Then a BuyToCover with quantity 1 (average price is not updating, why?)
Can you help me to identify the reason or the issue?
Thanks in advance
And out of my log in the OnBarUpdate with the executions in OnExecutionUpdate and an optional AveragePrice print out if the AveragePrice changes:
2021-09-03 18:25:55:805 02.09.2021 04:45:00 OnExecutionUpdate NT-00187-160 Short@2021-09-02-04:45
2021-09-03 18:25:55:805 AveragePrice 02.09.2021 04:46:00 49742,5
2021-09-03 18:25:55:811 02.09.2021 06:12:00 OnExecutionUpdate NT-00188-160 TP 0/1 | PosBefore: 4
<<<<<<<Missing>>>>>>>>
2021-09-03 18:25:55:821 02.09.2021 09:15:00 OnExecutionUpdate NT-00189-160 Short@2021-09-02-04:45
2021-09-03 18:25:55:821 AveragePrice 02.09.2021 09:16:00 50088,5
2021-09-03 18:25:55:874 03.09.2021 01:26:00 OnExecutionUpdate NT-00190-160 TP 1/1 | PosBefore: 3
2021-09-03 18:25:55:874 AveragePrice 03.09.2021 01:27:00 50261,5
2021-09-03 18:25:55:879 03.09.2021 02:43:00 OnExecutionUpdate NT-00191-160 TP 1/2 | PosBefore: 2
<<<<<<<Missing>>>>>>>>
2021-09-03 18:25:55:903 03.09.2021 11:33:00 OnExecutionUpdate NT-00192-160 SL 1/1 | PosBefore: 1 0
2021-09-03 18:25:55:903 AveragePrice 03.09.2021 11:34:00 0
Comment