Log in to see Cloud of Tags

Wealth-Lab Wiki

TASC 2012-11 | Identify the Start of a New Trend with DMI (Low)

RSS

Traders' Tip text

This month’s trading idea is based on tracking market exhaustion patterns and acting when they reverse in the opposite direction. The idea of using a cluster of indicators with multiple periods may not be breakthrough per se: for example, it's working in systems which utilize multiple moving averages (MMAs) - like "Rainbow Charts" or “Guppy MMA” by Daryl Guppy.

A common trait that MMAs share with TAC-DMI clusters is that when indicators within a group are moving close together, the group is largely in agreement. One of the differences made by author BC Low is that new trend starts when signaled by TAC-DMI clusters converging at an extreme and then reversing as a group. On the contrary, multiple moving averages tend to expand as a group, following a change in price direction.

As the Strategy code below illustrates, the convergence pattern of triple ADX, DI+ or DI- can be formalized pretty easily in WealthScript. Our “Convergence” routine with configurable thresholds highlights each of the four events on a chart triggered by combining the triple DI+/DI- and ADX clusters: possible start of uptrends and downtrends, topping, and bottoming out. Motivated traders can reuse the code, possibly enhancing their own systems with timely setups aimed at identification of the start of a trending move and top/bottom-picking.

Image

''Figure 1. Weekly chart of PFE (Pfizer) illustrating the application of the TAC-DMI approach.

WealthScript Code (C#)


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

namespace WealthLab.Strategies { public class TAC_DMI_Strategy : WealthScript { #region Convergence functions double Average(List<double> lst) { double total = 0.0; double average = 0.0; int period = lst.Count; if( period > 0 ) { for (int x = 0; x < period; x++) total += lst[x]; average = total / period; } return average; } bool Convergence(List<double> lst, double scatter, double threshold, bool greater) { bool result = false; if( lst.Count > 0 ) { lst.Sort(); double first = lst[0]; double last = lst[lst.Count-1]; double average = Average(lst); double diff = last - first; double pct = diff / average * 100; if( !double.IsInfinity(average)) { if( greater ) result = ( (first >= threshold && last >= threshold) && pct <= scatter ); else result = ( (first <= threshold && last <= threshold) && pct <= scatter ); } } return result; } #endregion private StrategyParameter paramADXThDn; private StrategyParameter paramADXThUp; public TAC_DMI_Strategy() { paramADXThDn = CreateParameter("ADX Up.Th.", 70, 70, 90, 10); paramADXThUp = CreateParameter("ATR Lo.Th.", 30, 10, 30, 10); } protected override void Execute() { #region DataSeries ADX adx4 = ADX.Series(Bars,4); ADX adx5 = ADX.Series(Bars,5); ADX adx6 = ADX.Series(Bars,6); DIPlus dip5 = DIPlus.Series(Bars,5); DIPlus dip8 = DIPlus.Series(Bars,8); DIPlus dip14 = DIPlus.Series(Bars,14); DIMinus dim5 = DIMinus.Series(Bars,5); DIMinus dim8 = DIMinus.Series(Bars,8); DIMinus dim14 = DIMinus.Series(Bars,14); LineStyle ls = LineStyle.Solid; #endregion

#region Plotting ChartPane adxPane = CreatePane(35,true,true); PlotSeries(adxPane,adx4,Color.Purple,ls,1); PlotSeries(adxPane,adx5,Color.Green,ls,1); PlotSeries(adxPane,adx6,Color.Violet,ls,1); DrawHorzLine(adxPane,30,Color.Blue,LineStyle.Dashed,1); DrawHorzLine(adxPane,70,Color.Red,LineStyle.Dashed,1); ChartPane dipPane = CreatePane(35,true,true); PlotSeries(dipPane,dip5,Color.Purple,ls,1); PlotSeries(dipPane,dip8,Color.Green,ls,1); PlotSeries(dipPane,dip14,Color.Violet,ls,1); DrawHorzLine(dipPane,50,Color.Red,LineStyle.Dashed,1); DrawHorzLine(dipPane,10,Color.Black,LineStyle.Dashed,1); DrawHorzLine(dipPane,50,Color.Black,LineStyle.Dashed,1); ChartPane dimPane = CreatePane(35,true,true); PlotSeries(dimPane,dim5,Color.Purple,ls,1); PlotSeries(dimPane,dim8,Color.Green,ls,1); PlotSeries(dimPane,dim14,Color.Violet,ls,1); DrawHorzLine(dimPane,50,Color.Red,LineStyle.Dashed,1); DrawHorzLine(dimPane,10,Color.Black,LineStyle.Dashed,1); DrawHorzLine(dimPane,50,Color.Black,LineStyle.Dashed,1); HideVolume(); Font font = new Font("Arial", 12, FontStyle.Bold); #endregion Plotting for(int bar = GetTradingLoopStartBar(14 * 3); bar < Bars.Count; bar++) { List<double> lstADX = new List<double>() { adx4[bar-1],adx5[bar-1],adx6[bar-1] }; List<double> lstDIP = new List<double>() { dip5[bar-1],dip8[bar-1],dip14[bar-1] }; List<double> lstDIM = new List<double>() { dim5[bar-1],dim8[bar-1],dim14[bar-1] }; bool adxConvergingUp = Convergence( lstADX, 10, paramADXThUp.ValueInt, false ); bool adxConvergingDown = Convergence( lstADX, 10, paramADXThDn.ValueInt, true ); bool adxTurnup = TurnUp(bar, adx4) && TurnUp(bar, adx5) && TurnUp(bar, adx6); bool adxTurndown = TurnDown(bar, adx4) && TurnDown(bar, adx5) && TurnDown(bar, adx6); bool dipTurnup = TurnUp(bar, dip5) && TurnUp(bar, dip8) && TurnUp(bar, dip14); bool dimTurnup = TurnUp(bar, dim5) && TurnUp(bar, dim8) && TurnUp(bar, dim14); // Signal 1: start of an uptrend if( adxConvergingUp && adxTurnup ) { SetBackgroundColor( bar, Color.FromArgb( 20, Color.Green ) ); AnnotateBar( "Possible uptrend start", bar, true, Color.Green, Color.Transparent, font ); //BuyAtMarket(bar + 1, "Signal-1-Long"); } // Signal 2: start of an uptrend if( adxConvergingDown && adxTurndown ) { SetBackgroundColor( bar, Color.FromArgb( 20, Color.Red ) ); AnnotateBar( "Possible downtrend start", bar, true, Color.Red, Color.Transparent, font ); //ShortAtMarket(bar + 1, "Signal-2-Short"); } // Signal 3: market bottom (DI+/ADX cluster reversal) if( adxConvergingDown && Average(lstDIP) <= 10 && dipTurnup ) { SetBackgroundColor( bar, Color.FromArgb( 40, Color.Green ) ); AnnotateBar( "Possible bottom", bar, true, Color.Green, Color.Transparent, font ); //BuyAtMarket(bar + 1, "Signal-3-Long"); } // Signal 4: market top (DI-/ADX cluster reversal) if( adxConvergingDown && Average(lstDIM) <= 10 && dimTurnup ) { SetBackgroundColor( bar, Color.FromArgb( 40, Color.Red ) ); AnnotateBar( "Possible top", bar, true, Color.Red, Color.Transparent, font ); //ShortAtMarket(bar + 1, "Signal-4-Short"); } } } } }

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.