條件A成交後12之K棒內成立條件B才顯示訊號該如何寫

  •   84 
  • 最後發表   路人小員工  2025 一月 21
路人小員工 發文於   2025/01/16

目前的寫法如下,條件5成立後,分數為1,當前支K棒分數為1,且條件六成立,

則顯示正式做多訊號。前述部分目前皆能正常的出現訊號。

condition5 = value13 cross over value16 and close > value16;

condition6 = low - value16 <=60;

If condition5 then begin 

count1 +=1;

(value21 = currentbar ;//後來新增的部分)

end;

If count1[1]=1 and condition6 (and currentbar- value21 <=12) then begin

count1 = 0;

plot12(close);//正式做多訊號

end;

之後為了限制得在條件6必須在條件5成立後12支K棒內出現,才算是正式的做多,超過12支K棒就不顯示訊號,

便增加了value21來訊號紀錄K棒的編號,在條件6後新增and currentbar- value21 <=12,

但卻變成沒有任何訊號,請問該怎麼修改才能達成目的呢?

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

試試看下列的程式是否可以。

var: count1(0);
var: intraBarPersist myBar(0);
condition5 = value13 cross over value16 and close > value16;
condition6 = low - value16 <=60;
If condition5 then 
    begin 
        count1 +=1;
        myBar = currentbar ;//後來新增的部分
    end;
If count1[1]=1 and condition6 and (currentbar - myBar <=12) then 
    begin
        count1 = 0;
        plot12(close);//正式做多訊號
    end;

路人小員工 發文於   2025/01/17

照著修改後,還是沒有訊號出現。

感謝許教授的回覆!

虎科大許教授 發文於   2025/01/18

var: intraBarPersist Count1(0);
var: intraBarPersist myBar(0);
condition5 = value13 cross over value16 and close > value16;
condition6 = low - value16 <= 60;
If condition5 and count1 = 0 then 
    begin 
        count1 += 1;
        myBar = currentbar ;//後來新增的部分
    end;
If count1=1 and condition6 and currentbar - myBar <= 12 then 
    begin
        count1 = 0;
        plot12(close);//正式做多訊號
    end;

路人小員工 發文於   2025/01/18

Var: count1(0);

var: intraBarPersist myBar1(0);

count1= 0;//修正這裡才有出現訊號

condition5 = value13 cross over value16 and close > value16;

condition6 = low - value16 <=60;

If condition5 and count1 = 0 then begin 

count1 +=1;

myBar1 = currentbar ;//後來新增的部分

plot11(close);//初步做多訊號

end;

If count1=1 and condition6 and currentbar - myBar1 <= 12 then begin

count1 = 0;

plot12(close);//正式做多訊號

end;

感謝許教授再次回應,為了確認初步條件是否滿足,新增了plot11(close);//初步做多訊號,

依照許教授的修改,結果初步跟正式訊號都不會出現訊號,但後來增加了count1= 0這句,兩個訊號都有出現,

但僅限在同支K符合兩個條件的K棒,如果條件五發生後的幾支K才滿足條件6,還是不會出現訊號。

虎科大許教授 發文於   2025/01/18

(1)你若能提供value13及value16是什麼,將有助於問題解決。

(2)正式做多訊號沒有出現,有可能是條件6的問題。我嘗試分別用5均及20均代表value13及value16,且將60改成5,在台指期5分鐘頻率,就會出現正式做多訊號。

var: intraBarPersist Count1(0);
var: intraBarPersist myBar(0);
if isFirstCall("date") then count1=0;
value13=average(c,5);
value16=average(c,20);
condition5 = value13 cross over value16 and close > value16;
condition6 = low - value16 <= 5;//60;
If condition5 and count1 = 0 then 
    begin 
        count1 = 1;
        myBar = currentbar ;//後來新增的部分
        plot11(low);
    end;
If count1=1 and condition6 and currentbar - myBar <= 12 then 
    begin
        count1 = 0;
        plot12(high);//正式做多訊號
    end;

 

路人小員工 發文於   2025/01/21

謝謝許教授,我再試試看!

發表回覆
Close