Log in to see Cloud of Tags

Wealth-Lab Wiki

TASC 2017-05 | Detecting Swings (D'Errico)

RSS

Traders' Tip text

Detecting swings is a range of popular techniques among traders. While the article by Domenico D'Errico throws light on some more creative approaches to the problem, let's start with the definition of the commonly recognized one. As given in the text (“the previous bar's low is lower than the previous two bars and the current bar's low”), a pivot high/low point is different from the more traditional one which is more like “1-2 consecutive lower lows followed by 1-2 consecutive higher lows”. Further, text and code is not in line with article's own Figure 2: the illustration leans towards the traditional definition.

Compare that to a ZigZag swing chart on author's Figure 1. Yes, that's actually another, "undocumented" 5th way to build a swing chart based on absolute or relative (percentage) movements from an established top or bottom. As can be seen on the illustration, several actual pivot highs and lows in the middle of the "legs" are ignored as price noise by this technique.

Next, author shows that the usage of RSI or BB crossovers can be as multifaceted as to define pivot points. For example, I heard about a research some traders made that went as far as building synthetic price bars (like Renko) based on the RSI crossovers. Like a new Renko brick is drawn each time the close price exceeds a fixed amount, a new bar is created when an event like RSI crossover/crossunder takes place.

While it may sound intriguing at first, a look into the code puts everything back in its place. Let's face it: in its present state, that's just tried and true crossovers and crossunders – and hardly anything else. Off-the-shelf RSI crossovers can be misguiding when detecting price swings. Take a look at author's Figure 2: while it shows the successive swings in a trading range, this is what typically happens in strong, lasting trends. Even a series of correctional movements can take place without affecting the price significantly — yet author's system would repeatedly signal an "RSI Swing High" and sold short an established uptrend. A possible way to alleviate this, for example, might be to ignore successful RSI swings in the same direction.

That's why various adaptive RSI thresholds have been introduced by several technical analysts. A well-known idea of dynamic RSI zones which could be found in David Sepiashvili's "The Self-Adjusting RSI" (TASC Feb 2006 issue) provides a solution to this problem by creating thresholds that change depending on the standard deviation of the RSI. At Wealth-Lab, I designed my own rendition of RSI that uses adaptive lookback period that is built on the frequency of pivot point swings: the Adaptive RSI 2.0. Long story short, if one wishes to build an RSI swing chart, an improvement effort is required.

On a closing note, swing-trading typically implies that positions are closed within days, rarely up to two weeks. While closing out a position after four weeks may be a universal approach to benchmark the performance of several strategies, a more adaptive way might be to exit, for example, as soon as the opposite pivot point is formed. But if I don't stop throwing suggestions right now, I'd write another article as there may be more aspects to cover!

Most all of author's techniques have already been coded in WealthScript long ago and are available for download within Wealth-Lab – or can be built interactively:

  1. Pivot high/low. Install the Community Indicators library to enjoy the range of pivot indicators: "Fractal Up/Down" indicators that identify 5-bar pivot patterns, "Gann Swing Oscillator" that adds flexibility to the swing detection formula, "Pivot Point Bar", and finally, a sophisticated framework for defining swings called "Swing Functions".
  2. and #3:
  3. Any Wealth-Lab user can backtest RSI or Bollinger Bands crossovers without having to code. A crossover of any suitable indicator can be easily added to interactive Rule-based Strategies created from the building blocks called Conditions.
  4. Same here, “RSI + Higher Low/Lower High” can be easily built in a drag and drop manner as illustrated on Figure 1:

Image

Figure 1 teaches how to build “RSI + Higher Low/Lower High” in a Rule-based Strategy.

If you're interested in evaluating the performance of swings as Domenico D'Errico defines them, give the code below a try:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { for(int bar = GetTradingLoopStartBar(2); bar < Bars.Count; bar++) { bool PivotLow = (Low[bar-1] < Low[bar-2]) && (Low[bar-1] < Low[bar]); bool PivotHigh = (High[bar-1] > High[bar-2]) && (High[bar-1] > High[bar]); if (IsLastPositionActive) { Position p = LastPosition; if (bar+1 - p.EntryBar >= 20) ExitAtMarket( bar+1, p, "After 4 weeks" ); } else { if (PivotLow) BuyAtMarket(bar+1); else if (PivotHigh) ShortAtMarket(bar+1); } } } } }

Image

Figure 2 shows some long and short trades taken by“Pivot High/Low” approach.

Eugene (Gene Geren)
Wealth-Lab team
www.wealth-lab.com

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.