Click here to Login

                                                   Issue with rebalancing


Dennis Schutten
2020-08-27 09:45:47


I have the following simple code:

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.


2020-08-29 13:53:45


Hi Dennis,

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).

Dennis Schutten
2020-08-31 10:05:35



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?


2020-09-01 12:53:26


Hi Dennis,

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;

No more messages


No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"


Trading Items
Custom Trading System Rebalancing
Top 20 stocks with the highest 10 day rate of change - Current an...
Minimum Variance Optimization with Solver V1.1- AMM
Short Term Trading System with RSI Ratios
Enhanced Candlestick Chart with Volume Variation

How-to Lessons
How to use QuantShare with Metastock data
How to create a chart with a black background
How to screen for stocks having a high correlation with the Dow J...
How to associate an index with a list of stocks
How to speed up watchlist and screener plug-ins when working with...

Related Forum Threads
charting issue with new version 2.91
Issue with QS Crashing
Peak / trough indicators and issue with Functions
CHM linked issue
Help with Survivorship Bias Free DB

Blog Posts
Working with the formula editor
Create Realtime Quote Sheets with the Watchlist Tool
How to Optimize a Trading System with Thousands of Billions of Co...
Industry Analysis - How to Compare Stocks with their Industries
How to measure market strength with the composite tool

Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2023
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

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.