Scale in buying positions in Amibroker backtesting

795 Views Asked by At

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

There are 1 best solutions below

0
On BEST ANSWER

Try this.

PosQty = 10; 
SetOption("MaxOpenPositions", PosQty );
PositionSize = -100/PosQty;

Buy = IIf(BuySignal(), sigScaleIn, 0);