Traders' Tip text
Mr. Ehlers continues to please the readers with more nearly-zero lag filters - this time it's
Super Passband oscillator from July 2016 issue of Stocks & Commodities.
Following the trading idea in the article, we are including a simple WealthScript system that can be applied selectively (only long side or both sides):
- Buy on the filter crossing above its -RMS line
- Short on the filter crossing below its RMS line
- Exit long when the filter either crosses below its RMS or crosses below -RMS (which signifies a false entry signal)
- Cover short when the filter either crosses above its -RMS or crosses above RMS (which signifies a false entry signal)
Figure 1:
A Wealth-Lab 6 chart illustrating entries made by the enclosed system based on the SuperPassband filter.
Our tests suggest that the new nearly-zero lag filter looks promising for counter-trend trades and for buying significant dips (see Figure 1). To execute the included trading system, Wealth-Lab users need to install (or update) the latest version of the
TASCIndicators library from the Extensions section of our website if they haven't already done so, and restart Wealth-Lab.
Strategy:using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using TASCIndicators;
namespace WealthLab.Strategies
{
public class TASC201607 : WealthScript
{
private StrategyParameter paramPeriod1;
private StrategyParameter paramPeriod2;
private StrategyParameter paramGoShort;
public TASC201607()
{
paramPeriod1 = CreateParameter("Period1", 40, 10, 100, 10);
paramPeriod2 = CreateParameter("Period2", 60, 20, 300, 10);
paramGoShort = CreateParameter("Go short?", 0, 0, 1, 1);
}
protected override void Execute()
{
int Period1 = paramPeriod1.ValueInt;
int Period2 = paramPeriod2.ValueInt;
bool goShort = paramGoShort.ValueInt == 1 ? true : false;
var spb = SuperPassband.Series(Close,40,60);
var rms = SuperPassbandRMS.Series(Close,40,60);
var mrms = rms*-1;
var pbPane = CreatePane(30,true,true);
PlotSeries(pbPane,spb,Color.Red,WealthLab.LineStyle.Solid,1);
DrawHorzLine(pbPane,0,Color.Blue,WealthLab.LineStyle.Solid,1);
PlotSeriesFillBand(pbPane,rms,mrms,Color.Yellow,Color.Transparent,WealthLab.LineStyle.Solid,1);
for(int bar = Math.Max(Period1,Period2); bar < Bars.Count; bar++)
{
SetBackgroundColor(bar,Color.Black);
if (IsLastPositionActive)
{
Position p = LastPosition;
if( p.PositionType == PositionType.Long )
{
if( CrossUnder(bar, spb, rms) || CrossUnder(bar, spb, mrms) )
SellAtMarket(bar+1, p);
}
else
{
if( CrossOver(bar, spb, mrms) || CrossOver(bar, spb, rms))
CoverAtMarket(bar+1, p);
}
}
else
{
if( CrossOver(bar, spb, mrms))
BuyAtMarket(bar+1);
else
if( CrossUnder(bar, spb, rms) && goShort )
ShortAtMarket(bar+1);
}
}
}
}
}
Eugene
Wealth-Lab team
www.wealth-lab.com