我正在尝试获取高/低/收盘价的序列数据,以进行特定日期范围的每周数据透视。.
示例代码:
//
study(title="Pivot Points", shorttitle="Weekly-Levels", overlay=true)
// defaultTimeFrame = ((isintraday) ? "D" : ((isdaily) ? "W" : ((isweekly) ? "M" : "3M")))
// inputTimeFrame = input(title="Time Frame", type=string, defval="Default")
// chosenTimeFrame = (inputTimeFrame == "Default") ? defaultTimeFrame : inputTimeFrame
startDate = input(title="Start Date", type=integer, defval=1, minval=1, maxval=31)
startMonth = input(title="Start Month", type=integer, defval=2, minval=1, maxval=12)
startYear = input(title="Start Year", type=integer, defval=2020, minval=2020, maxval=2100)
endDate = input(title="End Date", type=integer, defval=30, minval=1, maxval=31)
endMonth = input(title="End Month", type=integer, defval=6, minval=1, maxval=12)
endYear = input(title="End Year", type=integer, defval=2020, minval=1800, maxval=2100)
weekly_cpr = (time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0)) and (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))
getSeries(e) => security(tickerid, weekly_cpr, e, lookahead=barmerge.lookahead_on)
H = getSeries(high[1])
L = getSeries(low[1])
C = getSeries(close[1])
// Main Pivot
P = (H + L + C) / 3
我正在犯错误。
Processing script...
line 40: Cannot call `security` with arguments (string, series[bool], series, literal bool, literal bool, literal string); available overloads: security(string, string, series[integer], const bool, const bool, string) => series[integer]; security(string, string, series, const bool, const bool, string) => series; security(string, string, series[bool], const bool, const bool, string) => series[bool]; security(string, string, series[color], const bool, const bool, string) => series[color];
让我知道该如何处理?
答案 0 :(得分:0)
这是实现目标的一种简单方法。我们在图表的上下文中定义计算和条件,然后将其发送到security()
以便在其HTF上下文中进行评估。 Calcs不会重绘:
//@version=4
study(title="Pivot Points", shorttitle="Weekly-Levels", overlay=true)
startDate = input(title="Start Date", defval=1, minval=1, maxval=31)
startMonth = input(title="Start Month", defval=2, minval=1, maxval=12)
startYear = input(title="Start Year", defval=2020, minval=2020, maxval=2100)
endDate = input(title="End Date", defval=30, minval=1, maxval=31)
endMonth = input(title="End Month", defval=6, minval=1, maxval=12)
endYear = input(title="End Year", defval=2020, minval=1800, maxval=2100)
weekly_cpr = (time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0)) and (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))
H = high
L = low
C = close
P = (H + L + C) / 3
// We send both the date constraint and the request for the complete, calculated data through `security()`,
// so that all that is evaluated in the context of `security()`'s context.
pHtf = security(syminfo.tickerid, "W", weekly_cpr ? P[1] : na, lookahead = barmerge.lookahead_on)
plot(pHtf, "pHtf", color.blue, 1, plot.style_circles)