In “Within The Volatility Band” in this issue, author Sylvain Vervoort presents a volatility band component of his swing trading strategy. Ready-to-use AmiBroker code for the indicator is presented here. To display the indicator, simply enter it in the formula editor and press apply indicator. The averaging period and other parameters can be changed by right-clicking the chart and selecting parameters from the context menu.
A sample chart is shown in Figure 5.
FIGURE 5: AMIBROKER, VOLATILITY BANDS. This price chart of Seagate Technology (STX) with the SVEVolatilityBand overlay replicates results from Sylvain Vervoort’s article elsewhere in this issue.
LISTING 1 average = Param("Band average", 8, 1 ); Volperiod = Param("VolPeriod", 13, 1 ); devfactor = Param("Devfactor", 3.55, 0, 10, 0.01 ); Lowbandadjust = Param("Low band adj.", 0.9, 0, 5, 0.01 ); Typical = ( High + Low + Close )/3; AdjTyp = IIf( Typical > Ref( Typical, -1 ), Typical - Ref( Low, -1 ), Ref( Typical, -1 ) - Low ); Deviation = Sum( AdjTyp , VolPeriod )/ VolPeriod * devfactor; DevHigh = EMA( deviation, average ); DevLow = EMA( deviation, average ) * Lowbandadjust; Medianaverage = EMA( Typical, average ); Plot( C, "SVEVolatilityBand" + _PARAM_VALUES() + " Price", colorDefault, styleCandle ); Plot( EMA( Medianaverage, average ) + DevHigh, "Upper", colorViolet ); Plot( EMA( Medianaverage, average ) - DevLow, "Lower", colorViolet ); Plot( MA( Medianaverage, average ), "Median", colorBlue );