Chris: I'm not sure what you have in mind. Envelopes for moving averages can be as wide or narrow as you set them. If you want to set envelopes 5 points above and below an MA, the distance between the envelopes will be 10 points, and it won't change. The distance between the envelopes wouldn't depend on the behavior of the price of the stock -- unless you added another factor to the envelopes to make them expand and contract (volatility, for example). Bollinger bands would expand and contract, for example. (Standard deviation in Bollinger bands is a measure of volatility). So would Donchian channels, which are based on previous highs and lows. Did you have Bollinger bands in mind?
If so, try this:
output="bollbandrange.lst";
issuetype=common; exchange nyse,nasdaq,amex;
float bolbandlower, bolbandupper; bolbandlower:=movavg(0,20,cl)-(StDev(0,-19)*2); bolbandupper:=movavg(0,20,cl)+(StDev(0,-19)*2);
if bolbandupper-bolbandlower >=10 then println Symbol, " ,", "Band range: ", bolbandupper-bolbandlower:0:3, " Close: ", Close(0):0:3; endif; |