Systems - Trade The Price Swings

The system detailed below is discussed in the article "Trade The Price Swings" by Barbara Star, Ph. D, in the December 2003 issue of Technical Analysis of Stocks and Commodities Magazine.

This system is based on a linear regression endpoint indicator which is called Linear Regression Forecast (LRF) in Investor/RT. This indicator, when setup with the preferences discussed below, provides the endpoint of a linear regression line, and works similar to a moving average. According to Star's article, "It reduces lag time by turning two bars earlier than a simple moving average, and one bar sooner than an exponentially smoothed moving average of the same length."

The below chart shows the buy (green) and sell (red) signals on a 15-minute chart of the E-mini contract (ES`Z).

swingChart

The chart definition for the chart above: https://www.linnsoft.com/charts/swingchart-es 

The system incorporates the following list of rules:

  • Go long when price crosses above the LRF, followed by a bar in which price closes above the previous high.
  • Exit the long position using a trailing stop.
  • Exit the long position when the short signal below triggers.
  • Sell short when price crosses below the LRF, followed by a bar in which price below the previous low.
  • Exit the short position using a trailing stop.
  • Exit the short position when the long signal above triggers.

This system can be implemented using the following combination of rules/signals in an Investor/RT Trading System:

RULE 1: 1 Minute: If SWING_LONG then BUY 1 at Last price SIGNAL=SWING_LONG: LRF.1 > LRF.2 AND LRF.2 <= LRF.3 AND CL > HI.1

RULE 2: 1 Minute: If SWING_LONG_EXIT then SELL 1 at Last price SIGNAL=SWING_LONG_EXIT: BARSOPEN > 1 AND (SIGNAL = 1 OR POS = 1)

RULE 3: 1 Minute: If SWING_LONG_STOP then SELL 1 at Last price SIGNAL=SWING_LONG_STOP: BARSOPEN > 1 AND CL <= STOP

RULE 4: 1 Minute: If SWING_SET_LONG_TRAIL then NO ACTION SIGNAL=SWING_SET_LONG_TRAIL: IF(POS_STATE = 1) THEN (SET(STOP, CL - V#1))

RULE 5: 1 Minute: If SWING_SHORT then SELL SHORT 1 at Last price SIGNAL=SWING_SHORT: LRF.1 < LRF.2 AND LRF.2 >= LRF.3 AND CL < LO.1

RULE 6: 1 Minute: If SWING_SHORT_EXIT then COVER SHORT 1 at Last price SIGNAL=SWING_SHORT_EXIT: BARSOPEN > 1 AND (SIGNAL = 1 OR POS = 1)

RULE 7: 1 Minute: If SWING_SHORT_STOP then COVER SHORT 1 at Last price SIGNAL=SWING_SHORT_STOP: BARSOPEN > 1 AND CL >= STOP

RULE 8: 1 Minute: If SWING_SET_SHORT_TRAIL then NO ACTION SIGNAL=SWING_SET_SHORT_TRAIL: IF(POS_STATE = 2) THEN (SET(STOP, CL + V#1))

The system above is setup for Optimization on three different parameters. LRF is setup with an MA Period of V#3 and a Regression Period of V#2 in order that both of these may be optimized. Also, the trailing stop is implemented using V#1. The token "POS" represents the Position Indicator and is setup with a result of "Bars from End of Session" to force the closing of positions on the last bar of each session (if a position is open). POS_STATE tells whether the system is currently long (1) or short (2). BARSOPEN tells how many bars a position has been open. STOP is used to maintain a trailing stop, and only moves in the direction of the trade once initially set. "NO ACTION" rules are used to maintain the trailing stops. In Rule 2, SIGNAL refers to the signal "SWING_SHORT", while in Rule 6, SIGNAL refers to the signal "SWING_LONG".

The Trading System and Backtest Setup window for this system, setup as discussed above, can be seen below:

Trading System

swingTsys

Backtest Setup

swingBtest

The following four parameters will be used to optimize the system:

  • Periodicity (from 1 to 15 minutes, step 1)
  • LRF Regression Period, V#2 (from 3 to 12, step 1)
  • LRF MA Period, V#3 (from 1 to 6, step 1)
  • Trailing Stop, V#1 (from 0.50 to 4.0, step 0.25)

The Optimization window, setup to optimize the swing system as discussed above, can be seen below:

swingOpt

The optimized combination of parameters, from a "Net Profit" standpoint, was:

  • Periodicity: 3-minute
  • LRF Regression Period, V#2: 12
  • LRF MA Period, V#3: 1 (no smoothing)
  • Trailing Stop, V#1: 2.25

This combination produced a net profit of $2125 on 47 trades of a single E-mini contract.

To view the complete list of results, click here.