Hi Guys,
Written an algorithm which uses Relative Strength Indicator on a universe of stocks to buy or sell stocks.I am getting a crazy return of -94287607.6%.I am not able to get a hang of the problem.
Hi Guys,
Written an algorithm which uses Relative Strength Indicator on a universe of stocks to buy or sell stocks.I am getting a crazy return of -94287607.6%.I am not able to get a hang of the problem.
Cool idea but you are allowing your algo to borrow a bunch of $$$. That means your cash goes negative and when you buy your really shorting the stock and going further in the hole. You need to weight your investment per stock and use absolute values just in case your cash goes negative somehow. I added a couple lines to evenly weight your portfolio and recorded your cash and positions.
The back test lets you borrow whatever you want, it's on you to make sure you don't.