TASC 2016-01 | Simplify It (Rich, Rich)

Modified on 2015/11/30 13:54 by Eugene — Categorized as: TASC Traders Tips

Traders' Tip text

This WealthScript Strategy combines trend detection ideas outlined in the article "Simplify It" from November 2015 issue of Stocks & Commodities. Users have the means to experiment which method of determining overall market direction works better: the one that relies on the external symbol's (SPY) movement by John Rich, or the one that uses a combination of multiple moving averages (James Rich). The system's C# code for Wealth-Lab can be found below.

Image

Figure 1 illustrates the application of the system's rules on the Daily chart of HUM.

The method of screening for entries is so simple that it doesn't require programming. For every Wealth-Lab user, it should be pretty trivial to drag and drop the conditions in a Rule-based system.

Image

Figure 2 helps to build the system using drag & drop rules and conditions

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

namespace WealthLab.Strategies { public class SimplifyIt : WealthScript { private StrategyParameter paramTrendRule;

public SimplifyIt() { paramTrendRule = CreateParameter("SPY for trend", 1, 0, 1, 1); } protected override void Execute() { bool useSpyForTrend = paramTrendRule.ValueInt == 1; Bars spy = GetExternalSymbol("SPY",true); SMA spySma = SMA.Series(spy.Close,50); SMA sma20 = SMA.Series(Close,20); SMA sma50 = SMA.Series(Close,50); SMA sma200 = SMA.Series(Close,200); SMA smaHi = SMA.Series(High,8); SMA smaLo = SMA.Series(Low,8); //PlotSeries(PricePane,sma20,Color.Orange,WealthLab.LineStyle.Solid,1); PlotSeries(PricePane,sma50,Color.Red,WealthLab.LineStyle.Solid,1); //PlotSeries(PricePane,sma200,Color.Blue,WealthLab.LineStyle.Solid,1); PlotSeriesFillBand(PricePane, smaHi, smaLo, Color.Green, Color.Transparent, LineStyle.Solid, 1);

if( useSpyForTrend ) { ChartPane spyPane = CreatePane(30,true,true); PlotSymbol(spyPane,spy,Color.Blue,Color.Red); PlotSeries(spyPane,spySma,Color.Blue,WealthLab.LineStyle.Solid,1); } for(int bar = GetTradingLoopStartBar(200); bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if( p.PositionType == PositionType.Long ) { if( Closebar < smaLobar - Bars.SymbolInfo.Tick ) SellAtMarket(bar+1, p ); } else { if( Closebar > smaHibar + Bars.SymbolInfo.Tick ) CoverAtMarket(bar+1, p ); } } else { bool uptrend = // John's / James' method ( useSpyForTrend && (spy.Closebar > spySmabar && spySmabar > spySmabar-1 && Closebar > sma50bar)) || ( sma20bar > sma50bar&& sma50bar > sma200bar); bool downtrend = // John's / James' method ( useSpyForTrend && (spy.Closebar < spySmabar && spySmabar < spySmabar-1 && Closebar < sma50bar)) || ( sma20bar < sma50bar && sma50bar < sma200bar); if( uptrend ) // market trend is up { if( SMA.Series(Volume,50)bar > 1000000 ) // the volume criterion if( Closebar > smaHibar ) // the second step BuyAtMarket(bar + 1); } else if( downtrend ) // market trend is down { if( SMA.Series(Volume,50)bar > 1000000 ) // the volume criterion if( Closebar < smaLobar ) // the second step ShortAtMarket(bar + 1); } } } } } }


Eugene
Wealth-Lab team
www.wealth-lab.com