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?