I have a simple rotational model. At the end of the year it’s ranking all the stocks of the S&P500 based on the returns of that year. Then it will buy the 5 best performing stocks for the next year. If one of the stocks hit a loss of 25% this stock will be sold.
This code works fine, but I want to make one addition. When the ApplyStop is hit I want to move this position to a “safe haven” stock or ETF. In this case TLT.
(Add TLT to your selected watchlist or use multiple watchlist in the Analysis dialog).
This seems to work... almost: you need to start your test on the first day of an year and in few cases when multiple Stop are triggered on the same day the TLT (multiple positions) are entered
one at time in successive days.
Let's see if any other users have a better and more accurate idea.