碰到漲停後的回檔

  •   99 
  • 最後發表   StockS  2023 七月 07
StockS 發文於   2023/07/05

小幫手你好

我想要寫一個計算股票當天碰到漲停,後來回檔後又回漲停,用1分K計算當天的回檔幅度

我用交易腳本寫去print,但不知道為什麼print出來都是不對的

謝謝小幫手

var: intraBarPersist _stop(false);
var: last_date (0);

if date <> last_date then begin
    _stop = false;
    last_date = date;
    value2 = 0;
    value1 = 5000;
end;


if  currentTime <= 132400
    and condition1 and condition2
    and  high = getField("漲停價", "D") 
    and _stop = false
then begin
    value2 = getBarOffset(currentdate, currentTime);
    _stop = true;
end;


for value3 = value2 +1 to  getBarOffset(currentdate, 132400)
begin
    if low[value3] < value1 then value1 = low[value3];
end;    


if currenttime >= 132459 and c = getField("漲停價", "D") and value1 < 5000 
    then 
    print(file("C:\Users\Mionnibal\Documents\test.txt"),
    currentDate, symbol, "back%", (VALUE1 - getField("漲停價", "D"))/ getField("漲停價", "D"));

XQ小幫手 發文於   2023/07/07

Hello StockS,

 

您的腳本中並沒有撰寫 condition1 和 condition2,可能是此原因造成。

小幫手會建議您使用變數紀錄當日是否達成過漲停價後又回檔,並用另一個變數紀錄達成後的最低價,就可以計算回檔幅度。

舉例來說:

if issessionfirstbar then begin

    value1 = 0;

    value2 = 0;

    value3 = 0;

    end;

 

if (high = getfield("漲停價", "D") and close < getfield("漲停價", "D")) or (high[1] = getfield("漲停價", "D") and close < getfield("漲停價", "D")) then begin    //開始回檔

    value1 += 1;

    value2 = low;    //記錄回檔最低價

    end;

 

if value1 = 1 and low < value2 and high <> getfield("漲停價", "D") then begin

    value2 = low;    //若回檔有更低價就更新

    end;

 

if value2 <> 0 then value3 = getfield("漲停價", "D") - value2;    //計算回檔與漲停價的差距

發表回覆
Close