{ BBAND.TAS - This script computes BOLLINGER BANDS. Bollinger bands are lines which are 'n' standard deviations away from a 'p' day moving average of the close. To change the value of 'n', change 'bband_devs' below. To change the value of 'p', change 'bband_period' below. } #output_file 'bband.lst' bband_period = 20; { number of days in BBAND period } bband_devs = 2; { number of STD DEVIATIONS about close} bband_top : array; { top band } bband_bot : array; { bottom band } stddev : array; { good old std dev } movavg : array; { and the moving avg } { compute n day sma of close} movavg = mov(c,bband_period,'S'); { and the std dev of close same period} stddev = std(c,bband_period); { Now, compute the number of standard deviations about the close by default, this is 2 } stddev = mulby(stddev,bband_devs); { Now add the std deviations to the moving average to get the top Bollinger Band } bband_top = add(movavg,stddev); { Now subtract the std deviations from the moving average to get the bottom Bollinger Band } bband_bot = sub(movavg,stddev); { Now, the rest is up to you. I have suppied a simple check to see if the current close is over the top band or below the bottom band. You can use these BBAND arrays to check for the narrowing of the bands, tops or bottoms outside the bands, and bouncing off the bands. } if over(c,bband_top) > 0 then writeln(ticker,' BBAND upward breakout occurred'); if over(bband_bot,c) > 0 then writeln(ticker,' BBAND downward breakout occurred');