如何跨週期讀取自製的 VWAP 指標?

  •   38 
  • 最後發表   chclee1234  2 週前
chclee1234 發文於   2026/06/02

這是我們目前 VWAP:

// ── VWAP 計算核心 ──

 

// 典型價

tp_val = (High + Low + Close) / 3;

 

// 重置:08:30 / 15:00 / 夜盤自訂時間

if (Time >= 083000 and Time[1] < 083000)

or (Time >= 150000 and Time[1] < 150000) then

begin

    total_vol = Volume;

    total_amt = tp_val * Volume;

end

else

begin

    if (vwap_reset_time > 0)

       and (Time >= vwap_reset_time)

       and (Time[1] < vwap_reset_time) then

    begin

        total_vol = Volume;

        total_amt = tp_val * Volume;

    end

    else

    begin

        total_vol = total_vol + Volume;

        total_amt = total_amt + (tp_val * Volume);

    end;

end;

 

if total_vol <> 0 then

 

    _vwap = total_amt / total_vol;



這個在 1 分 K 已經可以運作了,在 5 分 K 也可以運作,但是如何在一分 K 去讀取 5 分 K 的 VWAP?

謝謝.

虎科大許教授 發文於   2026/06/02

雖然下列腳本可1分鐘跨5分鐘,但既然是指標,我會建議自訂跨頻率函數處理。

If barfreq <> "Min" or barinterval <> 1 then raiseRunTimeError("限用1分鐘");
// 典型價
tp_val = (GetField("最高價", "5") + GetField("最低價", "5") + GetField("收盤價", "5")) / 3;
// 重置:08:30 / 15:00 / 夜盤自訂時間
if (Time >= 083000 and Time[1] < 083000)
    or (Time >= 150000 and Time[1] < 150000) then
    begin
        total_vol = GetField("成交量", "5");
        total_amt = tp_val * GetField("成交量", "5");
    end
else
    begin
        if (vwap_reset_time > 0)
            and (Time >= vwap_reset_time)
            and (Time[1] < vwap_reset_time) then
            begin
                total_vol = GetField("成交量", "5");
                total_amt = tp_val * GetField("成交量", "5");
            end
        else
            begin
                total_vol = total_vol +GetField("成交量", "5");
                total_amt = total_amt + (tp_val * GetField("成交量", "5"));
            end;
    end;
if total_vol <> 0 then
    _vwap = total_amt / total_vol;

發表回覆
Close