如何显示栏内值时使用较低的时间框架?



我想在Pinescript中使用较低时间框架时显示内栏的最后三个接近值。我试过的代码不是我需要的。

我使用15分钟图表,我需要接近3分钟蜡烛。它在数组中生成5个栏内关闭值。我只需要最后两个酒吧的蜡烛关闭。

我的代码生成=>数组{1,2,3,4,5}和数组{6,7,8,9,10}

我需要的代码=>"1";在一个盒子和"2"在另一个方框

indicator('Test W1', overlay=true, shorttitle='Test W1', precision=1)
Close(s) => request.security_lower_tf(s, "3", close)
Close1(s) => request.security_lower_tf(s, "3", close[1])
var table top_boxes = table.new(position.bottom_center, 6, 6, color.black, border_color = color.white)
AR = Close('RELIANCE')
BR = Close1('RELIANCE')
table.cell(top_boxes, 0, 0, text = str.tostring(AR), bgcolor=color.new(color.green, 0), text_color =color.white, height=10, width = 35)
table.cell(top_boxes, 0, 1, text = str.tostring(AR), bgcolor=color.new(color.green, 0), text_color =color.white, height=10, width = 35)

我认为这是你想要的。这将给你最后的23分钟结束时间。你可以调整关闭你想通过改变数组索引号,唯一的问题是,当一个新的15分钟的蜡烛打开,你会得到一个数组越界错误,直到有一个3分钟的蜡烛关闭

//@version=5
indicator("lower time frame data", overlay = true)
var table top_boxes = table.new(position.bottom_center, 6, 6, color.black, border_color = color.white)
float[] ltfdata = request.security_lower_tf(syminfo.tickerid, '3', close)
float[] newArray = array.new<float>()
if array.size(ltfdata) > 0
for i = 0 to array.size(ltfdata) - 1 
newArray.unshift(ltfdata.get(i))
if barstate.islast
table.cell(top_boxes, 0, 0, text = str.tostring(newArray.get(1), format.mintick), bgcolor=color.new(color.green, 0), text_color =color.white, height=10, width = 35)
table.cell(top_boxes, 0, 1, text = str.tostring(newArray.get(2), format.mintick), bgcolor=color.new(color.green, 0), text_color =color.white, height=10, width = 35)

最新更新