Quantcast
RSS Feeds | Advertise | Subscribe | Contact Us
Futures Magazine.

News

Web Exclusives

 Fixing Bollinger Bands: Codes and results 

 
Print This Article
Return To Article
Normal Text
Large Text

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:


Comment on This Article

Name:
Email (will not be published):
Subject:
Comment:

    • 5/4/2010 2:36:27 PM
    • Phillip Churelington
    • Software?
    • For which program is the code offered used?
    • 5/16/2010 6:49:47 PM
    • EJ Knoll
    • help
    • Will this code work for TradeStation? It was an interesting article but if I can't get it into TradeStation, it isn't worth much. Hope you can help. Thanks
    • 5/26/2010 5:11:02 PM
    • D Shane
    • Formula
    • I am also trying to get this to work in CQG, just to plot the bands. I have tried what's in the magazine as well as what you have on this site, and I can't seem to get it to work. Any help would be appreciated. Thank you.

Recent Issues


Archived Issues

Most Read Articles

Related Articles