pinescript:在交换时区打印酒吧时间

发布于 2025-02-01 00:21:42 字数 671 浏览 3 评论 0原文

在我的pinescript(版本:5)中,我正在尝试添加一个标签,该标签将显示当前条的High,rsi和bar关闭时间。

时间到了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)

In my pinescript (version:5), I am trying to add a label that will display the current bar's high, RSI and the bar closing time.

The time is coming in UTC. How can I convert it to GMT:5:30 or "Asia/Kolkata" timezone?

My code snippet is this:

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)

I have tried out with this also, did not worked:

    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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伊面 2025-02-08 00:21:42

您可以做到这一点:

//@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)))

结果应该是这样:
在此处输入图像描述

You can do this:

//@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)))

Result should be like this:
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文