在“ barstate.islast”条件下构建的系列

时间:2018-10-24 14:00:26

标签: tradingview-api pine-script

我有一个简单的脚本,可以在最后的小节中找到需要的小节

//@version=3
study("My Script", overlay=true)
l = na

if barstate.islast
    for i=0 to 100
        if close[i] > open[i] and close[i+1] > open[i+1] and close[i+2] > open[i+2] and na(l)
            l := high[i]

plot(l, color=lime, linewidth=3)

因此所需的值在en的3个位置。是否有可能从所需的小节开始生成并绘制序列。这就是我得到的。enter image description here

但是我需要这一行从发现的值开始,例如:enter image description here

我可以添加偏移量,但它只会将此行移到开头。

//@version=3
study("My Script", overlay=true)
l = na
offsetIndex = na

if barstate.islast
    for i=0 to 100
        if close[i] > open[i] and close[i+1] > open[i+1] and close[i+2] > open[i+2]and na(l)
            offsetIndex := -i
            l := high[i]

plot(l, color=lime, linewidth=3, offset=offsetIndex, show_last=3)

enter image description here

0 个答案:

没有答案