Use 10% equity when buying each time in backtesting

I have a simple backtesting code in Amibroker. It looks something like this;

Buy = BuySignal();
Sell = SellSignal();

My equity is $10000. This code works but the limitation is that when it buys, the entire equity $10000 is sunk into the buy. What I want is something like this;

When BuySignal() is generated, buy $1000 or 10% of equity. Keep buying this amount whenever this BuySignal() is generated. If SellSignal() is generated, sell entire position.

How can I modify the code to do scaling-in of buying positions?

I am using Amibroker ver6.28.

1 Like