Traders' Tip text
The trading system from this month's article by Pawel Kosinski features an approach that combines multiple unrelated techniques to make an entry - trading the bands based on a sound statistical theory with the candlestick pattern recognition. It's believed that when several signals are in line, confirming each other, the strategy has a better chance.
Figure 1. Sample trade on the chart of VZ (Verizon). Data provided by Yahoo Finance.
The trading system could be assembled in Wealth-Lab in a drag and drop fashion from the building blocks known as Rules. On Figure 2 we show a way to achieve better flexibility through “Multi Condition Group” feature. In essence it triggers the entry signal when the Engulfing and one of Bollinger Band conditions occurred not on the same day exactly but close enough to each other i.e. within a few days.
Figure 2. All conditions required to assemble the trading system are in place.
For those of you who like to have a more finer control we publish the translated code below. It’s downloadable in Wealth-Lab (hit Ctrl-O and choose "Download..."):
WealthScript Code (C#)
Since it has some prerequisites, it’s preferred that you simply download this code in Wealth-Lab (hit Ctrl-O and choose "Download...") rather than copy/paste it:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
namespace WealthLab.Strategies
{
public class TradersTipsOct2019 : WealthScript
{
private StrategyParameter paramPeriod;
private StrategyParameter paramDev;
public TradersTipsOct2019()
{
paramPeriod = CreateParameter("Bands Period", 20, 5, 50, 5);
paramDev = CreateParameter("Bands Dev.", 2.0, 0.5, 5.0, 0.5);
}
protected override void Execute()
{
int period = paramPeriod.ValueInt;
var bbU = BBandUpper.Series(High,period, paramDev.Value);
var bbL = BBandLower.Series(Low, period, paramDev.Value);
PlotSeriesFillBand(PricePane, bbU, bbL, Color.Silver, Color.FromArgb(10,Color.Green), LineStyle.Solid, 1);
for(int bar = GetTradingLoopStartBar(period); bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
{
if(Highbar > bbUbar)
ExitAtMarket(bar+1,LastPosition);
}
else
{
//touches the lower band
if(
(Closebar-1 > bbLbar-1) && ((Lowbar-1 < bbLbar-1) || (Lowbar-2 < bbLbar-2))
//engulfing:
&& (Closebar-2 < Openbar-2) && (Closebar-1 > Openbar-1) &&
(Openbar-1 < Closebar-2) && (Closebar-1 > Openbar-2) &&
((Closebar-1 - Openbar-1) > 20*Bars.SymbolInfo.Tick) &&
(Closebar > Highbar-1 )
)
BuyAtMarket(bar+1);
}
}
}
}
}
Gene Geren (Eugene)
Wealth-Lab team