A big part of stock movements could be explained by the movement of the entire stock market. If the Dow Jones declines by 1%, it is likely that your medium or small cap stock will decline too simply because the movement of the majority of stocks are highly correlated with one another and with the market as a whole. It is important that you do not underplay the importance and the impact of the whole market on individual stocks.
This is a reason to include and use measures of the market strength as part of your investment strategy. Before investing in stocks, it is often advised to measure and estimate the whole market strength. This could be done by analyzing broader indices such as the S&P 500, Russell 2000 or it could be done using market breadth indicators or better your own composites.
Creating your own composites seems like a very hard task but thanks to QuantShare, you can now create simple and advanced composites very easily. Here are some examples of market indicators you can create to measure market strength:
- Number of stocks trading above their 100-day moving average
- Ratio of stocks trading in overbought area compared to those trading in an oversold area
- Number of stocks whose RSI(2) value is above 70
- Average return of up trending stocks minus return of down trending stocks
- Number of stocks with positive analysts recommendations
- Average PEG ratio of all stocks that compose the S&P 500
- Percentage of stocks trading above their resistance line
The number of composites you can create is infinite. Now, let me show you how to create your first market composite with QuantShare.
Number of stocks trading above their 100-day moving average
First, let us open the composite control. To do this, select "Tools" then "Composites" from QS trading software menu.
In the composites control, click on "Add" to create a new market composite.
Step 1: Define symbols
We have to specify the stocks that will included in the composite calculation.
If you want to create a composite based on all stocks then keep the symbols selection control empty and click on "Next". Otherwise, click on "Add Condition", and specify one or several conditions to select your symbols.
Step 2: Specify the composite formula and calculation method
The formula is the most important part of a composite and it tells QuantShare how the composite is calculated.
To count the number of stocks trading above their 100-day moving average, type this:
composite = close > sma(100);
And use the following calculation method: "Calculate the sum of the values added to the composite".
How it works?
- QuantShare calculates the composite variable for each stock included in the composite (for each trading bar)
- For each date, it calculates the sum (specified in the calculation method) of the composite values (for all stocks)
- It creates a new ticker symbol for that composite and associates it with the new data.
Step 3: Finish
Click on "Next", specify start & end dates and period, click on "Next" again, type the composite name then click on "Next" one more time.
How to add a market indicator in your trading system
Let us say we have a trading system that enters a long position when a stock decreases by 10% and exits that position after 10 bars.
Follow the next steps to create this strategy:
- Select "Analysis -> Simulator"
- Create on "New" to create a new trading system
- Select the formula editor
- Set a "10 bars" N-Bar stop
- Type the next formula:
buy = perf(close, 30) < -10;
Now, let us add our previously created market indicator. The idea is to constantly measure market strength using the moving average composite and prevent our trading system from entering any new positions if the number of stocks trading above their moving average is decreasing.
Let us say that the name of the previously created composite is "^Stocks_Above_M100" (All composite symbols start with "^" character).
You can reference this symbol by calling the "GetSeries" function.
Just add the following line to the strategy formula:
a = GetSeries("^Stocks_Above_M100", close, LastData);
buy = buy and perf(a, 10) > 0;
Explanation: Buy only if the 10-bar return of the market indicator is positive
Main advantages of creating market composites with QuantShare
- Composites are automatically updated when you download new data. You can enabled/disable this option by selecting "Tools -> Composites", selecting "Settings" tab then checking or un-checking the "Automatically update composites..." option.
- Ability to use C# programming language to create advanced composites
- Ability to create end-of-day and intraday (any time frame) composites
- Ability to create composites based on other composites
Finally yet importantly, you can use your custom composites with any other QuantShare tools, this includes: charting, trading system, trading rules, neural network, genetic algorithms, portfolio…