Traders' Tip text
This month, Sylvain Vervoort presents a “master class” on improving well-known indicators using smoothing techniques. A combination of TEMA and WMA does a nice job smoothing out wiggles in a %b oscillator, derived from zero-lag “Rainbow” data series (SVEZLRBPercB). The same Rainbow series, averaged with the typical price, visibly smooth the traditional Stochastic K oscillator.
To illustrate the application of SVEZLRBPercB and the smoothed Stochastic K, we include a demo long-only strategy with just two basic rules: buy when the StochK crosses above from oversold territory, and sell when it leaves overbought zone. As usual, the complexity of code is hidden by including the indicators in our
TASCIndicators library. To run the sample Strategy in Wealth-Lab, you'll need TASCIndicators version 2013.08 or higher. Please install (or update) the library from
our website to its latest version.
Figure 1. A Wealth-Lab 6 chart illustrating the application of smoothed indicators.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using TASCIndicators;
namespace WealthLab.Strategies
{
public class OscillatorsSmoothed : WealthScript
{
protected override void Execute()
{
HideVolume();
ChartPane cp = CreatePane( 40,true,true );
SVERBStochK K = SVERBStochK.Series(Bars,30,3);
SVEZLRBPercB PB = SVEZLRBPercB.Series(Bars,3,18);
PlotSeries( cp, PB, Color.DodgerBlue, LineStyle.Solid, 3 );
PlotSeriesOscillator( cp, K, 80, 20, Color.FromArgb(40, Color.Red),
Color.FromArgb(40, Color.Blue), Color.Red, LineStyle.Solid, 2 );
for(int bar = GetTradingLoopStartBar(18); bar < Bars.Count; bar++)
{
if (IsLastPositionActive) {
if( CrossUnder( bar, K, 80 ) )
SellAtMarket( bar+1, LastPosition );
}
else {
if( CrossOver( bar, K, 20 ) )
BuyAtMarket( bar+1 );
}
}
}
}
}
Eugene
Wealth-Lab team
www.wealth-lab.com