交易视图/ Pine脚本

时间:2020-04-18 13:10:17

标签: pine-script

我正在尝试获得10天或20天(天数=输入)的平均最高价/最低价。为此,我使用for循环和安全性(syminfo.tickerid,“ D”,高)。但是我不能在for循环中使用安全性。 因此,如何才能达到所有高点并除以天数。天数是动态的。

1 个答案:

答案 0 :(得分:1)

在Pine中,for循环是不必要的,效率很低。首选非重涂版本,请参见此出版物以获得解释:How to avoid repainting when using security() - PineCoders FAQ

//@version=4
study("", "", true)
hlMa = sma(hl2, input(10))

repainting = security(syminfo.tickerid, 'D', hlMa)
plot(repainting)

// More reliable.
noRepainting = security(syminfo.tickerid, 'D', hlMa[1], lookahead = barmerge.lookahead_on)
plot(noRepainting, "", color.orange, 6, transp = 70)

enter image description here