請問小幫手VR指標要使用跨月K線和周K線的周期,請問要如何寫,謝謝
VR指標要使用跨月K線和周K線的周期
- 204
- 最後發表 terry5964 2023 九月 19
terry5964
發文於
2023/09/11
XQ小幫手
發文於
2023/09/19
Hello terry5964,
您可以參考系統內建的 VR 函數,並把裡面的close 和 volume 換成想計算的頻率。
舉例來說,要計算週頻率的話可以另外建立一個名為 VR_W 的腳本,並將原本的VR腳本修改為:
SetBarMode(2);
input:Length(numericsimple);
setinputname(1,"天數");
variable:UPV(0),DNV(0),NCV(0);
UPV = SummationIf((getfield("Close", "W") > getfield("Close", "W")[1]), getfield("Volume", "W"), Length);
DNV = SummationIf((getfield("Close", "W") < getfield("Close", "W")[1]), getfield("Volume", "W"), Length);
NCV = SummationIf((getfield("Close", "W") = getfield("Close", "W")[1]), getfield("Volume", "W"), Length);
VR_W = iff(DNV + NCV/2=0,xf_getvalue("W", VR_W, 1) ,100 * (UPV + NCV/2)/(DNV + NCV/2));
這樣就可以計算出週頻率的 VR 值。
1 評論