PineScript:打印交换时区的酒吧时间



在我的pinescript(版本:5)中,我试图添加一个标签,将显示当前酒吧的高,RSI和酒吧关闭时间。

时间以UTC格式到来。我如何将其转换为GMT:5:30或"亚洲/加尔各答"?时区?

我的代码片段是这样的:
if (ta.crossunder(rsi, rsiOSLimit))
label.new(bar_index, high, str.tostring(high, "#") + ":" + str.tostring(rsi, "#") + ":" + str.format("{0,time,short}", time), color=color.black, textcolor=color.white, yloc= yloc.price)

我也试过这个,没有工作:

label.new(bar_index, high, str.tostring(high, "#") + ":" + str.tostring(rsi, "#") + ":" + str.format("{0,time,short}", time_close(timeframe.period, syminfo.session, syminfo.timezone)), color=color.black, textcolor=color.white, yloc= yloc.price)

你可以这样做:

//@version=5
strategy('Opening high/low', overlay=true)

//label.new(bar_index, high, tostring(time_close - timenow))

printTable(txt) =>
var table t = table.new(position.middle_right, 1, 1)
table.cell(t, 0, 0, txt, text_halign = text.align_right, bgcolor = color.yellow)
printTable(
str.format("Last bar''s open time EXCHANGE: {0,date,HH:mm:ss yyyy.MM.dd}", time(timeframe.period, syminfo.session, syminfo.timezone)) +
str.format("nLast bar''s close time EXCHANGE: {0,date,HH:mm:ss yyyy.MM.dd}", time_close(timeframe.period, syminfo.session, syminfo.timezone)))

结果应该是这样的:输入图片描述

最新更新