想寫警示腳本,條件1是60分k棒 有站上60sma,條件2是前一根k棒必需是跌破60分sma

  •   36 
  • 最後發表   燒腦  4 週前
燒腦 發文於   2026/07/14

條件1與條件2同時滿足,才跳出警示通知(策略雷達)

請問腳本這樣寫,可以嗎

謝謝

 

 

 

 

 

 

SetTotalBar(80);

var: maValue(0), isMatch(false);

maValue = Average(Close, 60);

if Close[1] < maValue[1] and Close > maValue then 

    isMatch = true 

else 

    isMatch = false;

 

if isMatch = true then 

begin

    ret = 1;

    retmsg = "60分K棒收盤站上60SMA!當前價:" + NumToStr(Close, 2) + ",均線價:" + NumToStr(maValue, 2);

end;

虎科大許教授 發文於   2026/07/14

不需要使用變數isMatch。

SetTotalBar(80);
var: maValue(0);

maValue = Average(Close, 60);
if Close[1] < maValue[1] and Close > maValue then 
    begin
        ret = 1;
        retmsg = "60分K棒收盤站上60SMA!當前價:" + NumToStr(Close, 2) + ",均線價:" + NumToStr(maValue, 2);
    end;

發表回覆
Close