如何在pinescript中获取特定时间段的最高价和最低价
How to get the highest high and the lowest low of specific timeframe in pinescript
我目前被困在 pine 脚本中,试图获得特定时间范围内的最高价和最低价,比如说 0000 到 0400,当天
pdh = security(tickerid, 'D', high)
pdl = security(tickerid, 'D', low)
这里为我们提供了当天的最高价和最低价。
请注意,这是使用 pine 脚本 V4。
//@version=4
study("Highest of first 4 bars in timezone GMT-5, different from tz of symbol")
t = timestamp("GMT-5", year, month, dayofmonth, hour, minute, second)
highest = -1.0
if hour(t) > 4
highest := nz(highest[1], -1)
else
for i = 0 to 1000
if na(t[i]) or hour(t[i]) > 4
break
highest := max(highest, high[i])
plot(highest)
我认为它看起来应该类似于上面的代码。也许它的工作方式并不完全符合我的预期(我没有调试也没有测试它),但我想它足以让你自己实现所需的功能。
我目前被困在 pine 脚本中,试图获得特定时间范围内的最高价和最低价,比如说 0000 到 0400,当天
pdh = security(tickerid, 'D', high)
pdl = security(tickerid, 'D', low)
这里为我们提供了当天的最高价和最低价。 请注意,这是使用 pine 脚本 V4。
//@version=4
study("Highest of first 4 bars in timezone GMT-5, different from tz of symbol")
t = timestamp("GMT-5", year, month, dayofmonth, hour, minute, second)
highest = -1.0
if hour(t) > 4
highest := nz(highest[1], -1)
else
for i = 0 to 1000
if na(t[i]) or hour(t[i]) > 4
break
highest := max(highest, high[i])
plot(highest)
我认为它看起来应该类似于上面的代码。也许它的工作方式并不完全符合我的预期(我没有调试也没有测试它),但我想它足以让你自己实现所需的功能。