From the May 01, 2010 issue of Futures Magazine • Subscribe!

Fixing Bollinger Bands: Codes and results

Codes for David Rooke's May 2010 Trading Techniques story, "Fixing Bollinger Bands."

Code 1:

Sub VolBandExtremes(Length,Mult)

Dim TXMA, ZL_TXMA As BarArray

Dim StDev, BandHigh, BandLow, BandWidth

Dim PctBand

Dim BuyThresh, SellThresh

BuyThresh = 0.2

SellThresh = 0.8

TXMA = TEMAPlus(Close, Length, 0)

ZL_TXMA = ZL_TEMA(TXMA, Length, 0)

If ZL_TXMA[Length-1] > 0 Then

StDev = StdDevPlus(Close, ZL_TXMA, Length)*Mult

BandHigh = ZL_TXMA+StDev

BandLow = ZL_TXMA-StDev

BandWidth = (BandHigh - BandLow)

If BandWidth > 0 Then

PctBand = (Close - BandLow) / BandWidth

Else

PctBand = 0.5

End If

End If

If CrossesUnder(PctBand,BuyThresh) Then

Buy ("LowBandBuy",1,0,Market,Day)

End If

If CrossesOver(PctBand,SellThresh) Then

Sell ("HighBandSell",1,0,Market,Day)

End If

End Sub

Code 2:

Sub VolBandBreakout(Length,ChanLen,Mult)

Dim TXMA As BarArray

Dim ZL_TXMA As BarArray

Dim BandH,BandL As BarArray

Dim StDev

TXMA = TEMAPlus(C, Length, 0)

ZL_TXMA = ZL_TEMA(TXMA, Length, 0)

If ZL_TXMA[Length-1] > 0 Then

StDev = MovingStDev(C, ZL_TXMA, Length, Mult)

End If

BandH = ZL_TXMA+StDev

BandL = ZL_TXMA-StDev

If (BandH - BandL) <> 0 Then Buy("BandBreakBuy",1,Highest(BandH,ChanLen,0)+GetActiveMinMove(),Stop,Day)

Sell("BandBreakSell",1,Lowest(BandL,ChanLen,0)-GetActiveMinMove(),Stop,Day)

End If

End Sub

Results:

Comments
comments powered by Disqus
Check out Futures Magazine - Polls on LockerDome on LockerDome