Tutorial - Compound Scan

Let's looks at the following compound scan.....

MACD1 <= 0 AND MACD > 0

In this scan, we introduce two new concepts: the compound scan, and the qualified scan token. We are going to run this scan on daily data to find MACD bullish crossovers. In other words, the MACD value for the previous day was less than or equal to zero, while the current day's MACD value is greater than zero.

First, open a new scan window (choose "New Scan Definition" from Name list). Now, let's start by either typing in the scan expression above or copy and pasting it into the scan expression box. Now click on the Check button. You will be asked for the preferences of the MACD indicator. For our example, let's choose an Exponential Moving Average of the Close, with a short term of 12, a long term of 26, and a Signal period of 3. If you would like additional information on the MACD, click here. Now let's take a closer look at the scan expression.

Compound Expressions: This scan expression is a compound expression due to the presence of the AND. When an AND is present, it means that the expression on both sides of the AND must be TRUE in order for the overall expression to evaluate to TRUE. If either sub-expression evaluates to FALSE, then the overall expression is FALSE. In this case, we ONLY want instruments whose MACD value was below zero yesterday AND is above zero today. The AND compound operator accomplishes this. Similarly, the OR operator would result in a TRUE result if EITHER sub-expression were TRUE. You can have as many ANDs and ORs as you like in your scan expression. You should be careful to properly parenthesize your expression in order to ensure appropriate evaluations. Remember, you can always check the order of evaluation by holding down the Cntl key while clicking on the Check button. We will discuss proper parenthesizing in further detail in the coming pages.

Qualified Tokens: Many tokens, including the Historical Data Tokens and the Technical Indicator Tokens, can be Qualified. Qualification refers to the appending of a number to the end of a token, such as the 1 appended to the MACD above, to get MACD1. Qualification allows you to access historical values for that token. The number appended to the token dictates how may periods into the past to go in order to access the proper data. For instance, the expression MACD1 tells Investor/RT to go back one period(or bar) and access the MACD value one bar back. If we are running our scan on daily data, the MACD1 simply means the MACD value yesterday. Similarly, MACD20 would mean the MACD value 20 days ago.

If we were running our scan on 5-minute data, then HI8 would mean the High of the 8th 5-minute bar back from the current bar. Similarly, if we were running the scan on 1-minute data, then the expression CL3 would mean the closing price of the bar 3 1-minute bars back. You can optionally use a period '.' between the token and the qualifying number if you would like. For instance, the expression HI2 and HI.2 are identical.

A very important exception must be noted. The tokens HI, LO, and OP will ALWAYS access daily data if they are used without qualifiers, regardless of the periodicity of the scan. For instance, if you are running a 5-minute scan and you use the expression HI, then you will get the DAILY high, not the high of the most recent 5-minute bar...which some might expect. It is designed this way to give the user access to daily HI, LO, and OP regardless of the timeframe of your scan. If you are using an Intraday periodicity, like 5-minute and you would like to access the LO for the most current 5-minute bar, you must use a qualifier of zero, or LO.0. Anytime a qualifier is used on HI, LO, and OP on intraday scans, then the intraday bars will be used for the data. The absence of a qualifier will force daily data access.

Now let's switch gears and look at other uses of scans, specifically, using Arithmetic in Scans.

<<Previous<< >> Next >>