在警示中想加入額外的條件是預估量大於前五日日均量的2.5倍,但加進去之後會沒有交易紀錄

  •   313 
  • 最後發表   豪邁野豬  2025 一月 12
豪邁野豬 發文於   2025/01/11

如題,附上語法,請問是我哪裡寫錯了嗎?

value1 = getField("估計量", "D");

var: ma5(0);

ma5 = average(volume[1], 5);

 

for i = 1 to 12  begin

    if  HB[i] <> -1   and   c  crosses over H[SecondLeftBar]  and  c > H[SecondLeftBar] * 1.02 

and DateDiff(CurrentDate, Date) < 60 and value1 / ma5 >2.5 and volume > 5000  then

        ret = 1;

附加文件

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

(1)你的程式有兩個迴圈,在第一個迴圈使用value1記錄轉折低點的相對位置。更早將估計量賦予value1是無效的。第二個迴圈的value1其實是第二哥迴圈留下來的value1。

(2)你的程式碼有優化空間。你要找的高低點,其實是第一轉折低點左邊第二根K,不需要使用陣列,也不需要跑迴圈。你試試看下列的程式是否可用。

input: Len(100, "最遠K棒數"); // 減少計算範圍
input: Shoulder (8, "N低點", inputkind:=Dict(["3",3],["4",4],["5",5],["6",6],["7",7],["8",8]), quickedit:=true);
setTotalBar(Len);
var: ma5(0);
var: SecondLeftBar(0);

ma5 = average(volume[1], 5);
value1 = getField("估計量", "D");
value2 = swinglowBar(low, Len, Shoulder, Shoulder, 1);
SecondLeftBar = value2 + 2;
if  value2 <> -1 
    and c cross over H[SecondLeftBar] 
    and c > H[SecondLeftBar] * 1.02 
    and DateDiff(CurrentDate, Date[SecondLeftBar]) < 60 
    and value1 / ma5 > 2.5 and volume > 5000  
then ret = 1;

  • 按讚來自於
  • salineyu
豪邁野豬 發文於   2025/01/12

可以了!謝謝許教授!!

發表回覆
Close