This article will show how a Buy or Sell signal can be generated when three studies agree with each other. The purpose of the article is to show how consensus among studies can be determined. No claim is being made that the signals are profitable.
Our example trading system will use input from three studies: Relative Strength Index (RSI), Stochastic Momentum (SM), and two Moving Averages (MA). The study signals are defined as:
- Buy when 3 period MA > 17 period MA, Sell when 3 period MA < 17 period MA.
- Buy when SM > Ave(SM), and Sell when SM < Ave(SM). Use 10 Bar, 25, 2, 7 averages.
- Buy when RSI > 60, and Sell when RSI < 40. Use a 7 period RSI parameter.
The 3 period moving average is plotted in Green on the chart when it is above the 17 period moving average plotted in Blue. The 3 period MA is plotted in Red when it is below the 17 period MA.
The first study window shows the Stochastic Momentum study plotted in Green and Red, based upon whether the study is above or below a 7 period average of the SM plotted in Blue.
The bottom study window show the Relative Strength Index. It is plotted in Green when it is above 60 and plotted in Red when it is below 40. Between 40 and 60 the RSI is plotted in Blue.
Alerts will be used to indicate when all three studies are in their Buy zone (plotting in green), or in their Sell zone (plotting in Red). The Buy Signal will be the consensus of all 3 studies showing a Buy signal. The Sell Signal will be the consensus of all 3 studies showing a Sell signal. The current state of the studies and their consensus will be shown at the bottom of the chart. Here is the setup for the six Alert objects used for the system.
The first alert tests whether the first average line (3 period) is above the 2nd average line (17 period). When this condition is True, the Section 1 position at the bottom of the chart is colored Green and the message 'MA Buy' is shown. When the condition if False, the Section 1 position is colored Red and the message 'MA Sell' is shown. The result of this alert is written to global variable 2 for use later on.
This alert tests the relationship of the SM study to its average. When SM > Ave, the Section 2 position is colored Green and the message 'SM Buy' is shown. Otherwise, the Section 2 is colored Red with the message 'SM Sell'. The result of this alert is written to global variable 3 for use later on.
This alert will test for the RSI study being above 60 and color Section 3 Green with the message 'RSI Buy'. Note, however, this alert does not color the section Red when it is not above 60. Another alert will be used to color the section Red when the RSI is below 40. The alert result is written to variable 4.
This alert will test for the RSI study being above 40 and color Section 3 Red with the message 'RSI Sell' when it is False. This is a little different style than what was used in the previous alert. I want to store in global variable 1 a False when RSI is below 40 and a True when it is above 40. You will understand the reason for this in the last alert that generates the consensus Sell signal.
This is the alert that generates the consensus Buy signal. Three of the alerts wrote their True/False results into global variables 2, 3, and 4. The Buy consensus exists when all three of these values are True. The alert uses the Global Flag category in panel A, to return the Count of the global variables that are True. The Count True function is going to count 3 variables starting with Global Variable number 2. When the Count True function returns a value of 3, the Section 6 position will be colored Green and show the message 'BUY'.
This alert counts the Sell signals which are stored in 3 global variables starting with Global Variable number 1. Remember, variable 1 holds a False when the RSI study is below 40. This lends itself to being counted with the other 2 signals when they are also False. When global variables 1, 2 and 3 are all False, the consensus signal is shown in Section 6 using a Red color and the 'SELL' message.
The following chart shows the three sell study signals on the left, and the consensus SELL signal on the right.
The next chart shows the three buy study signals on the left, and the consensus BUY signal on the right.
And finally, the next example shows disagreement in the study signals. One is showing a buy, one a sell, and the RSI study is neutral because it is between 40 and 60. Therefore, no consensus signal is shown.
A template for this system can be downloaded from the Ensign web site. The template is named: Study-Consensus.
| contact us
Ensign Software, Inc., 113 Stillwater Drive, Idaho Falls, ID 83404 Support: 801-328-1382 Billing: 208-552-2230
(c) 2011 Ensign Software, Inc. All Rights Reserved
Last modified 8/4/11 2:34 PM