ScanTheMarket.com Documentation
Detailed information about ScanTheMarket.com can be found in the
ScanTheMarket.com Getting Started Guide.
A 100-page programming guide for the ScanScript programming language is available
here.
These documents are viewable with Adobe's Acrobat Reader. You can download Adobe
Acrobat Reader for many different platforms for free. In addition, Adobe
provides installation instructions, technical notes, and customer support for
each of the Acrobat platforms offered.
Printed Documentation
ScanTheMarket.com User's Guide
ISBN: 978-1-4243-0105-8
Both documents mentioned above are available in printed form. The ScanTheMarket.com User's Guide an indispensable resource for anyone interested in using ScanTheMarket.com to maximize profit and minimize loss. The guide explains the features of ScanTheMarket.com and the ScanScript programming language gradually by introducing a few concepts and notations in each chapter. The in-depth coverage and example-driven approach makes this guide a must-read!
The printed User's Guide book is available free of charge when
you purchase a one-year subscription to ScanTheMarket.com.
Function Reference Guide
Conditional IF Function
IF(Condition, True part, False part)
The conditional IF function allows you to design complex Boolean logic filters. If you paste the following script into the
Script area on the Download section of the ScanTheMarket.com web site and proceed to download data, you will see a column of
numbers that oscillate between 1 and -1, depending on when the closing price is greater than the opening price:
SET A = IF(CLOSE > OPEN, 1, -1)
The first argument of the IF function is a logical test. The second argument is the value that will be used if the
condition evaluates to TRUE. Conversely, the third argument is the value that will be used if the condition evaluates to
FALSE. The logical test may be any value or expression that can be evaluated to
TRUE or FALSE. For example,
CLOSE = OPEN is a
logical expression; if the close price is the same as the opening price, the expression evaluates to
TRUE. Otherwise, the
expression evaluates to FALSE.
LOOP Function
LOOP(Vector1, Vector2, Offset1, Offset2, Operator)
LOOP provides simulated control structure by means of a single function call.
Vector1 is the vector to initialize the calculation from. Offset1 is the offset where values are referenced in Vector1 for
the incremental calculation, and Offset2 is the offset where values are referenced from in Vector2.
Example 1:
In the case of SET X = REF(X, 1), Vector1 is
X and Vector2 is 1. Since we're adding the value of 1 (not a vector) to
X in the
following example, Offset2 is set to zero:
SET X = LOOP(X, 1, 1, 0, ADD)
And now X contains the series 1,2,3,4,5,6,...n
Example2:
SET X = REF(CLOSE,1)
SET Y = (REF(Y, 3) - X) * 2
Because Y requires control structure we must instead write:
SET X = REF(CLOSE,1)
SET Y = LOOP(Y, X, 3, 0, SUBTRACT) * 2
We could reduce that to:
SET Y = LOOP(Y, CLOSE, 3, 1, SUBTRACT) * 2
Valid operators are ADD, SUBTRACT,
MULTIPLY and DIVIDE
COUNTIF
COUNTIF(Condition)
Returns a vector representing the total number of times the specified condition evaluated to
TRUE.
Example:
COUNTIF(CROSSOVER(SimpleMovingAverage(CLOSE, 14), CLOSE))
The script returns a vector with increasing values expressing the number of times the 14-day Simple Moving Average crossed
over the closing price.
LASTIF
LASTIF(Condtion)
Similar to COUNTIF, except LASTIF returns a vector containing the number of days since the last time the specified condition
evaluated to TRUE. The count is reset to zero each time the condition evaluates to
TRUE.
Example:
LASTIF(CLOSE < REF(CLOSE, 1))
The script returns a vector that increases in value for each bar where the closing price was not less than the previous
closing price. When the condition evaluates to TRUE, meaning the closing price was less than the previous closing price, the
reference count is reset to zero.
SUMIF
SUMIF(Condtion, Vector)
Last in the IF function lineup is the SUMIF function. This function outputs a running sum of all values in the supplied
Vector wherever the supplied Condition evaluates to TRUE.
For example if we wanted a vector containing the sum of volume for all the days where the closing price closed up 5%, we
could write:
FIND STOCKS WHERE SUMIF(CLOSE > REF(CLOSE,1) * 1.05, VOLUME)
The result will be a vector containing a running sum of volume for each day where the closing price closed up at least 5%.
SUM
SUM(Vector, Periods)
The SUM function (not to be confused with the
SUMIF function) outputs a vector containing a running sum, as specified by the
Periods argument.
Example:
SUM(CLOSE, 10)
The script returns a vector of sums based on a 10-period window.
AVG
AVERAGE(Vector, Periods)
AVG(Vector, Periods)
Returns a vector containing a running average, as specified by the Periods argument. The
AVERAGE function can also be
referenced by AVG for short.
Example:
AVERAGE(CLOSE, 10)
AVG(CLOSE, 10)
Both scripts return a vector of averages based on a 10- period window.
MAX
MAX(Vector, Periods)
Returns a vector containing a running maximum, as specified by the Periods argument. The values represent the maximum value
for each window.
Example:
MAX(CLOSE, 10)
Returns a vector of maximum values based on a 10- period window.
MIN
MIN(Vector, Periods)
Returns a vector containing a running minimum, as specified by the Periods argument. The values represent the minimum value
for each window.
Example:
MIN(CLOSE, 10)
Returns a vector of minimum values based on a 10- period window.
MAXOF
MAXOF(Vector1, Vector2, [Vector3]...[Vector8])
Returns a vector containing a maximum value of all specified vectors, for up to eight vectors. Vector1 and Vector2 are
required and vectors 3 through 8 are optional.
Example:
MAXOF(CLOSE, OPEN)
Returns a vector containing the maximum value for each bar, which is either the opening price or the closing price in this
example.
MINOF
MINOF(Vector1, Vector2, [Vector3]...[Vector8])
Returns a vector containing a minimum value of all specified vectors, for up to eight vectors. Vector1 and Vector2 are
required and vectors 3 through 8 are optional.
Example:
MINOF(CLOSE, OPEN)
Returns a vector containing the minimum value for each bar, which is either the opening price or the closing price in this
example.
REF
REF(Vector, Periods)
By default all calculations are performed on the last, most recent value of a vector. The following script finds stocks where
the last open price (the current bar's open price) is less than $30:
FIND STOCKS WHERE OPEN < 30
OPEN is assumed to be the current bar's open by default. You can reference a previous value of a vector by using the
REF
function:
FIND STOCKS WHERE REF(OPEN, 1) < 30
And now the script will find stocks where previous bar's open price was less than $30. The number 1 (the second argument)
tells the REF function to reference values as of one bar ago. To reference values two bars ago, simply use 2 instead of 1.
The valid range for the Periods argument is 1 - 250 unless otherwise noted.
TREND
TREND(Vector)
The TREND function can be used to determine if data is trending upwards, downwards, or sideways. This function can be used on
the price (open, high, low, close), volume, or any other vector. The TREND function returns a constant of either
UP, DOWN or
SIDEWAYS. Example:
FIND STOCKS WHERE TREND(CLOSE) = UP AND TREND(VOLUME) = DOWN
TREND is often the first function used as a means of filtering stocks that are not trending in the desired direction.
CROSSOVER
CROSSOVER(Vector1, Vector2)
Many technical indicators such as the MACD for example, have a "signal line". Traditionally a buy or sell signal is generated
when the signal line crosses over or under the technical indicator.
The CROSSOVER function helps you find stocks where one series has crossed over another. For example, we can find the exact
point in time when one moving average crossed over another by using the CROSSOVER function:
SET MA1 = SimpleMovingAverage(CLOSE, 28)
SET MA2 = SimpleMovingAverage(CLOSE, 14)
FIND STOCKS WHERE CROSSOVER(MA1, MA2) = TRUE
The script above will return a list of stocks where the MA1 vector most recently crossed over the MA2 vector. And we can
reverse the script to find stocks where the MA1 vector crossed below the MA2 vector:
FIND STOCKS WHERE CROSSOVER(MA2, MA1) = TRUE
ABS
ABS(Number)
The ABS function returns the absolute value for a number. Negative numbers become positive and positive numbers remain
positive.
Example:
ABS(CLOSE - OPEN)
The script always evaluates to a positive number, even if the opening price is greater than the closing price.
SIN
SIN(Number)
The SIN function returns the sine for a number (angle).
Example:
SIN(45)
The script outputs 0.851
COS
COS(Number)
COS returns the cosine for a number (angle).
Example:
COS(45)
The script outputs 0.525
TAN
TAN(Number)
The TAN function returns the tangent for a number (angle).
Example:
TAN(45)
The script outputs 1.619
ATN
ATN(Number)
Returns the arctangent for a number.
Example:
ATN(45)
The script outputs 1.548
EXP
EXP(Number)
EXP raises e to the power of a number. The
LOG function is the reverse of this function.
Example:
EXP(3.26)
The script outputs 26.28
LOG
LOG(Number)
Returns the natural logarithm of a positive number. The EXP function is the reverse of this function. Also see
LOG10.
Example:
LOG(26.28)
The script outputs 3.26
LOG10
LOG10(Number)
Returns the base 10 logarithm of a positive number. Also see LOG.
Example:
LOG10(26.28)
The script outputs 1.42
RND
RND(Number)
The RND function returns a random number from 0 to a maximum value.
Example:
RND(100)
Outputs a random number from 0 to 100.
Simple Moving Average
SimpleMovingAverage(Vector, Periods)
SMA(Vector, Periods)
MA Type Argument ID: SIMPLE
Overview
The Simple Moving Average is simply an average of values over a specified period of time.
Interpretation
A Moving Average is most often used to average values for a smoother representation of the underlying price or indicator.
Example
FIND STOCKS WHERE CLOSE > SMA(CLOSE, 30)
Finds stocks where the close is greater than a 30-day SMA.
Exponential Moving Average
ExponentialMovingAverage(Vector, Periods)
EMA(Vector, Periods)
MA Type Argument ID: EXPONENTIAL
Overview
An Exponential Moving Average is similar to a Simple Moving Average. An EMA is calculated by applying a small percentage of
the current value to the previous value, therefore an EMA applies more weight to recent values.
Interpretation
A Moving Average is most often used to average values for a smoother representation of the underlying price or indicator.
Example
FIND STOCKS WHERE CLOSE > EMA(CLOSE, 30)
Finds stocks where the close is greater than a 30-day EMA.
Time Series Moving Average
TimeSeriesMovingAverage(Vector, Periods)
TSMA(Vector, Periods)
MA Type Argument ID: TIME_SERIES
Overview
A Time Series Moving Average is similar to a Simple Moving Average, except that values are derived from linear regression
forecast values instead of regular values.
Interpretation
A Moving Average is most often used to average values for a smoother representation of the underlying price or indicator.
Example
FIND STOCKS WHERE CLOSE > TSMA(CLOSE, 30)
Finds stocks where the close is greater than a 30-day TSMA.
Variable Moving Average
VariableMovingAverage(Vector, Periods)
VMA(Vector, Periods)
MA Type Argument ID: VARIABLE
Overview
A Variable Moving Average is similar to an exponential moving average except that it adjusts to volatility.
Interpretation
A Moving Average is most often used to average values for a smoother representation of the underlying price or indicator.
Example
FIND STOCKS WHERE CLOSE > VMA(CLOSE, 30)
Finds stocks where the close is greater than a 30-day VMA.
Triangular Moving Average
TriangularMovingAverage(Vector, Periods)
TMA(Vector, Periods)
MA Type Argument ID: TRIANGULAR
Overview
The Triangular Moving Average is similar to a Simple Moving Average, except that more weight is given to the price in the
middle of the moving average periods.
Interpretation
A Moving Average is most often used to average values for a smoother representation of the underlying price or indicator.
Example
FIND STOCKS WHERE CLOSE > TMA(CLOSE, 30)
Finds stocks where the close is greater than a 30-day TMA.
Weighted Moving Average
WeightedMovingAverage(Vector, Periods)
WMA(Vector, Periods)
MA Type Argument ID: WEIGHTED
Overview
A Weighted Moving Average places more weight on recent values and less weight on older values.
Interpretation
A Moving Average is most often used to average values for a smoother representation of the underlying price or indicator.
Example
FIND STOCKS WHERE CLOSE > WMA(CLOSE, 30)
Finds stocks where the close is greater than a 30-day WMA.
Welles Wilder Smoothing (Moving Average)
WellesWilderSmoothing(Vector, Periods)
WWS(Vector, Periods)
MA Type Argument ID: WILDER
Overview
The Welles Wilder's Smoothing indicator is similar to an exponential moving average. The indicator does not use the standard
exponential moving average formula. Welles Wilder described 1/14 of today's value + 13/14 of yesterday's average as a 14-day
exponential moving average.
Interpretation
This indicator is used in the manner that any other moving average would be used.
Example
FIND STOCKS WHERE CLOSE > WWS(CLOSE, 30)
Finds stocks where the close is greater than a 30-day WWS.
Volatility Index Dynamic Average - VIDYA (Moving Average)
VIDYA(Vector, Periods, R2Scale)
MA Type Argument ID: VIDYA
Overview
VIDYA (Volatility Index Dynamic Average), developed by Mr. Tuschar Chande, is a moving average derived from linear regression
R2.
Interpretation
A Moving Average is most often used to average values for a smoother representation of the underlying price or indicator.
Because VIDYA is a derivative of linear regression, it quickly adapts to volatility.
Parameters
R2Scale is a value specifying the R-Squared scale to use in the linear regression calculations. Mr. Chande recommends a value
between 0.5 and 0.8 (default value is 0.65).
Example
FIND STOCKS WHERE CLOSE > VIDYA(CLOSE, 30, 0.65)
Finds stocks where the close is greater than a 30-day VIDYA with an R2 of 0.65.
Linear Regression Functions
A classic statistical problem is to try to determine the relationship between two random variables X and Y such as the
closing price of a stock over time. Linear regression attempts to explain the relationship with a straight line fit to the
data.
The linear regression model postulates that Y = a + bX + e
Where the "residual" e is a random variable with mean zero. The coefficients a and b are determined by the condition that the
sum of the square residuals is as small as possible. The indicators in this section are based upon this model.
R2 (R-Squared)
RSquared(Vector, Periods)
R2(Vector, Periods)
Overview
R-Squared is the coefficient of determination for the supplied vector over the specified periods. The values oscillate
between 0 and 1.
Example
FIND STOCKS WHERE R2(CLOSE, 30) < 0.1
Finds stocks where the coefficient of determination is less than 0.1.
Slope
Slope(Vector, Periods)
Overview
Returns the linear regression slope value for the data being analyzed over the specified number of periods. Values oscillate
from negative to positive numbers.
Example
FIND STOCKS WHERE SLOPE(CLOSE, 30) > 0.3
Finds stocks where the slope is greater than 0.3.
Forecast
Forecast(Vector, Periods)
Overview
Returns the linear regression forecast for the next period based on the linear regression calculation over the specified
number of periods.
Example
FIND STOCKS WHERE Forecast(CLOSE, 30) > REF(CLOSE,1)
Finds stocks where the forecast is higher than the previous closing price.
Bollinger Bands
BollingerBandsTop(Vector, Periods, Standard Deviations, MA Type)
BBT(Vector, Periods, Standard Deviations, MA Type)
BollingerBandsMiddle(Vector, Periods, Standard Deviations, MA Type)
BBM(Vector, Periods, Standard Deviations, MA Type)
BollingerBandsBottom(Vector, Periods, Standard Deviations, MA Type)
BBB(Vector, Periods, Standard Deviations, MA Type)
Overview
Bollinger bands rely on standard deviations in order to adjust to changing market conditions. When a stock becomes volatile
the bands widen (move further away from the average). Conversely, when the market becomes less volatile the bands contract
(move closer to the average). Tightening of the bands is often used as an early indication that the stock's volatility is
about to increase.
Interpretation
Bollinger Bands (as with most bands) can be imposed over an actual price or another indicator. When prices rise above the
upper band or fall below the lower band, a change in direction may occur when the price penetrates the band after a small
reversal from the opposite direction.
Recommended Parameters
Vector: CLOSE
Periods: 20
Standard Deviations: 2
MA Type: EXPONENTIAL
Example
FIND STOCKS WHERE CLOSE > BBT(CLOSE, 20, 2, EXPONENTIAL)
Finds stocks where the close is greater than a 20-day Bollinger Band Top calculated by 2 standard deviations, using an
exponential moving average.
Moving Average Envelope
MovingAverageEnvelopeTop(Periods, MA Type, Shift)
MAET(Periods, MA Type, Shift)
MovingAverageEnvelopeBottom(Periods, MA Type, Shift)
MAEB(Periods, MA Type, Shift)
Overview
Moving Average Envelopes consist of moving averages calculated from the underling price, shifted up and down by a fixed
percentage.
Interpretation
Moving Average Envelopes (or trading bands) can be imposed over an actual price or another indicator. When prices rise above
the upper band or fall below the lower band, a change in direction may occur when the price penetrates the band after a small
reversal from the opposite direction.
Recommended Parameters
Periods: 20
MA Type: SIMPLE
Shift: 5
Example
FIND STOCKS WHERE CLOSE > MAET(20, SIMPLE, 5)
Finds stocks where the close is greater than a 20-day Moving Average Envelope Top calculated by 5% using a simple moving
average.
Prime Number Bands
PrimeNumberBandsTop()
PNBT()
PrimeNumberBandsBottom()
PNBB()
Overview
This novel indicator identifies the nearest prime number for the high and low and plots the two series as bands.
Example
FIND STOCKS WHERE CLOSE > PNBT()
Finds stocks where the close is greater than the Prime Number Bands Top.
Momentum Oscillator
MomentumOscillator(Vector, Periods)
MO(Vector, Periods)
Overview
The momentum oscillator calculates the change of price over a specified length of time as a ratio.
Interpretation
Increasingly high values of the momentum oscillator may indicate that prices are trending strongly upwards. The momentum
oscillator is closely related to MACD and Price Rate of Change (ROC).
Recommended Parameters
Vector: CLOSE
Periods: 14
Example
FIND STOCKS WHERE MO(CLOSE, 14) > 90
Finds stocks where the momentum oscillator of the close is over 90
Chande Momentum Oscillator
ChandeMomentumOscillator(Vector, Periods)
CMO(Vector, Periods)
Overview
The Chande Momentum Oscillator (CMO), developed by Tushar Chande, is an advanced momentum oscillator derived from linear
regression. This indicator was published in his book titled "New Concepts in Technical Trading" in the mid 90's.
Interpretation
The CMO enters into overbought territory at +50, and oversold territory at -50. You can also create buy/sell triggers based
on a moving average of the CMO.
Also, increasingly high values of CMO may indicate that prices are trending strongly upwards. Conversely, increasingly low
values of CMO may indicate that prices are trending strongly downwards.
Recommended Parameters
Vector: CLOSE
Periods: 14
Example
FIND STOCKS WHERE CMO(CLOSE, 14) > 48
Finds stocks where the CMO of the close is overbought.
Volume Oscillator
VolumeOscillator(Short Term Periods, Long Term Periods, MA Type, Points or Percent)
VO(Short Term Periods, Long Term Periods, MA Type, Points or Percent)
Overview
The Volume Oscillator shows a spread of two different moving averages of volume over a specified period of time.
Interpretation
Offers a clear view of whether or not volume is increasing or decreasing.
Recommended Parameters
Short Term Periods: 9
Long Term Periods: 21
MA Type: SIMPLE
Points or Percent: PERCENT
Example
FIND STOCKS WHERE VO(9, 21, SIMPLE, PERCENT) > 0
Price Oscillator
PriceOscillator(Vector, Short Term Periods, Long Term Periods, MA Type)
PO(Vector, Short Term Periods, Long Term Periods, MA Type)
Overview
Similar to the Volume Oscillator, the Price Oscillator is calculated based on a spread of two moving averages.
Interpretation
The Price Oscillator is basically a moving average spread. Buying usually occurs when the oscillator rises, and selling
usually occurs when the oscillator falls.
Recommended Parameters
Vector: CLOSE
Short Term Periods: 9
Long Term Periods: 14
MA Type: SIMPLE
Example
FIND STOCKS WHERE PO(CLOSE, 9, 14, SIMPLE) > 0
Finds stocks where the Price Oscillator is in positive territory.
Prime Number Oscillator
PrimeNumberOscillator(Vector)
PNO(Vector)
Overview
Finds the nearest prime number from either the top or bottom of the series, and plots the difference between that prime
number and the series itself.
Interpretation
This indicator can be used to spot market turning points. When the oscillator remains at the same high point for two
consecutive periods in the positive range, consider selling. Conversely, when the oscillator remains at a low point for two
consecutive periods in the negative range, consider buying.
Recommended Parameters
Vector: CLOSE
Example
FIND STOCKS WHERE PNO(CLOSE) = REF(PNO(CLOSE), 1)
AND REF(PNO(CLOSE), 2) != PNO(CLOSE)
Rainbow Oscillator
RainbowOscillator(Vector, Levels, MA Type)
RBO(Vector, Levels, MA Type)
Overview
The rainbow oscillator is calculated based upon multiple time frames of a moving average.
Interpretation
The trend may reverse suddenly when values stay above 0.80 or below 0.20 for two consecutive days.
Recommended Parameters
Vector: CLOSE
Levels: 3
MA Type: SIMPLE
Example
SET R = RBO(CLOSE, 3, SIMPLE)
FIND STOCKS WHERE R > 0.8 AND REF(R, 1) > 0.8
Finds stocks where the Rainbow Oscillator has been above 0.8 for at least two consecutive days.
TRIX
TRIX(Vector, Periods)
Overview
TRIX is a momentum oscillator that shows the rate of change of an exponentially averaged closing price.
Interpretation
The most common usage of the TRIX oscillator is to buy when the oscillator rises and sell when the oscillator falls.
Recommended Parameters
Vector: CLOSE
Periods: 9
Example
FIND STOCKS WHERE TRIX(CLOSE, 9) > 0.9
Finds stocks where TRIX is in overbought territory.
Vertical Horizontal Filter
VerticalHorizontalFilter(Vector, Periods)
VHF(Vector, Periods)
Overview
The Vertical Horizontal Filter (VHF) identifies whether a market is in a trending or a choppy movement phase.
Interpretation
The VHF indicator is most commonly used as an indicator of market volatility. It is also frequently used as a component to
other technical indicators.
Recommended Parameters
Vector: CLOSE
Periods: 21
Example
FIND STOCKS WHERE VHF(CLOSE, 21) < 0.2
Wilder's Directional Movement System
ADX(Periods), ADXR(Periods), DIP(Periods), DIN(Periods), TRSUM(Periods), DX(Periods)
Overview
The Welles Wilder's Directional Movement System contains five indicators; ADX, DI+, DI-, DX, and ADXR.
The ADX (Average Directional Movement Index) is an indicator of how much the market is trending, either up or down: the
higher the ADX line, the more the market is trending and the more suitable it becomes for a trend-following system. This
indicator consists of two lines: DI+ and DI-, the first one being a measure of uptrend and the second one a measure of
downtrend.
Detailed information about this indicator and formulas can be found in Welles Wilder's book, "New Concepts in Technical
Trading Systems". The standard Directional Movement System draws a 14 period DI+ and a 14 period DI- in the same chart panel.
ADX is also sometimes shown in the same chart panel.
Interpretation
A buy signal is given when DI+ crosses over DI-, a sell signal is given when DI- crosses over DI+.
Recommended Parameters
Periods: 21
Example
FIND STOCKS WHERE DIP(14) > 60
Chaikin Volatility
ChaikinVolatility(Periods, Rate of Change, MA Type)
CV(Periods, Rate of Change, MA Type)
Overview
The Chaikin Volatility Oscillator is a moving average derivative of the Accumulation / Distribution index. This indicator
quantifies volatility as a widening of the range between the high and the low price.
Interpretation
The Chaikin Volatility Oscillator adjusts with respect to volatility, independent of long-term price action. The most popular
interpretation is to sell when the indicator tops out, and to buy when the indicator bottoms out.
Recommended Parameters
Periods: 10
Rate of Change: 10
MA Type: SIMPLE
Example
FIND STOCKS WHERE CV(10, 10, SIMPLE) < -25
Moving Average Convergence / Divergence (MACD)
MACD(Short Cycle, Long Cycle, Signal Periods, MA Type)
MACDSignal(Short Cycle, Long Cycle, Signal Periods, MA Type)
Overview
The MACD is a moving average oscillator that shows potential overbought/oversold phases of market fluctuation. The MACD is a
calculation of two moving averages of the underlying price/indicator.
Interpretation
Buy and sell interpretations may be derived from crossovers (calculated by the MACDSignal function), overbought / oversold
levels of the MACD and divergences between MACD and underlying price.
Recommended Parameters
Long Cycle: 26
Short Cycle: 13
Signal Periods: 9
MA Type: SIMPLE
Example
SET A = MACDSignal(13, 26, 9, SIMPLE)
SET B = MACD(13, 26, 9, SIMPLE)
FIND STOCKS WHERE CROSSOVER(A, B) = TRUE
Finds stocks where the MACD Signal line recently crossed over the MACD.
Stochastic Oscillator
SOPK(%K Periods, %K Slowing Periods, %D Periods, MA Type)
SOPD(%K Periods, %K Slowing Periods, %D Periods, MA Type)
Overview
The Stochastic Oscillator is a popular indicator that shows where a security's price has closed in proportion to its closing
price range over a specified period of time.
Interpretation
The Stochastic Oscillator has two components: %K (the SOPK function) and %D (the SOPD function). %K is most often displayed
on a stock chart as a solid line and %D is often shown as a dotted line. The most widely used method for interpreting the
Stochastic Oscillator is to buy when either component rises above 80 or sell when either component falls below 20. Another
way to interpret the Stochastic Oscillator is to buy when %K rises above %D, and conversely, sell when %K falls below %D.
Recommended Parameters
% K Periods: 9
% K Slowing Periods: 3
% D Periods: 9
MA Type: SIMPLE
Example
FIND STOCKS WHERE SOPK(9, 3, 9, SIMPLE) > 80 OR SOPD(9, 3, 9, SIMPLE) > 80
Finds stocks where the Stochastic Oscillator is in oversold territory.
Relative Strength Index
RelativeStrengthIndex(Vector, Periods)
RSI(Vector, Periods)
Overview
The RSI is popular indicator developed by trader Welles Wilder. The RSI is a popular indicator that shows comparative price
strength within a single security.
Interpretation
The most widely used method for interpreting the RSI is price / RSI divergence, support / resistance levels and RSI chart
formations.
Recommended Parameters
Vector: CLOSE
Periods: 14
Example
FIND STOCKS WHERE RSI(CLOSE, 14) > 55
Historical Volatility Index
HistoricalVolatilityIndex(Vector, Periods, Bar History, Standard Deviations)
HVI(Vector, Periods, Bar History, Standard Deviations)
Overview
Historical volatility is the log-normal standard deviation. The Historical Volatility Index is based on the book by Don
Fishback, "Odds: The Key to 90% Winners".
The formula for a 30-day historical volatility index between 1 and 0 is:
Stdev(Log(Close / Close Yesterday), 30) * Sqrt(365)
Some traders use 252 instead of 365 for the bar history that is used by the square root function. The Log value is a natural
log (i.e. Log10).
Interpretation
High values of HVI indicate that the stock is volatile, while low values of HVI indicate that the stock is either flat or
trending steadily.
Recommended Parameters
Vector: CLOSE
Periods: 15
Bar History: 30
Standard Deviations: 2
Example
FIND STOCKS WHERE HVI(CLOSE, 15, 30, 2) < 0.01
Chaikin Money Flow Index
ChaikinMoneyFlow (Periods)
CMF (Periods)
Overview
The Chaikin Money Flow oscillator is a momentum indicator that spots buying and selling by calculating price and volume
together. This indicator is based upon Accumulation / Distribution, which is in turn based upon the premise that if a stock
closes above its midpoint, (high + low) / 2, for the day then there was accumulation that day, and if it closes below its
midpoint, then there was distribution that day.
Interpretation
A buy signal is generated when the indicator is rising and is in positive territory.
A sell signal is generated when the indicator is falling and is in negative territory.
Recommended Parameters
Periods: 15
Example
FIND STOCKS WHERE CMF(15) > 20 AND REF(CMF(15), 1) > 20
Finds stocks where the Chaikin Money Flow Index is bullish.
Price Volume Trend
PriceVolumeTrend(Vector)
PVT(Vector)
Overview
Also known as Volume Price Trend. This indicator consists of a cumulative volume that adds or subtracts a multiple of the
percentage change in price trend and current volume, depending upon their upward or downward movements. PVT is used to
determine the balance between a stock's demand and supply.
This indicator shares similarities with the On Balance Volume index.
Interpretation
The Price and Volume Trend index generally precedes actual price movements. The premise is that well-informed investors are
buying when the index rises and uninformed investors are buying when the index falls.
Recommended Parameters
Vector: CLOSE
Example
FIND STOCKS WHERE TREND(PVT(CLOSE)) = UP
Finds stocks where PVT is trending upwards.
Finds stocks where PVI is trending upwards.
Negative Volume Index
NegativeVolumeIndex(Vector)
NVI(Vector)
Overview
The Negative Volume Index is similar to the Positive Volume Index, except it puts focus on periods when volume decreases from
the previous period.
Interpretation
The interpretation of the Negative Volume Index is that well-informed investors are buying when the index falls and
uninformed investors are buying when the index rises.
Recommended Parameters
Vector: CLOSE
Example
FIND STOCKS WHERE TREND(NVI(CLOSE)) = UP
Finds stocks where NVI is trending upwards.
Performance Index
PerformanceIndex(Vector)
PFI(Vector)
Overview
The Performance indicator calculates price performance as a normalized value or percentage.
Interpretation
A Performance indicator shows the price of a security as a normalized value. If the Performance indicator shows 50, then the
price of the underlying security has increased 50% since the start of the Performance indicator calculations. Conversely, if
the indictor shows -50, then the price of the underlying security has decreased 50% since the start of the Performance
indicator calculations.
Recommended Parameters
Vector: CLOSE
Example
FIND STOCKS WHERE PFI(CLOSE) > 45
Finds stocks where the performance index is over 45%
Swing Index
SwingIndex(Limit Move Value)
SI(Limit Move Value)
Overview
The Swing Index (Wilder) is a popular indicator that shows comparative price strength within a single security by comparing
the current open, high, low, and close prices with previous prices.
Interpretation
The Swing Index is a component of the Accumulation Swing Index.
Recommended Parameters
Limit Move Value: 1
Example
FIND STOCKS WHERE SI(1) > 0
Finds stocks where the Swing Index is in positive territory.
Stochastic Momentum Index
SMIK(%K Periods, %K Smooth, %K Double Periods, %D Periods, MA Type, %D MA Type)
SMID(%K Periods, %K Smooth, %K Double Periods, %D Periods, MA Type, %D MA Type)
Overview
The Stochastic Momentum Index, developed by William Blau, first appeared in the January 1993 issue of Stocks & Commodities
magazine. This indicator plots the closeness of price relative to the midpoint of the recent high / low range.
Interpretation
The Stochastic Momentum Index has two components: %K (SMIK) and %D (SMID). %K is most often displayed on a chart as a solid
line and %D is often shown as a dotted line. The most widely used method for interpreting the Stochastic Momentum Index is to
buy when either component rises above 40 or sell when either component falls below 40. Another way to interpret the
Stochastic Momentum Index is to buy when %K rises above %D, or sell when %K falls below %D.
Recommended Parameters
%K Periods: 14
%K Smoothing: 2
%K Double Periods: 3
%D Periods: 9
MA Type: SIMPLE
%D MA Type: SIMPLE
Example
FIND STOCKS WHERE SMID(14, 2, 3, 9, SIMPLE, SIMPLE) > 40 OR
SMIK(14, 2, 3, 9, SIMPLE, SIMPLE) > 40
Finds stocks where the Stochastic Momentum Index is in oversold territory.
Median Price
MEDIANPRICE()
MP()
Overview
A Median Price is simply an average of one period's high and low values.
Interpretation
A Median Price is often used as an alternative way of viewing price action and also as a component for calculating other
technical indicators.
Example
FIND STOCKS WHERE CROSSOVER(CLOSE, SMA(MP(), 14))
Finds stocks where the close crossed over the 14-day SMA of the Median Price.
Weighted Close
WeightedClose()
WC()
Overview
Weighted Close is an average of each day's open, high, low, and close, where more weight is placed on the close.
Interpretation
The Weighted Close indicator is a simple method that offers a simplistic view of market prices.
Example
FIND STOCKS WHERE WC() > REF(WC(), 1)
Finds stocks where the weighted close is higher than the previous value.
Volume Rate of Change
VolumeRateOfChange(Vector, Periods)
VROC(Vector, Periods)
Overview
The Volume Rate of Change indicator shows whether or not volume is trending in one direction or another.
Interpretation
Sharp Volume ROC increases may signal price breakouts.
Recommended Parameters
Vector: VOLUME
Periods: 12
Example
FIND STOCKS WHERE VROC(VOLUME, 12) > 0 AND REF(VROC(VOLUME, 12), 1) < 0
Finds stocks where the Volume ROC recently moved into positive territory.
Lowest Low Value
LowestLowValue(Periods)
LLV(Periods)
Overview
Returns the lowest value of the low price over the specified number of periods.
Interpretation
Used as a component for calculation by many other technical indicators.
Recommended Parameters
Periods: 21
Example
FIND STOCKS WHERE LOW = LLV(21)
Finds stocks where the low is the lowest low in the past 21 bars.
Correlation Analysis
CorrelationAnalysis(Vector1, Vector2)
CA(Vector1, Vector2)
Overview
Correlation analysis is used to determine the relationship between two vectors.
Interpretation
The function returns a value indicating the relationship between two Vectors. The Vectors may contain price, indicator
values, or other values.
Recommended Parameters
Vector1: [Any Vector]
Vector2: [Any Vector]
Example
FIND STOCKS WHERE CA(CLOSE, SMA(CLOSE, 14)) > 0.99
Finds stocks where the close price movement highly correlates with the 14-day SMA movement.
Japanese Candlestick Patterns
Just about every trader is familiar with Japanese Candlestick charting, which was popularized by Steve Nison, author of the
book "Japanese Candlestick Charting Techniques". Many traders have been using a form of Japanese candlestick charting for
decades, even before it was named "candlestick charting".
What are Candlesticks?
The main feature of a candlestick is that the area between the open and close price is filled in, with emphasis on the
direction. Typically you will see bars represented as dark candles on days where the price closed lower than the open, or
white candles on days where the price closed higher than the open. The actual high and low prices are called "wicks".
Candlesticks don't involve calculations, rather they simply offer a different perspective for viewing price action. The
interpretation of candlesticks is based primarily on patterns that are formed from period to period. For example, you may
have heard of terms like "Three Black Crows", "Morning Star", or "Dark Cloud Cover". These are all candlestick patterns,
which are formed by two or more candlesticks.
Scanning for Candlestick Patterns
Although you could very well write your own scripts to search for candlestick patterns, ScanScript provides a simple,
built-in function that can identify up to two-dozen predefined patterns:
CandlestickPattern()
CSP()
Overview
The CandlestickPattern() function identifies candlestick patterns automatically.
The function takes no arguments and outputs a constant representing one of the two-dozen candlestick patterns as outlined
below.
Example
FIND STOCKS WHERE CSP() = MORNING_STAR
Finds stocks where the candlestick pattern is a Morning Star.
Patterns
The Candlestick function returns the following constants. Also see chapter 5 of the ScanScript programming guide for visual
representations of these patterns:
LONG_BODY
DOJI
HAMMER
HARAMI
STAR
DOJI_STAR
MORNING_STAR
EVENING_STAR
PIERCING_LINE
ENGULFING_LINE
HANGING_MAN
DARK_CLOUD_COVER
BEARISH_ENGULFING_LINE
BEARISH_DOJI_STAR
BEARISH_SHOOTING_STAR
SPINNING_TOPS
HARAMI_CROSS
BULLISH_TRISTAR
THREE_WHITE_SOLDIERS
THREE_BLACK_CROWS
ABANDONED_BABY
BULLISH_UPSIDE_GAP
BULLISH_HAMMER
BULLISH_KICKING
BEARISH_KICKING
BEARISH_BELT_HOLD
BULLISH_BELT_HOLD
BEARISH_TWO_CROWS
BULLISH_MATCHING_LOW
Sector and Industry Constants
The following sector and industry constants may be used as a filter to limit your scans to a specific sector or industry.
Sector and Industry constants can be set via the SET keyword, e.g.:
SET Sector = Basic Materials
Or:
SET Industry = Personal & Household Products
Sector Constants
Services
Capital Goods
Transportation
Consumer Cyclical
Consumer Non-Cyclical
Healthcare
Services
Basic Materials
Energy
Technology
Services
Technology
Conglomerates
Capital Goods
Financial
Basic Materials
Consumer Non-Cyclical
Basic Materials
Consumer Non-Cyclical
Consumer Cyclical
Basic Materials
Consumer Cyclical
Basic Materials
Healthcare
Services
Financial
Basic Materials
Consumer Cyclical
Healthcare
Basic Materials
Capital Goods
Basic Materials
Financial
Transportation
Capital Goods
Financial
Services
Utilities
Basic Materials
Technology
Consumer Non-Cyclical
Energy
Basic Materials
Consumer Non-Cyclical
Services
Consumer Cyclical
Services
Transportation
Services
Consumer Cyclical
Financial
Services
Financial
Services
Technology
Services
Technology
Consumer Cyclical
Consumer Non-Cyclical
Transportation
Services
Transportation
Utilities
Industry Constants
Advertising
Aerospace & Defense
Air Courier
Airline
Apparel/Accessories
Appliance & Tool
Audio & Video Equipment
Auto & Truck Manufacturers
Auto & Truck Parts
Beverages (Alcoholic)
Beverages (Non-Alcoholic)
Biotechnology & Drugs
Broadcasting & Cable TV
Business Services
Casinos & Gaming
Chemical Manufacturing
Chemicals - Plastics & Rubber
Coal
Communications Equipment
Communications Services
Computer Hardware
Computer Networks
Computer Peripherals
Computer Services
Computer Storage Devices
Conglomerates
Construction & Agricultural Machinery
Construction - Supplies & Fixtures
Construction - Raw Materials
Construction Services
Consumer Financial Services
Containers & Packaging
Crops
Fabricated Plastic & Rubber
Fish/Livestock
Food Processing
Footwear
Forestry & Wood Products
Furniture & Fixtures
Gold & Silver
Healthcare Facilities
Hotels & Motels
Insurance (Accident & Health)
Insurance (Life)
Insurance (Miscellaneous)
Insurance (Prop. & Casualty)
Investment Services
Iron & Steel
Jewelry & Silverware
Major Drugs
Medical Equipment & Supplies
Metal Mining
Misc. Capital Goods
Misc. Fabricated Products
Misc. Financial Services
Misc. Transportation
Mobile Homes & RVs
Money Center Banks
Motion Pictures
Natural Gas Utilities
Non-Metallic Mining
Office Equipment
Office Supplies
Oil & Gas - Integrated
Oil & Gas Operations
Oil Well Services & Equipment
Paper & Paper Products
Personal & Household Products
Personal Services
Photography
Printing & Publishing
Printing Services
Railroads
Real Estate Operations
Recreational Activities
Recreational Products
Regional Banks
Rental & Leasing
Restaurants
Retail (Apparel)
Retail (Catalog & Mail Order)
Retail (Department & Discount)
Retail (Drugs)
Retail (Grocery)
Retail (Home Improvement)
Retail (Specialty)
Retail (Technology)
S&Ls/Savings Banks
Schools
Scientific & Technical Instr.
Security Systems & Services
Semiconductors
Software & Programming
Textiles - Non Apparel
Tires
Tobacco
Trucking
Waste Management Services
Water Transportation
Water Utilities