|Tutorial 31 – Data Mining on Technical Analysis|
In Tutorial 16 we looked at how to use Data Mining to identify instruments whose price has crossed above or below a moving average.
This week we continue with a similar theme, illustrating how Data Mining can be used to generate a list of trading opportunities based on your favourite technical criteria. We will look at two technical filters – each with a different level of complexity – to demonstrate the power of Data Mining.
In this tutorial:
For ease, we have included a link to download each filter in the relevant section. That way, you don’t have to worry about building the filter yourself. For more information about creating and editing Data Mining filters, please refer to Tutorial 6 – Basic Data Mining.
This fairly basic filter looks for stocks where the MACD is below zero and has crossed above its signal line during the last trading day.
We looked at the MACD in greater detail in Tutorial 23, discussing how it can be used to help spot trend reversals.
To reiterate, when the MACD rises above its signal line it is generally interpreted as a bullish signal, suggesting that the price of stock is likely to experience upward momentum. In addition, the MACD may also be used as divergence indicator (when the indicator fails to reflect the pattern on the price charts) illustrating a further sign of trend weakness and a likely reversal.
Instructions on uploading the file can be found in the Importing filters section below.
Once you have imported the file, click on the Select Filter button in the Data Mining screen and choose MACD / Signal from the list. This will display the following screen:
The grey control panel on the right shows the filter we are viewing and is comprised of four criteria. To the left we can see a list of shares that meet the criteria of the filter and just below, a scatter graph. More information on using these features is contained in Tutorial 6 – Basic Data Mining.
By now you should be aware that ShareScope includes a host of intuitive features to help you navigate the program with increased speed and efficiency. So let’s begin by selecting one of the filtered stocks. To do this, click on one of the shares in the list and then press Enter to view its graph.
To see the filter in practice, we will need to add the MACD indicator to the graph screen. To add this, simply right click in the middle of the screen and select Add Indicator then MACD... from the context menu.
This displays the following dialog:
The filter uses a standard 13 and 26 period MACD with a 9 period signal, so make sure these values are entered as in image above. In this example, we will also add a histogram – although this isn’t essential. Once you are happy with your selection, click OK.
We can now see the MACD displayed below the main graph window.
The histogram is another means of showing when the MACD (solid line) and signal line (dotted line) cross. The circled areas highlight the signal identified by the Data Mining filter – i.e. where the MACD is below “0” and has just crossed above its signal line.
This allows you to identify at a glance, formations that may be of greater interest – such as the bullish divergence pattern on the MACD below.
More information on interpreting the MACD can be found in Tutorial 23 – RSI and MACD Indicators.
Our second filter is more involved than the first, using a number of analytics created with the help of ShareScript. As such, it can only be used in ShareScope Plus/Pro.
This filter looks for momentum in the underlying price of a stock and draws on the MACD, Stochastic and exponential moving averages (EMAs) to help identify trend formations.
The key to this filter is that “buy” signals on each indicator are identified as having occurred within a specified number of days (not merely the last trading day). The rationale behind this is that signals are unlikely to occur on ALL criteria on a single trading day, and as such, widening the time frame enables us to populate our shortlist with a greater number of stocks. This can only be achieved using ShareScript.
This filter has been coupled with an ADX reading to help highlight strong trends.
Click here to find out more about ShareScript.
You will also need to download the following script files for the filter to work.
Instructions on uploading the file can be found in the Importing filters section below.
Once you have imported the file, click on the Select Filter button in the Data Mining screen and choose Momentum filter from the list.
Whilst we won’t go into great detail here, to summarise, the Stochastic is a momentum indicator which can be used to identify overbought and oversold conditions. It is plotted within a range of zero and 100, where a number above 80 is generally considered overbought and a number below 20 as oversold. As with the MACD, the crossing of the Stochastic above its signal line can also be interpreted as a “buy” signal.
The ADX is an indicator of trend strength and is also measured on a scale of 0 to 100. A reading below 20 indicates a weak trend (either bullish or bearish) and readings above 40 indicate a strong trend. ADX can also be used to identify potential changes in a market from trending to non-trending. When ADX begins to strengthen from below 20 and moves above 20, it is a sign that the trading range is ending and a trend is developing.
As you can see, there are 4 ShareScript criteria on the Data Mining sidebar:
ADX (bullish): this looks for the most recent 14-period ADX move above 20. The range boxes allow you to specify when the event happened. In this example, let’s include only ADX moves above 20 in the last 5 trading days. So enter “0” in the left box and “5” in the right box.
EMA cross: this looks for the most recent 20-day and 40-day EMA golden cross. This time, let’s exclude any cross older than 1 day - so enter “0” in the left box and “1” in the right box.
MACD cross: this looks for the most recent MACD move above its signal line. The filter uses a standard 13- and 26- period MACD with a 9 period signal. Let’s enter “0” and “5” to exclude anything older than 5 days ago.
Stoch cross: this criteria looks for the most recent stochastic move above its signal line. This time, we will exclude anything older than 3 days old. So enter “0” in the left box and “3” in the right box.
At the time of writing (18/02/2009), this filter generates only one LSE-listed stock – Electric Word PLC.
Of course, you may want to broaden your shortlist, in which case you can extend the time range used in each filter, change the list used or deactivate one of the criteria. See Tutorial 6 – Basic Data Mining for more information.
Let’s see the filter in practice. Simply select an item from your shortlist and press Enter to view the graph of the selected stock.
Now we will need to add the 4 criteria to our graph screen:
ADX: right click in the middle of the screen and select Add Indicator then Directional Movement (ADX)... from the context menu. In the following dialog, ensure that “14” is entered as the number of periods and click OK.
MACD: right click in the middle of the screen and select Add Indicator then MACD... from the context menu. As the filter is using a standard 13 and 26 period MACD with a 9 period signal, make sure these values are entered in the appropriate fields and click OK.
Stochastic: right click in the middle of the screen and select Add Indicator then Stochastic Oscillator... from the context menu. To replicate the filter settings, ensure the following settings are entered and press OK.
EMAs: to complete the graph screen will need to add a 20-day and a 40-day exponential moving average. You can do this via the Moving Averages... context menu option. For more information, please see Tutorial 22 - Understanding Moving Averages.
Having done this, the graph will appear as follows:
Let’s hone in on the most recent price history to see what the filter has signalled:
Let’s see how this matches up with the filter.
At point (1) we can see a golden cross emerging, as the 20-day EMA begins to cross above the 40-day EMA during the last trading day.
At point (2) the MACD crosses its signal line – within the 5 day time frame we specified in the filter.
Similarly, point (3) shows the Stochastic Oscillator passing through its signal line on 16/02/09 – just two trading days ago.
And finally, we can see the ADX moving above 20 (point 4) suggesting that a trend is developing.
You can backtest this filter quite easily – simply by changing the date range you are viewing. For example, to see how well the filter performed 20 trading days ago, change the minimum and maximum range values to say 20 and 25 trading days respectively. You can view the subsequent price movement to gauge the success of the filter.
Before importing either of the example filters into ShareScope, you first need to download the file to your desktop. To do this, simply click on one of the links above and select the option Save to Desktop. You will then need to unzip the file(s).
To import filter(s):
The next time you click on the Select Filter button on the Data Mining screen, you will notice that the new filter now appears in the list of available filters to view.
Please note that if you decide to upload the second filter (Momentum filter), you will also need to install the corresponding ShareScript files in order for the filter to work successfully.
To import the ShareScript files, download the above files to your desktop and unzip. In ShareScope, click on the Help menu option and select Open ShareScope folder. Open the ShareScript folder and then locate the Columns folder. Open this folder and copy the files here.
Don’t forget the ShareScope forums are an excellent place to share and discuss filters you have created. We have created a dedicated area specifically for this purpose.
To visit the ShareScope forum, click the following link: http://forums.sharescope.co.uk and click on the Data Mining section.
For more information on using the forums, please click on the following link: http://forums.sharescope.co.uk/faq.php.
Remember, if you have any trouble finding or using any of these features, please don’t hesitate to call our Customer Support team. They will be delighted to help.