0
votes

If I run this script

Custom_time_frame_close = security(syminfo.tickerid, '12M', close)
plot(Custom_time_frame_close)

the plot will have many horizontal lines like such

enter image description here

How can remove the horizontal lines so that it looks identical to if I was using the 1 year resolution (without changing to the 1 year resolution)?

1

1 Answers

0
votes

When you call the yearly close dataseries it contains every new value at the end of the year(close) and has no information about the intra-year changes.

The easiest workaround is to smooth the dataseries with Simple Moving Average:

//@version=4
study("")
Custom_time_frame_close = security(syminfo.tickerid, '12M', close)
plot(Custom_time_frame_close)

Smoothed_custom_time_frame_close = sma(Custom_time_frame_close, 50)
plot(Smoothed_custom_time_frame_close, color = color.red) 

Otherwise instead of the security call you'll have to calculate the intra-year values from the current timeframe's data.