I am trying to backtest a strategy that will buy the 5 top ranked ETFs from a list of 26, using 20% of the current account equity. The account is funded with $100,000 to start. When the strategy begins, buy $20,000 of each of the top five. After the holding period, rebalance the holdings with the new top five ranked ETFs. This looks to keep you invested in the "best" ETFs according to your ranking algorithm.
I have attached a very simple Strategy to do rebalancing on a weekly basis, ignoring the ranking feature for now. Here's the code --
Code: Select all
// If today is Thursday then sell the position tomorrow (Friday) at the Open
if DayOfWeek(Date) = 4 then Sell next bar at Open;
// If today is Friday then buy the position Monday at the Open
if DayOfWeek(Date) = 5 then Buy next bar at Open;
If I set the Trade Size to "500 Shares" in the Portfolio properties, Backtester will create 500-share positions until it runs out of portfolio equity. If I set Trade Size to $20,000, it will create $20k-sized positions until it runs out of portfolio equity. It just starts at the top of the ETF list and goes down until it runs out of money.
The problem comes when I set Trade Size to 20% of Equity in the Portfolio Properties. Now Backtester buys the entire list. It starts with 20% of $100K for the first position. It uses 20% of $80K for the second. Then 20% of $64K for the third. It continues to use the declining account balance until it reaches the end of the list.
I'm looking for comments and/or suggestions on this behavior. My experience with other backtesters (Wealth Lab, NT, AB, TradersStudio) is that they will take 20% of the current portfolio equity, not of the declining balance, for each new position. These other testers will create five positions at any time with close to 20% of the portfolio equity.
Has anyone out there worked on this problem ?
Do you have a way to tell Backtester to make five 20% positions as the portfolio equity grows and shrinks over time?
Thanks.