pine其他时间段的计算

Calculations on other time periods in pine

我希望能够在 1m 周期图表上绘制 45m 周期的 Ichimoku 云,并针对某些 45m 条件发出信号警报。使用 1m 周期的原因是为追踪止损应用自定义逻辑以生成尽可能接近报价的警报。

我知道创建云的逻辑:

//Ichimoku input Logic
conversionPeriods = input(9, minval=1, title="Conversion Line Periods"),
basePeriods = input(26, minval=1, title="Base Line Periods")
laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Periods"),
displacement = input(26, minval=1, title="Displacement")

//Ichimoku function Logic
donchian(len) => avg(lowest(len), highest(len))

//Ichimoku line Logic
tenkanLine = donchian(conversionPeriods)
kijunLine = donchian(basePeriods)
leadLine1 = avg(tenkanLine, kijunLine)
leadLine2 = donchian(laggingSpan2Periods)

如何在 1m 周期上实现此逻辑,但使用 45m 周期数据用于云?我想一个可能的解决方案与使用 security(tickerId, 45, close) 有关,但我不确定如何。

你快到了。您现在可以通过安全功能请求不同的期限:

plot(security(tickerid, '45', tenkanLine))
plot(security(tickerid, '45', kijunLine))
plot(security(tickerid, '45', leadLine1))
plot(security(tickerid, '45', leadLine2))

这是一个带有 sma 图的简单示例。

sma_expr = sma(close, 14)
sma_45_period = security(tickerid, '45', sma_expr)

plot(sma_45_period)