Hello, I am importing discretionary option trades from a CSV file into AmiBroker. Each trade contains:
- Entry date
- Exit date
- Final PnL (in $)
To backtest this, I simulate trades on a synthetic symbol with constant price = 100. For each trade:
- Buy at 100 on entry
- Sell at a price adjusted so that the final PnL matches the known result., I.e for a $500 profit: sellprice = 105, 1 contract, pointvalue = 100
Trade statistics are correct. However, the portfolio equity curve is step-shaped because the synthetic price remains flat during the trade and changes only on exit, so the entire PnL is booked at the exit bar.
What I want instead is linear mark-to-market allocation of the known final PnL across the trade duration. Example:
- Profit = +500
- Duration = 5 bars
- Desired behavior: +100 per bar increase in equity until exit.
What I tried:
- Modifying synthetic prices (creating a ramp)
ā Affects chart but does NOT affect portfolio equity in the HTML report. - Custom Backtest Procedure:
- Running standard portfolio processing
- Iterating open positions
- Distributing profit per bar
- Modifying bo.Cash during the trade
- Reversing the accumulated adjustment at exit
This partially works but:
- Modifying bo.Cash gives inconsistencies in the equity (the way I tried)
- The HTML report seems to use internal engine equity arrays that may not be writable.
Questions:
- Is portfolio equity (used in the standard HTML report) writable or overridable from CBT? I mean directly, not via positionsize
- Is there a way to alter mark-to-market behavior of open positions?
- Is there a way to distribute final trade profit across its lifetime instead of booking it fully at exit?
I do NOT want to change final trade results ā only the intra-trade equity path.
Thank you.

