TRADERS’ TIPS

January 2019

Tips Article Thumbnail

For this month’s Traders’ Tips, the focus is Sylvain Verboort’s article in the July 2018 issue, “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands.” Here, we present the January 2019 Traders’ Tips code with possible implementations in various software.

You can right-click on any chart to open it in a new tab or window and view it at it’s originally supplied size, often much larger than the version printed in the magazine.

The Traders’ Tips section is provided to help the reader implement a selected technique from an article in this issue or another recent issue. The entries here are contributed by software developers or programmers for software that is capable of customization.


logo

TRADESTATION: JANUARY 2019

In “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands” in the July 2018 STOCKS & COMMODITIES, author Sylvain Vervoort introduced a new type of price band that he calls the SVEVolatilityBand. He created this new type of band to better highlight volatility changes when using non-time-related charts. According to the author, when using charts such as renko, traditional bands may fail to effectively highlight these changes.

The TradeStation EasyLanguage code for the SVEVolatilityBands indicator based on the author’s work is presented here.

Indicator: SVEVolatilityBands
// SVEVolatilityBands
// Sylvain Vervoort
// TASC Jan 2019

inputs:
	Price( Close ),
	BandsPeriod( 20 ),
	BandsDeviation( 2.4 ),
	LowBandAdjust( .9 ),
	MidLineLength( 20 ) ;
	
variables:
	HighBand( 0 ),
	LowBand( 0 ),
	MidLine( 0 ),
	ATRVal( 0 ),
	WtdAvgVal( 0 ) ;
	
		
ATRVal = AvgTrueRange( BandsPeriod * 2 - 1 ) 
	* BandsDeviation ;
WtdAvgVal = WAverage( Price, BandsPeriod ) ;
HighBand = WtdAvgVal + WtdAvgVal 
	* ( AtrVal / Price ) ;
LowBand = WtdAvgVal - WtdAvgVal 
	* ( AtrVal * LowBandAdjust / Price ) ;
MidLine = WAverage( TypicalPrice, MidLineLength ) ;

Plot1( HighBand, "Upper Band" ) ;
Plot2( LowBand, "Lower Band" ) ;
Plot3( MidLine, "Mid Line" ) ;
		

To download the EasyLanguage code, please visit our TradeStation and EasyLanguage support forum. The files for this article can be found here: https://community.tradestation.com/Discussions/Topic.aspx?Topic_ID=156727. The filename is “TASC_JAN2019.ZIP.”

For more information about EasyLanguage in general, please see https://www.tradestation.com/EL-FAQ.

A sample chart is shown in Figure 1.

Sample Chart

FIGURE 1: TRADESTATION. A TradeStation mean renko chart of the S&P 500 displays the SVEVolatilityBands indicator.

This article is for informational purposes. No type of trading or investment recommendation, advice, or strategy is being made, given, or in any manner provided by TradeStation Securities or its affiliates.

—Doug McCrary
TradeStation Securities, Inc.
www.TradeStation.com

BACK TO LIST

logo

THINKORSWIM: JANUARY 2019

We have put together a study for thinkorswim based on the July 2018 article by Sylvain Vervoort, “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands.”

We built the study and strategy by using our proprietary scripting language, thinkScript. To ease the loading process, simply click on https://tos.mx/ODAWqm, then choose view thinkScript study and name it “SVEVolatilityBand.” This can then be added to your chart from the edit study and strategies menu within thinkorswim.

In Figure 2, the study can be seen on a range chart set to ATR (average true range) of the GBP/USD forex pair. See Sylvain Vervoot’s article in the July 2018 issue for more details on how to interpret the study.

Sample Chart

FIGURE 2: THINKORSWIM. Here, the study can be seen on a range chart set to ATR (average true range) of the GBP/USD forex pair.

—thinkorswim
A division of TD Ameritrade, Inc.
www.thinkorswim.com

BACK TO LIST

logo

QUANTACULA: JANUARY 2019

The smoothed volatility bands indicator described by author Sylvain Vervoort in his July 2018 article, “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands,” is available in Quantacula’s open-source TASC Extensions library. The sourcecode for all 100+ indicators is available in the following GitHub repository, which is a treasure trove of Quantacula programming knowledge:

https://github.com/LucidDion/TASC-Extensions

The SVESmoothedVolatilityBandUpper and Lower were recently added to the repository by a Quantacula user and have since been included in the latest builds of the Quantacula.com website and the Quantacula Studio desktop backtesting platform.

We noticed that the bands identify extreme price excursions when the deviation parameter is set to 3.0. The following trading model uses simulated limit orders to try and buy Nasdaq 100 stocks that penetrate the lower band. The model then sells the next day at market open. It uses the following settings:

Starting capital: $400,000
Margin ractor: 2:1
Commission: $4.95 per trade
Position size: 5% of equity per trade

We tested the model on the QPremium Nasdaq 100 universe, which contains dynamic logic that swaps symbols in and out of the universe as they were added and removed from the Nasdaq 100 historically. The equity curve for the SVE smoothed volatility band lower trading model in Quantacula Studio is shown in Figure 3.

Sample Chart

FIGURE 3: QUANTACULA. The equity curve for the SVE smoothed volatility band lower trading model in Quantacula Studio is shown.

The model’s C# code for Quantacula.com or Quantacula Studio is shown here:

using QuantaculaBacktest;
using QuantaculaCore;
using QuantaculaIndicators;
using TASCIndicators;

namespace Quantacula
{
    public class MyModel : UserModelBase
    {
	 //constructor
        public MyModel() : base()
        {
        }

	 //Initialize is called once prior to backtest
        public override void Initialize(BarHistory bars)
        {
            vb = new SVESmoothedVolatilityBandLower(bars, 20, 20, 3.0, 0.90);
            Plot(vb);
        }

	 //Execute is called once for every bar of data in the history
        public override void Execute(BarHistory bars, int idx)
        {
            PlaceTrade(bars, TransactionType.Buy, OrderType.Limit, vb[idx]);
            foreach (Position pos in OpenPositions)
                ClosePosition(pos, OrderType.Market);
        }

	 //declare variables
        private IndicatorBase vb;
    }
}

BACK TO LIST

logo

NINJATRADER: JANUARY 2019

The SveVolatilityBand indicator, as discussed in the July 2018 article “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands,” is available for download at the following links for NinjaTrader 8 and for NinjaTrader 7.

Once the file is downloaded, you can import the indicator in NinjaTader 8 from within the Control Center by selecting Tools → Import → NinjaScript Add-On and then selecting the downloaded file for NinjaTrader 8. To import in NinjaTrader 7 from within the Control Center window, select the menu File → Utilities → Import NinjaScript and select the downloaded file.

You can review the indicator’s source code in NinjaTrader 8 by selecting the menu New → NinjaScript Editor → Indicators from within the Control Center window and selecting the SveVolatilityBand file. You can review the indicator’s source code in NinjaTrader 7 by selecting the menu Tools → Edit NinjaScript → Indicator from within the Control Center window and selecting the SveVolatilityBand file.

NinjaScript uses compiled DLLs that run native, not interpreted, which provides you with the highest performance possible.

A sample chart implementing the strategy is shown in Figure 4.

Sample Chart

FIGURE 4: NINJATRADER. The SveVolatilityBand indicator displayed on a one-minute ES 12-18 chart on November 8, 2018.

—Raymond Deux & Jim Dooms
NinjaTrader, LLC
www.ninjatrader.com

BACK TO LIST

logo

eSIGNAL: JANUARY 2019

For this month’s Traders’ Tip, we’ve provided the SveVolatilityBand.efs study based on the article by Sylvain Vervoort that appeared in the July 2018 issue of STOCKS & COMMODITIES, “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands.” This study displays the volatility band on the price chart.

The studies contain formula parameters that may be configured through the edit chart window (right-click on the chart and select edit chart). A sample chart is shown in Figure 5.

Sample Chart

FIGURE 5: eSIGNAL. Here is an example of the study plotted on a 60-minute chart of EUR A0-FX.

To discuss this study or download a complete copy of the formula code, please visit the EFS library discussion board forum under the forums link from the support menu at www.esignal.com or visit our EFS KnowledgeBase at www.esignal.com/support/kb/efs/. The eSignal formula script (EFS) is also available here:

/*********************************
Provided By:  
eSignal (Copyright c eSignal), a division of Interactive Data 
Corporation. 2016. All rights reserved. This sample eSignal 
Formula Script (EFS) is for educational purposes only and may be 
modified and saved under a new file name.  eSignal is not responsible
for the functionality once modified.  eSignal reserves the right 
to modify and overwrite this EFS file with each new release.

Description:        
    The V-Trade. Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands
    by Sylvain Vervoort
    

Version:            1.00  11/13/2018

Formula Parameters:                     Default:
VolatilityBand                          True
Bands Average Bars                      20
Bands Volatility Range                  2.4
Low Band Adjust (Vol. Band Only)        0.9
Middle Line LWMA Average                20

Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.

**********************************/



var fpArray = new Array();

function preMain(){
    setPriceStudy(true);
    setStudyTitle("SveVolatilityBand");
    setCursorLabelName("Upper",0);
    setCursorLabelName("Basis",1);
    setCursorLabelName("Lower",2);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_LINE, 1);
    setPlotType(PLOTTYPE_LINE, 2);
    setDefaultBarThickness(2,0);
    setDefaultBarThickness(2,1);
    setDefaultBarThickness(2,2);
    setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF),0);
    setDefaultBarFgColor(Color.RGB(0xFE,0x69,0x00),1);
    setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF),2);
    
    
    var x = 0;
    fpArray[x] = new FunctionParameter("VolatilityBand", FunctionParameter.BOOLEAN);
	with(fpArray[x++]){
        setName("Volatility Band (true=Volatility, false=Bollinger)");
        setDefault(true);
        
    }

    fpArray[x] = new FunctionParameter("BandsPeriod", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setName("Bands Average Bars");
        setLowerLimit(1);
        setDefault(20);
       
    }
    fpArray[x] = new FunctionParameter("BandsDeviation", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setName("Bands Volatility Range");
        setLowerLimit(0);
        setDefault(2.4);
        
    }
    fpArray[x] = new FunctionParameter("LowbandAdjust", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setName("Low Band Adjust (Vol. Band Only)");
        setLowerLimit(0);
        setDefault(0.9);
        
    }
    fpArray[x] = new FunctionParameter("MiddleLineLwma", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setName("Middle Line LWMA Average");
        setLowerLimit(1);
        setDefault(20);
        
    }
}

var bInit = false;
var bVersion = null;

var xAtrBuf = null;
var xTempBuf = null;
var xHigh = null;
var xLow = null;
var xClose = null;
var xWMA;
var xHighChannel = null;
var xLowChannel = null;
var xMedianAverage = null;

function main(VolatilityBand, BandsPeriod, BandsDeviation, LowbandAdjust, MiddleLineLwma){
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;
        
    if (getBarState() == BARSTATE_ALLBARS){
        bInit = false;
    }
   
    if (!bInit){
                
        xClose = close();
        xHigh = high();
        xLow = low();
        xWMA = wma(BandsPeriod);
        
        xTempBuf = efsInternal("Calc_TempBuf", xHigh, xLow, xClose);
        xAtrBuf = efsInternal("Calc_AtrBuf", xTempBuf, BandsPeriod, BandsDeviation);
        
        xMedianAverage = wma(MiddleLineLwma, hlc3());
        if (VolatilityBand == true) {
            xHighChannel = efsInternal( "_HighChannel", xWMA, xAtrBuf, xClose);
            xLowChannel = efsInternal( "_LowChannel", xWMA, xAtrBuf, xClose, LowbandAdjust);
        }
        else {
            xHighChannel = upperBB(BandsPeriod, BandsDeviation, xClose);
            xLowChannel = lowerBB (BandsPeriod, BandsDeviation, xClose);
        }    
        bInit = true;
    }

    var vHighChannel = xHighChannel.getValue(0);    
    var vMedianAverage = xMedianAverage.getValue(0);
    var vLowChannel = xLowChannel.getValue(0);    
    
    return [vHighChannel, vMedianAverage, vLowChannel];
}

function Calc_TempBuf (xHigh, xLow, xClose){
    if (xClose.getValue(-1) == null ) return (xHigh.getValue(0)- xLow.getValue(0));
    var TB = Math.max(xHigh.getValue(0), xClose.getValue(-1)) - Math.min(xLow.getValue(0), xClose.getValue(-1));
    return TB; 
}

 var xSMA = null;
function Calc_AtrBuf(xTempBuf, BandsPeriod, BandsDeviation){  
    if(xSMA == null) xSMA = sma(BandsPeriod, xTempBuf);
    if (xTempBuf.getValue(-BandsPeriod) == null) return;
    return (xSMA.getValue(0) * BandsDeviation);
}

 function _HighChannel(xWMA, xAtrBuf, xClose){
        if (xAtrBuf.getValue(0) == null) return;
        var vHC = xWMA.getValue(0) + (xWMA.getValue(0) * xAtrBuf.getValue(0) / xClose.getValue(0)) ;
            
    return vHC;
}

function _LowChannel(xWMA, xAtrBuf, xClose, LowbandAdjust){
        if (xAtrBuf.getValue(0) == null) return;
        var vLC = xWMA.getValue(0) - (xWMA.getValue(0) * xAtrBuf.getValue(0) * LowbandAdjust / xClose.getValue(0)) ;
            
    return vLC;
}

function verify(){
    var b = false;
    if (getBuildNumber() < 779){
        
        drawTextAbsolute(5, 35, "This study requires version 10.6 or later.", 
            Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null, 13, "error");
        drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=https://www.esignal.com/download/default.asp", 
            Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null, 13, "upgrade");
        return b;
    } 
    else
        b = true;
    
    return b;
}

—Eric Lippert
eSignal, an Interactive Data company
800 779-6555, www.eSignal.com

BACK TO LIST

logo

WEALTH-LAB: JANUARY 2019

Don’t be confused by the SveVolatilityBands name: The new bands discussed by author Sylvain Vervoort in his July 2018 STOCKS & COMMODITIES article “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands” are different from the synonymous indicator from his August 2013 article in STOCKS & COMMODITIES and which we wrote about in the Traders’ Tips section of that issue.

Since this indicator does not come with a trading system, we decided that a good illustration of its application may be through the concept of volatility contraction and expansion. Price breakout following a volatility contraction implies an expansion in volatility of the price range, which acts as catalyst to longer-term trends. The opposite phase, that is, when the bands’ volatility reaches its longer-term high, signifies considerable price changes and a potential end of the trend. The width percentage of the smoothed volatility bands is measured over desired lookback (here, 200 days).

System rules:

The system may be risky in its current barebone state so motivated traders might want to use a stop-loss and/or a trend filter to liquidate the position if the trend has changed from bullish.

A sample chart is shown in Figure 6.

Sample Chart

FIGURE 6: WEALTH-LAB. This sample chart demonstrates the characteristic volatility expansion trade in AAPL (Apple Inc).

For extra flexibility in configuring various parameters, drag “sliders” at the bottom of the screen interactively. The strategy’s code is downloadable and can be found under the “breakouts” folder in the “open strategy” dialog (Ctrl-O, then click download and begin download).

To execute successfully in Wealth-Lab, the system requires the latest version of the TASCIndicators library. Please install (or update if you haven’t done so already) the library from our Wealth-Lab.com site to its latest version.

C# Code

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using TASCIndicators;

namespace WealthLab.Strategies
{
	public class SVESmoothedVolatilityBands : WealthScript
	{
		private StrategyParameter paramBandAvg;
		private StrategyParameter paramMiddleLine;
		private StrategyParameter paramDevFact;
		private StrategyParameter paramLowBAdj;
		private StrategyParameter paramSqueezeLookback;

		public SVESmoothedVolatilityBands()
		{
			paramBandAvg = CreateParameter("Band average", 20, 2, 100, 1);
			paramMiddleLine = CreateParameter("Middle line period", 20, 2, 100, 1);
			paramDevFact = CreateParameter("Deviation factor", 2.4, 0.2, 5.0, 0.2);
			paramLowBAdj = CreateParameter("Low Band Adj.", 0.9, 0.1, 3.0, 0.1);
			paramSqueezeLookback = CreateParameter("Squeeze lookback", 200, 5, 150, 1 );        
		}
		
		protected override void Execute()
		{
			int average = paramBandAvg.ValueInt;
			int middleperiod = paramMiddleLine.ValueInt;
			double devfact = paramDevFact.Value;
			double lowbandadjust = paramLowBAdj.Value;
			int squeezelen = paramSqueezeLookback.ValueInt;

			// Smoothed Volatility Bands
			var TypicalPrice = AveragePriceC.Series( Bars );
			var MedianAverage = WMA.Series(TypicalPrice, middleperiod);
			var HighChannel = SVESmoothedVolatilityBandUpper.Series( Bars, average, middleperiod, devfact, lowbandadjust );
			var LowChannel = SVESmoothedVolatilityBandLower.Series( Bars, average, middleperiod, devfact, lowbandadjust );

			SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(50, Color.Violet));
			PlotSeriesFillBand(PricePane, HighChannel, LowChannel, Color.Blue, shadowBrush, LineStyle.Solid, 2);
			PlotSeries(PricePane, MedianAverage, Color.Blue, LineStyle.Solid, 1);
			HideVolume();

			// Squeeze and expansion in SveVolatilityBands
			var PctWidth = ( ( HighChannel - LowChannel ) / MedianAverage ) * 100; PctWidth.Description = "% Width";
			var PctWidthMax = Highest.Series( PctWidth, squeezelen );
			var PctWidthMin = Lowest.Series( PctWidth, squeezelen );
			
			ChartPane PctWPane = CreatePane( 20, true, true );
			PlotSeries( PctWPane, PctWidth, Color.Blue, WealthLab.LineStyle.Solid, 2 );
			PlotSeries( PctWPane, Lowest.Series( PctWidth, squeezelen ), Color.DarkGreen, LineStyle.Dashed, 2 );
			PlotSeries( PctWPane, Highest.Series( PctWidth, squeezelen ), Color.DarkRed, LineStyle.Dashed, 2 );

			for(int bar = GetTradingLoopStartBar(average); bar < Bars.Count; bar++)
			{
				if (IsLastPositionActive)
				{
					if(	PctWidth[bar] >= PctWidthMax[bar] )
					{
						SetBackgroundColor( bar, Color.FromArgb(30, Color.Red) );
						if( Low[bar] <= Lowest.Series(Low, average)[bar] )
							SellAtMarket(bar+1, LastPosition, "Vola expansion");
					}					
				}
				else
				{
					if(	PctWidth[bar] <= PctWidthMin[bar] )
					{
						SetBackgroundColor( bar, Color.FromArgb(30, Color.Green) );
						if( Close[bar] >= SMA.Series(Close,	squeezelen)[bar] )
							BuyAtStop( bar+1, Highest.Series(High, average)[bar], "Vola contraction" );
					}
				}	
			}
		}
	}
}

—Gene (Eugene) Geren, Wealth-Lab team
MS123, LLC
www.wealth-lab.com

BACK TO LIST

logo

NEUROSHELL TRADER: JANUARY 2019

The moving averages and volatility bands described by Sylvain Vervoort in his July 2018 STOCKS & COMMODITIES article “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands” can be easily implemented in the NeuroShell Trader by combining a few of NeuroShell Trader’s 800+ indicators. To implement the indicators, select new indicator from the insert menu and use the Indicator Wizard to create the following indicators:

Moving Averages:
Simple Moving Average:	Avg(Close,100)
Exponential Moving Average:		ExpAvg(Close,100)
Linearly-weighted Moving Average: 	LinWgtAvg(Close,100)

SveVolatiltyBands:
Upper Band: 	Mul2( LinWgtAvg(Close,20), Add2(1, Divide( Mul2( Avg( Sub( Max2( High, Lag(Close,1)), Min2( Low, Lag(Close,1))), 20), 2.4), Close)))
Lower Band: 	Mul2( LinWgtAvg(Close,20), Sub(1, Divide( Mul3( Avg( Sub( Max2( High, Lag(Close,1)), Min2( Low, Lag(Close,1))), 20), 2.4, 0.9), Close)))
Middle:		LinWgtAvg(Avg3(High,Low,Close),20)

Bollinger Bands:
Upper Band:	BB High(Close,20,2.4)
Lower Band:	BB Low(Close,20,2.4)
Middle:	LinWgtAvg(Avg3(High,Low,Close),20)

Users of NeuroShell Trader can go to the Stocks & Commodities section of the Neuro­Shell Trader free technical support website to download a copy of this or any Traders’ Tips.

A sample chart is shown in Figure 7.

Sample Chart

FIGURE 7: NEUROSHELL TRADER. This NeuroShell Trader chart shows a comparison of the different moving averages and volatility bands.

—Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com

BACK TO LIST

logo

AIQ: JANUARY 2019

The AIQ EDS file for Sylvain Vervoort’s July 2018 article in S&C, “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands,” can be obtained on request via email to info@TradersEdgeSystems.com. The code is also available below.

!THE V-TRADE, PART 5
!Author: Sylvain Vervoort, TASC July 2018
!Coded by: Richard Denning 11/15/18
!www.TradersEdgeSystems,com

!ABBREVIATIONS:
C is [close].
C1 is valresult(C,1).
C2 is valresult(C,2).
C3 is valresult(C,3).
C4 is valresult(C,4).
C5 is valresult(C,5).
C6 is valresult(C,6).
C7 is valresult(C,7).
C8 is valresult(C,8).
C9 is valresult(C,9).
C10 is valresult(C,10).
C11 is valresult(C,11).
C12 is valresult(C,12).
C13 is valresult(C,13).
C14 is valresult(C,14).
C15 is valresult(C,15).
C16 is valresult(C,16).
C17 is valresult(C,17).
C18 is valresult(C,18).
C19 is valresult(C,19).
PD is {position days}.
PEP is {position entry price}.

!MOVING AVERAGES:
!SIMPLE MOVING AVERAGES:
smaLen1 is 50.
smaLen2 is 100.
smaLen3 is 200.
esaLen is 20.
esaBandPct is 10.

sma1 is simpleavg(C,smaLen1).
sma2 is simpleavg(C,smaLen2).
sma3 is simpleavg(C,smaLen3).

!LINEAR WEIGHTED 
LWMA is (C*20+C1*19+C2*18+C3*17+C4*16
      +C5*15+C6*14+C7*13+C8*12+C9*11
      +C10*10+C11*9+C12*8+C13*7+C14*6
      +C15*5+C16*4+C17*3+C18*2+C19*1)/210.

!ESA BANDS:
esa is expavg(C,esaLen).
upperESA is esa*(1+esaBandPct/100).
lowerESA is esa*(1-esaBandPct/100).

!BOLLINGER BANDS:
!SET PARAMETERS FOR BANDS:
 BBlen 	is 20.!Default is 20
 Mult1 	is 2. !Default is 2
 Mult2 	is 2. !Default is 2

Variance is Variance([close],BBlen).
StdDev is Sqrt(Variance).
SMA is simpleavg([close],BBlen).
UpperBB is SMA + StdDev *  Mult1.
LowerBB is SMA - StdDev *  Mult2.

ShowValues if 1.

Squeeze if upperESA > UpperBB and lowerESA < LowerBB.

SqIndicator is iff(Squeeze,1,iff(not Squeeze,0,-1)).

Buy if upperESA < UpperBB  and valrule(Squeeze,1)
	 and C > sma3 and C<LWMA. 
Sell if (PD>=3 and  LWMA < valresult(LWMA,1)) or C < PEP.

The EDS file contains the code for the various moving averages mentioned in the article as well as code for the Bollinger Bands and exponential bands. I did not code the SVE bands discussed by Vervoort in his article. I coded a system that uses the concept of a squeeze, as discussed in the article. A squeeze occurs when the Bollinger Bands are inside the exponential bands. Figure 8 shows a sample trade from the system on NVDA. Figure 9 shows the EDS summary report for a four-year backtest using the NASDAQ 100 list of stocks.

Sample Chart

FIGURE 8: AIQ. This shows a sample trade from the squeeze system.

Sample Chart

FIGURE 9: AIQ. Here is a summary EDS report for a four-year backtest of the squeeze system.

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

BACK TO LIST

logo

TRADERSSTUDIO: JANUARY 2019

The TradersStudio code file for Sylvain Vervoort’s July 2018 article in S&C, “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands,” can be obtained on request via email to info@TradersEdgeSystems.com. The code is also available here:

'THE V-TRADE, PART 5
'Author: Sylvain Vervoort, TASC July 2018
'Coded by: Richard Denning 11/15/18
'www.TradersEdgeSystems.com

Sub SQUEEZE_MKT(smaLen,lwmaLen,esaLen,esaPct,minHold)
'smaLen=150,lwmaLen=20,esaLen=20,esaPct=7,minHold=3
Dim SMA As BarArray
Dim upperBB As BarArray
Dim lowerBB As BarArray
Dim ESA As BarArray
Dim upperESA As BarArray
Dim lowerESA As BarArray
Dim LWMA As BarArray
Dim SQZE As BarArray
Dim SMAmkt As BarArray
SMA = Average(C,smaLen)
SMAmkt = Average(C Of independent1,smaLen)
LWMA = WeightedMA(C,lwmaLen,0)
upperBB = UpperBolBand(C,esaLen,2,0)
lowerBB = LowerBolBand(C,esaLen,2,0)
ESA = XAverage(C,esaLen)
upperESA = ESA*(1+esaPct/100)
lowerESA = ESA*(1-esaPct/100)

If upperESA > upperBB And lowerESA < lowerBB Then
    SQZE = 1
Else
    SQZE = 0
End If

If C Of independent1 > SMAmkt Then
  If upperESA < upperBB  And SQZE[1]=1 And C > SMA And C < LWMA Then
    Buy("LE",1,0,Market,Day) 
  End If
End If
If (BarsSinceEntry >= minHold And LWMA < LWMA[1]) Or C < EntryPrice Then
    ExitLong("LX","",1,0,Market,Day)
End If
End Sub

I did not code the SVE bands that are discussed in Vervoort’s article. I coded a system that uses the concept of a squeeze, as discussed in the article. A squeeze occurs when the Bollinger Bands are inside the exponential bands. Figure 10 shows a sample equity curve trading the list of the NASDAQ 100 stocks from 2000 to 2014 using the SQUEEZE_MKT code.

Sample Chart

FIGURE 10: TRADERSSTUDIO. This shows a sample equity curve trading the list of the NASDAQ 100 stocks from 2000–2014 using the SQUEEZE_MKT code.

—Richard Denning
info@TradersEdgeSystems.com
for TradersStudio

BACK TO LIST

logo

AMIBROKER: JANUARY 2019

In “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands” in the July 2018 STOCKS & COMMODITIES, author Sylvain Vervoort presented the Sve volatility bands that can serve as a complementary tool to Bollinger Bands. Sve volatility bands are essentially ATR-based bands with a small twist.

Some ready-to-use code for AmiBroker is provided here. A sample chart is shown in Figure 11.

BandsPeriod = Param("Bands Period", 20, 2, 100 ); 
BandsDeviation = Param("Bands Deviation", 2.4, 1.0, 3.0, 0.1 ); 
LowBandAdj = Param("LowBand Adjust", 0.9, 0.5, 1.5, 0.1 ); 
MiddleMA = Param("Middle LWMA", 20, 2, 100 ); 

TR = ATR( 1 ); // true range 

// TASC code uses simple MA 
MATR = BandsDeviation * MA( TR, BandsPeriod * 2 - 1 ); 

MAC = WMA( C, BandsPeriod ); 

HighChannel = MAC * ( 1 + MATR / Close ); 
LowChannel = MAC * ( 1 - LowBandAdj * MATR / Close ); 

// WMA from typical price 
MedAverage = WMA( Avg, MiddleMA ); 

Plot( Close, "Price", colorDefault, styleCandle ); 
Plot( HighChannel, "HighChannel", colorPink ); 
Plot( LowChannel, "LowChannel", colorPink ); 
Plot( MedAverage, "MedAverage", colorBlue );
Sample Chart

FIGURE 11: AMIBROKER. Here is an example range bar chart of GBPUSD with Sve Volatility bands and a weighted moving average.

—Tomasz Janeczko, AmiBroker.com
www.amibroker.com

BACK TO LIST

MICROSOFT EXCEL: JANUARY 2019

In “The V-Trade, Part 5: Technical Analysis—Moving Average Support & Resistance And Volatility Bands” in the July 2018 STOCKS & COMMODITIES, author Sylvain Vervoort has laid out a couple of ways to look for support & resistance in a price time series.

Among the first he describes are a set of moving averages, where we are looking at price action reaching and frequently bouncing off one of these averages as the pricing continues a trend, or penetrating one or more of the averages in reversal situations.

Figure 12 shows a price chart and a renko chart of roughly the same time period. Due to the nature of creating renko bars, the renko chart will almost never display the exact same number of bars as in a price chart of the same period. It usually displays many fewer bars since the process of creating a renko bar may have “devoured” many price bars in the areas of sideways or very low-pitch trending price action. This “timeless” nature of renko charts reduces the predictive utility of the moving averages on renko charts.

Sample Chart

FIGURE 12: EXCEL, MOVING AVERAGES ON PRICE AND RENKO CHARTS

Compare the location of the cursor on the price chart and on the renko chart. The cursor on the renko chart is over the bar that most closely matches the time stamp of the bar under the cursor on the price chart. Selecting peaks and adjacent valleys with the cursor on the price chart can give you a feel for the renko bricks inserted for a steep price move, or the price bars “devoured” in a shallow or sideways price move.

Figures 13 & 14 allow us to compare and contrast two approaches to using volatility banding in predictive strategies.

Sample Chart

FIGURE 13: EXCEL, SVE VOLATILITY BANDS ON PRICE AND RENKO CHARTS

Sample Chart

FIGURE 14: EXCEL, BOLLINGER BANDS

The envelope created by Vervoort’s new SveVolatility band strategy does a nice job of tracking both the price and renko bars.

Bollinger Bands are by design much more sensitive to changes in volatility and among other features, they do a very nice job of locating sideways and well-defined price trend channels.

The spreadsheet file for this Traders’ Tip can be downloaded here:

—Ron McAllister
Excel and VBA programmer
rpmac_xltt@sprynet.com

BACK TO LIST

Originally published in the January 2019 issue of
Technical Analysis of STOCKS & COMMODITIES magazine.
All rights reserved. © Copyright 2018, Technical Analysis, Inc.