布林通道選股語法

  •   18 
  • 最後發表   隔壁的老王  5 小時前
隔壁的老王 發文於   2025/10/14

請問小編,我寫了一個語法,要得到今日的日K、周K及月K上布林的UB2.00大於昨日的UB2.00,今日的下布林LB2.00小於昨日的LB2.00,目前跑出來只有日K及周K正確,月K的部分不對,想請小編幫我看一下哪裡出錯,謝謝

 

Value1=close;

Value2=getfield("Close", "W");

Value3=getfield("Close", "M");

Value4=BollingerBand(Close,20,2);

Value5=BollingerBand(Close,20,-2);

Value6=BollingerBand(Value2,20,2);

Value7=BollingerBand(Value2,20,-2);

Value8=BollingerBand(Value3,20,2);

Value9=BollingerBand(Value3,20,-2);

Value10=AVerage(close,20);

Value11=AVerage(Value2,20);

Value12=AVerage(Value3,20);

 

IF Value1 > Value1[1] and Value1 > Value1[2] and Value1 > Value10

and Value4 > Value4[1] and Value5 < Value5[1] 

and Value2 > Value2[1] and Value2 > Value2[2] and Value2 > Value11

and Value6 > Value6[1] and Value7 < Value7[1]

and Value3 > Value3[1] and Value3 > Value3[2] and Value3 > Value12

and Value8 > Value8[1] and Value9 < Value9[1]

and Volume > 1000

then ret=1;

排序方式: 標準 | 最新
虎科大許教授 發文於   2025/10/14

(1)你需要先釐清,是

月K上布林的UB2.00大於「昨日」的月K上布林的UB2.00,

還是

月K上布林的UB2.00大於「前一根」月K上布林的UB2.00

(2)跨頻率處理,應盡可能避免用變數處理,以免造成邏輯錯誤。

隔壁的老王 發文於   2025/10/14

我需要的是月K上布林的UB2.00大於「前一根」月K上布林的UB2.00。

虎科大許教授 發文於   2025/10/14

setBarFreq("D");
setBackBar(21,"M");
condition1=c>c[1] and c>c[2] and c>Average(close,20);
condition2=BollingerBand(Close,20,2)>BollingerBand(Close[1],20,2) 
            and BollingerBand(Close,20,-2)<BollingerBand(Close[1],20,-2);
condition3=getfield("Close", "W")>getfield("Close", "W")[1] 
            and getfield("Close", "W")>getfield("Close", "W")[2]
            and getfield("Close", "W")>Average(getfield("Close", "W"),20);
condition4=BollingerBand(getfield("Close", "W"),20,2)>BollingerBand(getfield("Close", "W")[1],20,2)
            and BollingerBand(getfield("Close", "W"),20,-2)<BollingerBand(getfield("Close", "W")[1],20,-2);
condition5=getfield("Close", "M")>getfield("Close", "M")[1] 
            and getfield("Close", "M")>getfield("Close", "M")[2]
            and getfield("Close", "M")>Average(getfield("Close", "M"),20);
condition6=BollingerBand(getfield("Close", "M"),20,2)>BollingerBand(getfield("Close", "M")[1],20,2)
            and BollingerBand(getfield("Close", "M"),20,-2)<BollingerBand(getfield("Close", "M")[1],20,-2);
if Volume > 1000 and condition1 and condition2 and condition3
    and condition4 and condition5 and condition6
then ret=1;

隔壁的老王 發文於   2025/10/14

感激不盡!

隔壁的老王 發文於   2025/10/15

許教授您好,我跑完後的結果一直顯示系統錯誤,是不是哪裡出問題??

虎科大許教授 發文於   2025/10/15

是不是你使用免費版?我測試是OK的?

隔壁的老王 發文於   2025/10/15

對,我是用免費版,還是說還要等收盤後再找會比較好?

虎科大許教授 發文於   2025/10/15

這應該與收不收盤無關,而與權限有關。你只能購買盤後選股模組才可使用相關功能。

隔壁的老王 發文於   2025/10/15

原來如此,感謝您

發表回覆
Close