Traders' Tip text
Swing trading implies short-term trades lasting for days - like the "zero line bounce" continuation pattern. In the absense of an exit strategy, we didn't find our backtest results exceptional. So for this Traders' Tip we decided to fall back on a different strategy. Its rules are pretty simple: buy when the
Activator, DMI and
SMI are all in alignment and sell when it's no longer true.
Strategy rules:
- Buy tomorrow at open when today's close is above the HiLo and both the DMI and SMI are greater than 0
- Sell tomorrow at open when today's close is below the HiLo and both the DMI and SMI are lower than 0
Figure 1. When all the indicators align in bullish mode, the chart background is painted greenish - or reddish during bear trends.To execute the included trading system, install (or update) the latest versions of the
TASCIndicators TASCIndicators and
Community Indicators libraries from the Extensions section of our website if they haven't already done so, and restart Wealth-Lab. Then either copy/paste the included Strategy's C# code or simply let Wealth-Lab do the job. From “Open Strategy” dialog, click “Download” to get this strategy as well as many other contributed by the Wealth-Lab community.
WealthScript Code (C#)
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using TASCIndicators;
using Community.Indicators;
namespace WealthLab.Strategies
{
public class SC202010 : WealthScript
{
protected override void Execute()
{
var hilo = GannHiLoActivator.Series(Bars, 3, false);
var dmi = DIPlus.Series(Bars, 10) - DIMinus.Series(Bars, 10);
var smi = SMI.Series(Bars, 8, 3, 3);
PlotSeries( PricePane, hilo, Color.DarkGreen, LineStyle.Solid, 2);
PlotSeries( CreatePane( 30,false,true), dmi, Color.DarkGreen, LineStyle.Histogram, 3);
ChartPane sPane = CreatePane( 30,false,true);
PlotSeries( sPane, smi, Color.Fuchsia, LineStyle.Solid, 2);
DrawHorzLine( sPane, 40, Color.Green, LineStyle.Dashed, 1);
DrawHorzLine( sPane, -40, Color.Red, LineStyle.Dashed, 1);
HideVolume();
for(int bar = GetTradingLoopStartBar( 20 ); bar < Bars.Count; bar++)
{
var _long = (Close[bar] > hilo[bar] && dmi[bar] > 0 && smi[bar] > 0);
var _short = (Close[bar] < hilo[bar] && dmi[bar] < 0 && smi[bar] < 0);
if (Close[bar] > hilo[bar])
SetSeriesBarColor( bar, hilo, Color.DarkGreen);
else
SetSeriesBarColor( bar, hilo, Color.Red);
if (dmi[bar] > 0)
SetSeriesBarColor( bar, dmi, Color.DarkGreen);
else
SetSeriesBarColor( bar, dmi, Color.Red);
if (smi[bar] > 0)
SetSeriesBarColor( bar, smi, Color.DarkGreen);
else
SetSeriesBarColor( bar, smi, Color.Red);
if (_long)
SetBackgroundColor( bar, Color.FromArgb(30, Color.DarkGreen));
if(_short)
SetBackgroundColor( bar, Color.FromArgb(30, Color.DarkRed));
if (IsLastPositionActive)
{
if ( _short )
SellAtMarket( bar + 1, LastPosition);
}
else
{
if ( _long )
BuyAtMarket( bar + 1);
}
}
}
}
}
Gene Geren (Eugene)
Wealth-Lab team