有用戶問到如何撰寫布林軌道指標帶寬策略的選股腳本
在這邊寫了一段範例供各位參考
規則如下:
布林軌道選股策略- 收盤價小於上軌且大於中軌, BBand width 小於10% ,選完之後還是無法濾掉大於10%的股票 請問該如何修改程式碼?
input: Length(20), UpperBand(2), LowerBand(2); variable: up(0), down(0), mid(0), bbandwidth(0),midband(0); SetInputName(1, "天數"); SetInputName(2, "上"); SetInputName(3, "下"); up = bollingerband(Close, Length, UpperBand); midband = average(close, Length); down = bollingerband(Close, Length, -1 * LowerBand); mid = (up + down) / 2; bbandwidth = 100 * (up - down) / mid; if close < up and close > midband and bbandwidth < 10 then ret = 1; outputfield(1,up,"up"); outputfield(2,midband,"midband"); outputfield(3,bbandwidth,"BB%");
以上說明


5 評論