使用tradingview的安全功能,如何平滑缺口?
我正在尝试在 15 分钟图表上绘制多个时间范围 EMA,这是我的代码。
//@version=5
indicator(title='higher tf', overlay=true)
// 4 hr
show_4h = input(title='Show 4 hour', defval=true, group = "4 HOUR")
show_ema20_4 = input(title='Show 20 EMA of 4 hour', defval=true, group = "4 HOUR")
ema20_4_period = input(title='20 EMA of 4 hour Period', defval=20, group = "4 HOUR")
show_ema50_4 = input(title='Show 50 EMA of 4 hour', defval=true, group = "4 HOUR")
ema50_4_period = input(title='50 EMA of 4 hour Period', defval=50, group = "4 HOUR")
show_ema100_4 = input(title='Show 100 EMA of 4 hour', defval=true, group = "4 HOUR")
ema100_4_period = input(title='100 EMA of 4 hour Period', defval=100, group = "4 HOUR")
show_ema200_4 = input(title='Show 200 EMA of 4 hour', defval=true, group = "4 HOUR")
ema200_4_period = input(title='200 EMA of 4 hour Period', defval=200, group = "4 HOUR")
ema20_4 = request.security(syminfo.tickerid, '360', ta.ema(close, ema20_4_period),lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_on)
ema50_4 = request.security(syminfo.tickerid, '360', ta.ema(close, ema50_4_period),lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_on)
ema100_4 = request.security(syminfo.tickerid, '360', ta.ema(close, ema100_4_period), lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_on)
ema200_4 = request.security(syminfo.tickerid, '360', ta.ema(close, ema200_4_period), lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_on)
plot(show_4h ? show_ema20_4 ? ema20_4 : na : na, title='20 EMA 4 hour')
plot(show_4h ?show_ema50_4?ema50_4: na : na, title="50 EMA 4 hour")
plot(show_4h ?show_ema100_4?ema100_4: na : na, title="100 EMA 4 hour")
plot(show_4h ?show_ema200_4?ema200_4: na : na, title="200 EMA 4 hour")
绘图时,图表上有步骤。
然而,当我使用内置指标并将时间范围更改为 4 小时时,该线完全平滑。
这就是它的样子。
红线是内置指标,蓝线是我的指标。
怎样才能让线条流畅呢?
I am trying to plot multiple timeframe EMA on 15 min chart, this is my code.
//@version=5
indicator(title='higher tf', overlay=true)
// 4 hr
show_4h = input(title='Show 4 hour', defval=true, group = "4 HOUR")
show_ema20_4 = input(title='Show 20 EMA of 4 hour', defval=true, group = "4 HOUR")
ema20_4_period = input(title='20 EMA of 4 hour Period', defval=20, group = "4 HOUR")
show_ema50_4 = input(title='Show 50 EMA of 4 hour', defval=true, group = "4 HOUR")
ema50_4_period = input(title='50 EMA of 4 hour Period', defval=50, group = "4 HOUR")
show_ema100_4 = input(title='Show 100 EMA of 4 hour', defval=true, group = "4 HOUR")
ema100_4_period = input(title='100 EMA of 4 hour Period', defval=100, group = "4 HOUR")
show_ema200_4 = input(title='Show 200 EMA of 4 hour', defval=true, group = "4 HOUR")
ema200_4_period = input(title='200 EMA of 4 hour Period', defval=200, group = "4 HOUR")
ema20_4 = request.security(syminfo.tickerid, '360', ta.ema(close, ema20_4_period),lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_on)
ema50_4 = request.security(syminfo.tickerid, '360', ta.ema(close, ema50_4_period),lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_on)
ema100_4 = request.security(syminfo.tickerid, '360', ta.ema(close, ema100_4_period), lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_on)
ema200_4 = request.security(syminfo.tickerid, '360', ta.ema(close, ema200_4_period), lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_on)
plot(show_4h ? show_ema20_4 ? ema20_4 : na : na, title='20 EMA 4 hour')
plot(show_4h ?show_ema50_4?ema50_4: na : na, title="50 EMA 4 hour")
plot(show_4h ?show_ema100_4?ema100_4: na : na, title="100 EMA 4 hour")
plot(show_4h ?show_ema200_4?ema200_4: na : na, title="200 EMA 4 hour")
on plotting, there are steps on the graph.
However, when I use the in-built indicator and change the timeframe to 4 hour that line is completely smooth.
This is how it looks like.
the red line is the in-built indicator and the blue line is my indicator.
How can I make the line smooth?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需将“
timeframe_gaps=true
”添加到您的indicator()
中即可。如果您想向
strategy()
添加时间范围间隙,则必须向变量添加“barmerge.gaps_on
”。You can just add "
timeframe_gaps=true
" to yourindicator()
.If u want to add timeframe gaps to a
strategy()
you have to add "barmerge.gaps_on
" to your variable.您面临这个问题,因为您将指数移动平均线“EMA”的时间范围值设为
360
,这意味着6 小时
,因此一旦您打开任何图表,EMA 将针对6小时,您应该将其更改为timeframe.period
,使其成为类似于时间范围时间范围.periodYou face this problem, because you make the values of timeframe for exponential moving average "EMA" is
360
which mean6 hours
so once you open any chart the EMA will be for 6 hours, you should to change it totimeframe.period
to be the EMA similar to timeframe timeframe.period