Log in to see Cloud of Tags

Wealth-Lab Wiki

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

RSS

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( Close[bar] < smaLo[bar] - Bars.SymbolInfo.Tick ) SellAtMarket(bar+1, p ); } else { if( Close[bar] > smaHi[bar] + Bars.SymbolInfo.Tick ) CoverAtMarket(bar+1, p ); } } else { bool uptrend = // John's / James' method ( useSpyForTrend && (spy.Close[bar] > spySma[bar] && spySma[bar] > spySma[bar-1] && Close[bar] > sma50[bar])) || ( sma20[bar] > sma50[bar]&& sma50[bar] > sma200[bar]); bool downtrend = // John's / James' method ( useSpyForTrend && (spy.Close[bar] < spySma[bar] && spySma[bar] < spySma[bar-1] && Close[bar] < sma50[bar])) || ( sma20[bar] < sma50[bar] && sma50[bar] < sma200[bar]); if( uptrend ) // market trend is up { if( SMA.Series(Volume,50)[bar] > 1000000 ) // the volume criterion if( Close[bar] > smaHi[bar] ) // the second step BuyAtMarket(bar + 1); } else if( downtrend ) // market trend is down { if( SMA.Series(Volume,50)[bar] > 1000000 ) // the volume criterion if( Close[bar] < smaLo[bar] ) // the second step ShortAtMarket(bar + 1); } } } } } }

Eugene
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.