只为最后 5 个小节创建一个盒子:一个我无法破解的简单问题

问题描述 投票:0回答:1

我想在最后 5 个小节周围创建一个盒子。我只想在图表上画一个框。

我已经写了这段代码,但它不起作用。

// @version=5
indicator("One Box", overlay=true)

var int left = na
if barstate.islast
    left := bar_index-5

top    = ta.highest(5)
bottom = ta.lowest(5)
box.new(left= left ,top= top, right= bar_index, bottom= bottom)

非常感谢

pine-script pine-script-v5
1个回答
0
投票

我编辑了我的代码,这就是答案:我更改了 if 块的位置

// @version=5
indicator("One Box", overlay=true)


left = bar_index[4]
top    = ta.highest(5)
bottom = ta.lowest(5)

if barstate.islast
    box.new(left= left ,top= top, right= bar_index, bottom= bottom)
© www.soinside.com 2019 - 2024. All rights reserved.