take a tour of stockworm
Overview
Quotes
Valuation
Charts
Technical indicators
Trading signals
Point and figure charting
Fundamental analysis
Rule sets
Stock screeners  (see our flash screener movie)
Portfolio management
Autoinvestor strategies
Data coverage
About us

Technical trading signals

Technical trading signals are the end goal of any technical analysis-based trading system. These signals tell the user when to buy or sell a stock. In other words, technical trading signals are used to time the buying and selling of stocks. Other tools, such as stock screeners can be used to determine which stocks should be candidates for market timing analysis.

Trading signals appear as green (buy) or red (sell) arrows on the charts:

Trading signals become even more powerful when used with stock screeners to scour the market for the best technical picks or when used in conjunction with strategies to time portfolio purchases.

Creation of trading signals

Stockworm conceptually divides trading signals into long (buy) and short (sell) formulas. Each formula is written in a simple but powerful scripting language. A buy signal is issued when the buy formula is true and the short formula is false. A sell signal is issued when the sell formula is true and the buy formula is false.

You can specify only the long formula (the short formula will be true when the long formula is false) only the short formula (the long formula will be true when the short formula is false) or both (the formulas will be evaluated independently).

Formulas are composed of one or more technical indicator lines. Functions can be applied to modify the value of the indicator lines (e.g. the EMA function takes the exponential moving average of a line, given an averaging period: EMA(LINE, PERIOD)). Operators are the glue which binds the functions/lines together (e.g. "CLOSE > 5" or "CLOSE <= EMA(CLOSE, 10)").

The next two sections describe all of the operators and functions which are available for custom signal creation.

Operators

Operators are formula elements which are subcategorized into arithmetic operators (+, -, *, etc.), logical operators (A > B, A AND B, etc.), and the shift operator (A[B]). All of the Stockworm formula operators are listed and described below. The list appears in the order in which these expressions will be evaluated, in the absence of parenthesis to explicitly enforce ordering.

Expressions Usage
A OR B 'OR' is a logical operator which evaluates whether at least one of the arguments in the expression 'A OR B' is true. Example: SIGNAL > MACD OR RSI > 0.2 (true if either SIGNAL > MACD or RSI > 0.2).
A AND B 'AND' is a logical operator which evaluates whether or not both arguments in the expression 'A AND B' are true. Example: SIGNAL > MACD AND RSI > 0.2 (true if both SIGNAL > MACD and RSI > 0.2).
A = B
A <> B
Equal to and not equal to are also logical operators. Equal to (=) is true when two expressions are equal (e.g. STOCHASTICS_PERCENT_K = 0.8 is true only if the stochastics %k line is identically equal to 0.8) while not equal to (<>) is true for non-equality.
A < B
A <= B
A > B
A >= B
These logical operators compare the value of two expressions. Less than (<) is true when the first expression is less than the second expression and less than or equal to (<=) is true when the first expression is less than or equal to the second expression. Greater than (>) and greater than or equal to (>=) are evaluated in a similar fashion.
A + B
A - B
The arithmetic operator plus (+) adds the first expression to the second expression. The arithmetic operator minus (-) subtracts the second expression from the first expression. Example: The expression 'PRICE_HIGH - PRICE_LOW' would give the price range over the current period, assuming that PRICE_HIGH was defined as the high price line in the technical indicator list and PRICE_LOW was defined as the low price in the technical indicator list.
A * B
A / B
The arithmetic operator times (*) multiplies the first expression by the second expression while the division arithmetic operator (/) divides the first expression by the second expression. Example: The expression '(PRICE_HIGH - PRICE_LOW)/(PRICE_HIGH[1] - PRICE_LOW[1])' yields the ratio of the current period's price range to the previous period's price range.
- A The arithmetic operator minus (-), when applied to a single argument, gives the negative value of this argument. This operation is equivalent to multiplying the argument by -1.
NOT A The logical operator NOT will convert 'true' values to 'false' and vice versa. Example: The expression 'NOT(PRICE_CLOSE > 5)' will be true when the closing price is not greater than 5 (PRICE_CLOSE <= 5 is an equivalent statement).
A[B] The offset operator ([]) is used to denote past values of a given expression. For example, 'PRICE_CLOSE[5]' refers to the closing price 5 periods ago. PRICE_CLOSE[0], which denotes the closing price 0 periods ago, is equivalent to PRICE_CLOSE.

Functions

Functions are provided to perform potentially complex operations on technical indicator lines. For example, the 'EMA' function will perform an exponential moving average upon a given line with a user supplied averaging period. Functions can operate on complex expressions. For example, the expression 'EMA(PRICE_HIGH - PRICE_LOW, 5)' represents a 5 period exponential moving average of the price range. A complete description of each function is provided below.

Functions Usage
ABS(LINE) Calculates absolute values for given line. Can be useful, for instance, if you are trying to calculate how far two lines are apart from each other without regard to their relative position.
CROSSINGDOWN(LINE, CONSTANT, PERIODS)
CROSSINGDOWN(LINE, LINE, PERIODS)
CROSSINGUP(LINE, CONSTANT, PERIODS)
CROSSINGUP(LINE, LINE, PERIODS)
The crossing set of functions are intended to provide notice of either an indicator line crossing through a constant value (LINE, CONSTANT, PERIODS version) or of two indicator lines crossing each other (LINE, LINE, PERIODS version). Up or Down indicates the direction that the indicator line is going, relative to the constant or to the other line. The number of periods (minimum of 2) provides a span of periods over which to determine both the crossover and the overall trend ('up' or 'down'). Example: The expression 'CROSSINGUP(RSI, 0.3, 5)' will be true when the RSI indicator line crosses through 0.3 and is rising (5 periods are used to evaluate the RSI direction and whether or not a crossover occurred). Example: The expression 'CROSSINGDOWN(MACD, SIGNAL, 2)' will be true when the MACD line crosses below the signal line (a sell signal).
EMA(LINE, PERIODS)
SMA(LINE, PERIODS)
The EMA function computes the exponential moving average of a given line over a user-specified number of periods. The SMA function computes the simple moving average of a given line over a user-specified number of periods. Example: The expression 'EMA(PRICE_CLOSE, 50) > EMA(PRICE_CLOSE, 200)' is true when the 50 period exponential moving average is greater than the 200 period exponential moving average.
FALLING(LINE, PERIODS)
FLAT(LINE, PERIODS)
RISING(LINE, PERIODS)
The FALLING, FLAT, and RISING functions are intended to determine the trend of a given line. As the names imply, the 'FALLING' function is true if a line is falling (decreasing), the 'FLAT' function is true if a line is identically flat (no change in the value of the line over the periods) and the 'RISING' function is true if a line is increasing. The PERIODS argument determines how many periods will be sampled to determine the trend (minimum of 2 periods). A linear fit is applied to the data over the PERIODS data set, and the slope of this line is used to determine the trend. Example: the expression 'RISING(PRICE_CLOSE, 20)' would be true if the predominant trend of the closing price has been rising over the past 20 periods (including the current period).
LINEARFIT(LINE, PERIODS) The LINEARFIT function estimates the value at each point by performing a linear fit of past data and then computing the estimated current data value based upon this fit. For each point, the linear fit is computed by analyzing 'PERIODS' data points up to and including the current date. The estimated line value is assigned to the current period (using the slope/intercept from the linear fit) and then the calculation proceeds for the next data point. The LINEARFIT function is ideally used in conjunction with the STD function to locate channel breakouts.
MAX(LINE, PERIODS)
MIN(LINE, PERIODS)
The MAX and MIN functions yield the maximum or minimum values of the given line over the specified number of periods (inclusive of the current period). Example: the expression 'MIN(PRICE_CLOSE, 5)' would give the minimum value of the closing price for the past 5 periods.
STDDEV(LINE, PERIODS) The STDDEV function computes a 'rolling' standard deviation of the given line. For each point, the standard deviation is computed by analyzing 'PERIODS' data points up to and including the current date. This standard deviation number is assigned to the current period and then the calculation proceeds for the next period.