如何在脚本中制作多个时间框架一目均衡指标?

  • 本文关键字:框架 时间 脚本 pine-script
  • 更新时间 :
  • 英文 :


使用一目均衡策略的我希望在同一图表上显示来自不同时间框架的共性。最聪明的方法是什么?我想出了如何用不同的时间框架制作2个ema,使用如何避免重画和使用安全功能& &;更高时间范围数据

然而,我不知道如何使用相同的技术来制作一目云。什么好主意吗?


//@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本身的一目表指示代码并将其修改如下,它就可以工作了:


//@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))

最新更新