Traders' Tip text
The exponential standard deviation bands (ESD bands) from this month's Traders' Tip follow the same interpretation guidelines as the traditional Bollinger Bands, for example. The difference is in the usage of exponential standard deviation which is believed to make the ESD bands more sensitive to the market action. As to the optimal condition to applying them, author Vitali Apirine suggests a flat trend.
To illustrate their application we've included a simple system that is based on a %b indicator that depicts how the price relates to the bands as well as to what degree it is above or below any of the bands. If the price is equal to the upper band, %b will be 100%, if it's equal to the lower band, %b will be 0.0, and a %b value of 50% (0.5) means the price is in between i.e. equal to the EMA.
Below you can find rules of the system:
Entry:
- Buy at market when ESD Band Width percentage stays below 0.2 (20%) for 3 days in a row
- Open no more than 3 positions
- Exit at market when ESD Band Width percentage indicator >= 0.8 (80%)
Figure 1. A Wealth-Lab 6 chart illustrating the application of the system's rules on a Daily chart of Powershares QQQ Trust ETF (QQQ).''
To execute the example trading system, Wealth-Lab users should install (or update) the latest version of
TASCIndicators library from the Extensions section of our website if they haven't already done so, and restart Wealth-Lab.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Indicators;
using TASCIndicators;
namespace WealthLab.Strategies
{
public class PctB : WealthScript
{
private StrategyParameter esdbPeriod;
private StrategyParameter esdbStdDev;
public PctB()
{
esdbPeriod = CreateParameter("ESD Bands Period", 20, 5, 50, 5);
esdbStdDev = CreateParameter("Std Dev", 2, 1, 5, 0.25);
}
protected override void Execute()
{
var period = esdbPeriod.ValueInt;
var sd = esdbStdDev.Value;
var esdbL = ESDBandLower.Series(Close,period,sd);
var esdbU = ESDBandUpper.Series(Close,period,sd);
DataSeries PctESDBW = ( Close - esdbL ) / ( esdbU - esdbL );
PctESDBW.Description = "% ESDB Width";
DataSeries pctESDBBelow = SeriesIsBelowValue.Series( PctESDBW, 0.2, 3 );
ChartPane xob_pane = CreatePane( 20, true, true );
PlotSeries( xob_pane, pctESDBBelow, Color.DarkRed, WealthLab.LineStyle.Solid, 1 );
ChartPane PctBBWPane = CreatePane( 20, true, true );
PlotSeries( PctBBWPane, PctESDBW, Color.Blue, WealthLab.LineStyle.Solid, 2 );
Color fillColor = Color.FromArgb(16, 0, 0, 255);
PlotSeriesFillBand( PricePane, esdbU, esdbL, Color.Blue, fillColor, LineStyle.Solid, 1);
HideVolume();
for(int bar = PctESDBW.FirstValidValue; bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
{
if( PctESDBW[bar] >= 0.8 )
SellAtMarket( bar+1, LastPosition );
}
else
{
if( bar >= pctESDBBelow[bar]+3 && pctESDBBelow[bar-3] > pctESDBBelow[bar-4] )
{
SetBackgroundColor( bar, Color.FromArgb(231, 255, 231) );
if( BuyAtMarket( bar+1 ) != null )
LastPosition.Priority = -Close[bar];
}
}
}
}
}
}
Eugene
Wealth-Lab team
www.wealth-lab.com