@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.
@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.