Equity value at each buy


How is the equity value determined for the next trade during a back test or walk forward?

I'm using SetPositionSize(5,spsPercentOfEquity) and a stop. This is the first trade. Is the second trade using the equity value of $28,499 or $29,628



@DingoCC, as the name says, it is the percent of EQUITY, that is the amount of cash + the current value of all open positions.

@DingoCC, here is an example that I hope will help you to understand the matter better.

Look at the "Detailed log" (I highlighted the calculated Equity at each Buy/Entry ).

and then compare the "Position Value" column in the standard "Trade list":


You'll see that the dollar amount of the Position Value changes, but the percent is always 10% of the Equity (I ordered the results by entry Date).

In this example, for simplicity, I set my Initial Equity at 1M, max 10 positions (10% each), no margin, fractional shares allowed, Buying the next day at Open.
I also added some custom columns (I used the CBT) to clarify further how the Equity is calculated at the moment of Entry (i.e., it is equivalent to the Initial Equity (1M) + the current P&L). In a real situation, commissions are also taken into account.

Maybe I forgot some details, but in general, I think it is enough to clarify things. Comments from @Tomasz and expert users are welcome.


Thanks beppe for the detailed response.

I've tried to change the column sort order in the detailed report and now nothing is returned. I've broken it! I'll open another question on this.

@beppe Can you share please?

@DingoCC, unfortunately, no. I only wrote that code to help me better understand how AmiBroker calculates Equity, and it's a great simplification that doesn't take into account everything AB does internally. Furthermore, it was super slow (nested loops), so its usefulness is very limited.
Maybe some other more experienced developer has done a better job and wants to contribute to this thread.