自動計算「多空回本價」指標

  • 自動計算「多空回本價」指標

    Posted by YAMAHA732 on 2026/05/06 at 17:49

    不知道先前有沒有人寫過, 我猜或許有? 若有重覆,再請版主告知後撤下來。

    我自己和其他有在做當沖的親朋好友,想在主畫面看到當沖股票回本tick 數, 所以我就寫了這個指標.

    有些時候只是心血來潮想當沖不一定有執行自動交易程式,看盤時突然發現該股票有機可趁,有這個就不用心算,用券商APP下單之後看到tick數操作它們的停利停損UI少了一點反應時間。 有附上2張均豪、聯電的5月6日5分K做範例。

    P.S. 我是用4折手續費去設數值的,若有錯誤歡迎指正。

    // 指標名稱:雙向當沖回本指標

    var: tick_val(0), need_ticks(0), long_price(0), short_price(0);

    // 1. 判斷 Tick 單位

    if Close < 10 then tick_val = 0.01

    else if Close < 50 then tick_val = 0.05

    else if Close < 100 then tick_val = 0.10

    else if Close < 500 then tick_val = 0.50;

    // 2. 依照你的回本規則判斷檔數 (僅處理 300 元以下)

    if Close >= 10 and Close < 30 then need_ticks = 2

    else if Close >= 30 and Close < 45 then need_ticks = 3

    else if Close >= 45 and Close < 50 then need_ticks = 4

    else if Close >= 50 and Close < 60 then need_ticks = 2

    else if Close >= 60 and Close < 90 then need_ticks = 3

    else if Close >= 90 and Close < 100 then need_ticks = 4

    else if Close >= 100 and Close < 150 then need_ticks = 1

    else if Close >= 150 and Close < 200 then need_ticks = 2

    else if Close >= 200 and Close <= 300 then need_ticks = 2

    else need_ticks = 0;

    // 3. 計算雙向回本目標價

    if need_ticks > 0 then

    begin

    long_price = Close + (tick_val * need_ticks); // 做多回本價

    short_price = Close – (tick_val * need_ticks); // 做空回本價

    end

    else

    begin

    long_price = 0;

    short_price = 0;

    end;

    // 4. 輸出數值

    if long_price > 0 then

    begin

    Plot1(long_price, “做多回本價”);

    Plot2(short_price, “做空回本價”);

    Plot3(need_ticks, “需跳檔數”);

    end;

    YAMAHA732 回覆 1 小時, 11 分鐘 之前 1 會員 · 0 則回應
  • 0 則回應

尚未有任何回應

Log in to reply.