Log in to see Cloud of Tags

Wealth-Lab Wiki

TASC 2010-09 | Clear Method (Black)

RSS

Traders' Tip text

The accompanying WealthScript C# code demonstrates how to generate the “Clear Method” Swing Line and plot. We elected to plot manually using DrawLine instead of using the PlotSeries statements in order to show the transitions like in the article’s plots. While the author wasn’t necessarily advocating the method as a stand-alone trading strategy, we added a stop and reverse strategy based on “Clear” as a matter of interest. In a 5-year raw profit backtest using daily bars, only 5 of the Dow 30 symbols returned a profit (excluding commissions). An idea for another test would be to take “Clear” trades in lower timeframes but only in the direction of the larger trend.


Image

Figure 1. “Clear” is certain to get you quickly into new trends, but you’ll have to live through the whipsaws along the way as with other trend-following strategies.


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 ClearMethod : WealthScript { protected override void Execute() { Color clr = Color.Cyan; DataSeries swingLine = new DataSeries(Bars, "Clear Series"); DataSeries swingDir = new DataSeries(Bars, "Swing Direction"); // init to swing is up, lowest high double HH = High[0]; double LH = HH; double HL = Low[0]; double LL = HL; bool upSwing = true; swingDir[0] = -1; swingLine[0] = LL; for(int bar = 1; bar < Bars.Count; bar++) { double hi = High[bar]; double lo = Low[bar]; if (upSwing) { // if (hi > HH) HH = hi; // inconsequential if (lo > HL) HL = lo; if (hi < HL) { upSwing = false; //LL = lo; LH = hi; } } else { // if (lo < LL) LL = lo; //inconsequential if (hi < LH) LH = hi; if (lo > LH) { upSwing = true; // HH = hi; HL = lo; } } if (upSwing) { swingLine[bar] = HL; swingDir[bar] = -1; } else { swingLine[bar] = LH; swingDir[bar] = 0; } /* Plot the line manually to show crossovers and transitions */ if (swingDir[bar] != swingDir[bar-1]) { clr = (swingDir[bar] != 0) ? Color.Fuchsia : Color.Cyan; DrawLine(PricePane, bar - 1, swingLine[bar-1], bar, swingLine[bar-1], clr, LineStyle.Solid, 2); } else { clr = (swingDir[bar] != 0) ? Color.Cyan : Color.Fuchsia; DrawLine(PricePane, bar - 1, swingLine[bar-1], bar, swingLine[bar], clr, LineStyle.Solid, 2); } } /* Basic Trend Following "Clear Method" Strategy */ BuyAtMarket(1); for(int bar = 1; bar < Bars.Count; bar++) { Position p = LastPosition; if (swingDir[bar] != 0) // trend up { if (IsLastPositionActive && p.PositionType == PositionType.Short) { CoverAtMarket(bar + 1, p); BuyAtMarket(bar + 1); } } else { if (IsLastPositionActive && p.PositionType == PositionType.Long) { SellAtMarket(bar + 1, p); ShortAtMarket(bar + 1); } } } } } }

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.