The AIQ code I am providing this month is based on Sylvain Vervoort’s article in this issue, “Within The Volatility Band.”
Figure 7 shows a chart of CVR Partners LP (UAN) with the setup (yellow circle), the buy signal (green circle), and the exit (red circle). Vervoort’s article states that a valid buy signal does not occur unless the closing price has penetrated the lower band and then closes above the upper band. On October 3, 2011, the close of 20.25 is below the lower band of 20.81 and then we have to wait until January 3, 2012 for the close of 26.48 to be above the upper band of 25.36. We would enter the next day at the opening price of 26.57. We would stay in the trade until the closing price is below the lower band. The exit does not occur for several months until May 9, 2012, when the close of 24.45 is below the lower band of 27.76. We would then exit the next day at the open of 24.41 for a loss of $2.07 plus commission and slippage. The highest close of the trade occurred on February 2, 2012, just a few weeks after the entry, for a high open profit of $4.35. The trade would have been profitable if we had used the middle band as the exit. Note that I did not code the suggested trading system, since Vervoort indicates that more is to come in future parts of his article series.
FIGURE 7: AIQ, VOLATILITY BANDS. Here is a sample chart of UAN with the SVE volatility bands and setup (yellow), entry (green), and exit (red) signals for the period October 3, 2011 to May 10, 2012.
The code and EDS file can be downloaded from www.TradersEdgeSystems.com/traderstips.htm, and is also shown below.
!WITHIN THE VOLATILITY BAND !Author: Sylvain Vervoort !Coded by: Richard Denning 6/7/2013 !www.TradersEdgeSystems.com !INPUTS: BANDAVG is 8. !average=Band average VOLASUM is 13. !volperiod=Volatility Summing period DEVFAC is 3.55. !defac=Deviation factor LBADJ is 0.9. !lowbandadjust=Low band adjustment factor !FORMULAS: H is [high]. L is [low]. L1 is valresult(L,1). C is [close]. typPrice is (H+L+C)/3. typPrice1 is valresult(typPrice,1). typical is iff(typPrice>=typPrice1,typPrice-L1,typPrice1-L). dev is sum(typical,VOLASUM)/VOLASUM*DEVFAC. devHigh is expavg(dev,BANDAVG). devLow is expavg(dev,BANDAVG)*LBADJ. medAvg is expavg(typPrice,BANDAVG). HD if hasdatafor(BANDAVG*3+2*VOLASUM)>= BANDAVG*3+2*VOLASUM. !PLOT THE FOLLOWING AS SINGLE LINE INDICATORS IN THE UPPER PANEL: SVEupper is iff(HD,expavg(medAvg,BANDAVG)+DevHigh,C). SVElower is iff(HD,expavg(medAvg,BANDAVG)-DevLow,C). SVEmid is iff(HD,simpleavg(medAvg,BANDAVG),C).