
[英]How to read in 2 timeframe data of 1 indicator in PineScript?
[英]how to make multiple timeframe ichimoku indicator in pinescript?
我使用 ichimoku 策略,希望在同一张图表上显示来自不同时间范围的 kumos。 最聪明的方法是什么? 我想出了如何使用如何避免重绘和使用安全 Function 和更高时间范围数据来制作具有不同时间范围的 2 个 ema
但是,我无法弄清楚如何使用相同的技术来制作 ichimoku 云。 有任何想法吗?
//@version=5
indicator('Lesson 9 multi time frames, no repaint ', overlay=true)
// what data should i feed it?
Midpoint(src,len,) =>
math.avg(ta.highest(src, len), ta.lowest(src, len))
res = input.timeframe(title='Timeframe', defval='D')
// Create non-repainting security function
rp_function(_symbol, _res, _src) =>
request.security(_symbol, _res, _src[barstate.isrealtime ? 1 : 0])
// Get higher timeframe data not the data i need. (from video)
htfHigh = rp_function(syminfo.tickerid, res, high)
htfLow = rp_function(syminfo.tickerid, res, low)
// just plotting some higher time frame
plot(htfHigh, color=color.new(color.red, 0), title='HTF high')
plot(htfLow, color=color.new(color.blue, 0), title='HTF low')
// ichimoku daily
D_TK = Midpoint(source, 9)
D_KJ = Midpoint(source,26)
D_CK = close
// senkou a and b
D_SKA = math.avg(TK, KJ)
D_SKB = Midpoint(52)
欢迎任何想法:)
使用 TV 本身的 Ichimoku 指标代码并按如下方式对其进行修改,它可以正常工作:
//@version=5
indicator(title="Ichimoku Cloud with the required TF", shorttitle="Ichimoku", overlay=true)
close_req_tf = request.security(syminfo.tickerid, '240', close)
use_price = close_req_tf
conversionPeriods = input.int(9, minval=1, title="Conversion Line Length")
basePeriods = input.int(26, minval=1, title="Base Line Length")
laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length")
displacement = input.int(26, minval=1, title="Lagging Span")
donchian(len) => math.avg(ta.lowest(use_price, len), ta.highest(use_price, len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
plot(conversionLine, color=#2962FF, title="Conversion Line")
plot(baseLine, color=#B71C1C, title="Base Line")
plot(close, offset = -displacement + 1, color=#43A047, title="Lagging Span")
p1 = plot(leadLine1, offset = displacement - 1, color=#A5D6A7,
title="Leading Span A")
p2 = plot(leadLine2, offset = displacement - 1, color=#EF9A9A,
title="Leading Span B")
plot(leadLine1 > leadLine2 ? leadLine1 : leadLine2, offset = displacement - 1, title = "Kumo Cloud Upper Line", display = display.none)
plot(leadLine1 < leadLine2 ? leadLine1 : leadLine2, offset = displacement - 1, title = "Kumo Cloud Lower Line", display = display.none)
fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.