【问题标题】:PineScript: Print the bar time in exchange timezonePineScript:在交换时区打印条形时间
【发布时间】:2022-09-23 15:53:06
【问题描述】:

在我的 pinescript(版本:5)中,我正在尝试添加一个标签,该标签将显示当前柱的最高价、RSI 和柱关闭时间。

UTC 时间即将到来。如何将其转换为 GMT:5:30 或“亚洲/加尔各答”时区?

我的代码 sn-p 是这样的:

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)

    标签: pine-script algorithmic-trading


    【解决方案1】:

    你可以这样做:

    //@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("\n\nLast 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)))
    

    结果应该是这样的: enter image description here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-09
      • 2012-12-22
      • 2011-01-19
      • 2017-06-07
      • 2011-01-06
      相关资源
      最近更新 更多