【发布时间】:2019-09-10 16:34:59
【问题描述】:
为了回测其中一个策略,我需要检索过去 5 天的 day HIGH 值,这应该适用于任何图表分辨率。
当图表分辨率为 DAILY 时,以下代码可以正常工作,但如果我将图表分辨率更改为较低的时间范围,即 15 分钟或 30 分钟,我会在第 2、3、4 和 5 天获得同一天的最高值。
理想情况下,安全功能输出不应受到图表分辨率变化的影响,并且输出应该是不同的值。
// @version=4
study("Plot high prices for lat 5 days")
day_high = security(syminfo.tickerid, "D", high, false)
day1 = day_high[1]
day2 = day_high[2]
day3 = day_high[3]
day4 = day_high[4]
day5 = day_high[5]
//Check whether this is the first bar of the day? If yes, display highs for last 5 days
t = time("1440", session.regular)
is_first = na(t[1]) and not na(t) or t[1] < t
if (is_first)
label.new(bar_index, na, tostring(day5) + ", " + tostring(day4) + ", " + tostring(day3) + ", " + tostring(day2) + ", " + tostring(day1), style=label.style_cross, yloc=yloc.abovebar)
【问题讨论】:
标签: pine-script