You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Pine Script v5中如何获取UTC时区小时而非交易所时区小时

在Pine Script v5中获取UTC时区小时数

Pine Script v5内置的hour变量默认返回交易所时区的小时数,要创建指代UTC时区小时数的UTC_hour变量,直接调用hour函数并指定时区参数即可:

//@version=5
indicator("UTC Hour Demo", overlay=true)

// 定义UTC时区的小时变量
UTC_hour = hour(time, "UTC")

// 示例:在图表上实时显示当前UTC小时数
var label utc_label = label.new(bar_index, high, "", color=color.orange, textcolor=color.white)
label.set_text(utc_label, str.format("UTC Hour: %d", UTC_hour))
label.set_xy(utc_label, bar_index, high)

说明

  • hour(time, "UTC")中的第二个参数"UTC"强制函数以UTC时区解析时间,返回0-23的小时数值。
  • 也可以使用ta.hour(time, "UTC"),效果与hour()完全一致,v5中全局函数和ta命名空间下的函数互通。

内容的提问来源于stack exchange,提问作者user3848207

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 05:10:31