本帖最後由 sangi 於 13-2-3 13:57 編輯
剛跑過程式..沒問題
話說 Price 是否一定要用(O+H+L+C)/4 ? ........先把他改成Close 來試看看吧
提供我的版本給你參考
1. Bollinger Band Width : (UBand-LBand)/ MidBand
Inputs: Length (20) ,NumStdDevs(2) ,PriceValue((O + H + L + C) / 4) ;
Vars: BMidBand(0) ,BUpperBand(0) ,BLowerBand(0) ,BBandWidth(0) ;
BMidBand = AverageFC(PriceValue,Length) ;
BUpperBand = BollingerBand(PriceValue,Length,NumStdDevs) ;
BLowerBand = BollingerBand(PriceValue,Length,-NumStdDevs) ;
BBandWidth = IFF(BMidBand > 0 ,(BUpperBand - BLowerBand)/BMidBand,0) ;
Plot1(BBandWidth) ;
2. Bollinger Band %B : (Price-LBand)/(UBand-LBand)
Inputs: Length (20) ,NumStdDevs(2) ,PriceValue((O + H + L + C) / 4) ;
Vars: BMidBand(0) ,BUpperBand(0) ,BLowerBand(0) ,BBandPercentB(0) ;
BMidBand = AverageFC(PriceValue,Length) ;
BUpperBand = BollingerBand(PriceValue,Length,NumStdDevs) ;
BLowerBand = BollingerBand(PriceValue,Length,-NumStdDevs) ;
BBandPercentB = IFF(BUpperBand <> BLowerBand,(PriceValue - BLowerBand) / (BUpperBand - BLowerBand),0) ;
Plot1(BBandPercentB) ;
|