如何获取特定日期的酒吧索引

时间:2020-07-22 02:07:57

标签: pine-script

我是松树脚本的新手。 我想比较2个特定日期的价格。

但是我如何在特定日期获取bar_index?

预先感谢

2 个答案:

答案 0 :(得分:0)

timestamp函数将返回指定日期和时间的UNIX时间。

如果以毫秒为单位的时间比1月3日更长,请抓住低点。 对于盘中,请在时间戳功能中指定分钟。

//@version=4
study("low on specific date")

specificDate = time >= timestamp(2019, 1, 3, 00, 00)

var float lowOnDate= na
if specificDate and not specificDate[1]
    lowOnDate := low
plot(lowOnDate)

答案 1 :(得分:0)

假设您想在 6 月 30 日凌晨 3 点 GMT+8 的 1H 时间范围内获取蜡烛数据

x1 = (time - timestamp("GMT+8",2021,06,30,03,00,00))/3600000

candleHigh = high[x1]

如果您在不同的 TF 中,只需将其转换为毫秒