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 = High0; double LH = HH; double HL = Low0; double LL = HL; bool upSwing = true; swingDir0 = -1; swingLine0 = LL; for(int bar = 1; bar < Bars.Count; bar++) { double hi = Highbar; double lo = Lowbar; 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) { swingLinebar = HL; swingDirbar = -1; } else { swingLinebar = LH; swingDirbar = 0; } /* Plot the line manually to show crossovers and transitions */ if (swingDirbar != swingDirbar-1) { clr = (swingDirbar != 0) ? Color.Fuchsia : Color.Cyan; DrawLine(PricePane, bar - 1, swingLinebar-1, bar, swingLinebar-1, clr, LineStyle.Solid, 2); } else { clr = (swingDirbar != 0) ? Color.Cyan : Color.Fuchsia; DrawLine(PricePane, bar - 1, swingLinebar-1, bar, swingLinebar, clr, LineStyle.Solid, 2); } } /* Basic Trend Following "Clear Method" Strategy */ BuyAtMarket(1); for(int bar = 1; bar < Bars.Count; bar++) { Position p = LastPosition; if (swingDirbar != 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.