SetSimLongRank(-rsi(14)); // Instructs QS to first buy stocks with the highest rank
newmonth = week()!= ref(week(),-1);
buy = 1 ;
sell = newmonth;
While backtesting this works fine. However once in a portfolio or rerunning in the simulator with new data it does not rebalance last period even is all data is present and up to date.
What could be the issue? Symbols are selected from a static watchlist and I see all data is updated.
In an EOD portfolio, the rebalance is based on the rebalance date specified. If you want to rebalance that portfolio then you can run it once a week before the market opens on Monday (so that week() because different than the previous week).
This does not anwers my question completly. I have a stategy which I have made on the 18th of august. When I rerun this strategy in the simulator with latest data it does not rebalance. What could be the issue?
Sometimes, you need to update the strategy to make it work with the portfolio.
In your case, if you run for example the strategy on Tuesday, it will not buy anything even if you did run it since a long time.
The reason is that "newmonth" (should be called newweek) will return false, no stock will be sold and thus no stocks will be bought because probably there is no extra room for more positions.
You should either run it on Monday or just remove that rule and set:
sell = 1;
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.