Below find two lines from a "Detailed Report". Buys and sells are on the close, with no trade lags, and no commissions. The option "Use previous bar equity for position sizing" is unchecked.
On 01/24 XLF is sold on the close, and the cash proceeds are fully invested to buy XLB. The final equity value, based on the closing prices of that day and the indicated position quantities, is correct.
The equity value listed after Exit Long is the equity value calculated at the open.
The equity value listed after Entry Long is the equity value at the open for the positions that are maintained (XLK and XLV) plus the cash proceeds from selling XLF at the close. I presume that this equity value is used to calculate the position size.
I am wondering whether there is a setting I may have missed somewhere, or whether AmiBroker is "hard-wired" to calculate equity using opening prices for unchanged positions even if all trades take place on the close. From reading another post on a similar topic this seems to be the case.
I know that executing this trading logic on the close (with closing equity calculation) is tricky and will always result in deviations from the actual closing calculations.
Just trying to understand.
3 Open Positions: , XLK (+2788.13), , XLV (+1681.5), , XLF (+2567.9), Market Value: 96987.05,
Equity: 96987.04, Cash: -0.00, Margin: 0.00, Net Cash Balance: -0.00,
Exit Long, XLF, Price: 11.70334, (Avg. exit pr. 11.70334), Shares: 2567.901, Commission: 0,
(Total comm.: 0), Profit: -2299.042 (-7.11 %), Entry rank:1, Equity: 97285.04, Fx rate: 1
Enter Long, XLB, Price: 12.45974, Shares: 2412.011, Commission: 0, Rank: 1, Equity 95536.66,
Margin Loan: 0, Fx rate: 1
3 Open Positions: , XLK (+2788.13), , XLV (+1681.5), , XLB (+2412.01), Market Value: 93145.51,
Equity: 93145.51, Cash: -0.00, Margin: 0.00, Net Cash Balance: -0.00,