The Forecast Oscillator is a technical indicator that compares a security close price to its time series forecast. The time series forecast function name is "tsf" and it calculates the projection of the price trend for the next bar.
The Forecast Oscillator and therefore the time series forecast are based on linear regression . The time series forecast indicator is equal to the sum of two other indicators: the linear regression (LinearReg) and the linear regression slope (LinearReg_Slope).
Code: Select all
study("Forecast Oscillator", overlay=false)
src = input(close)
len = input(defval=14, minval=1, title="Length")
lrc = linreg(src, len, 0)
lrc1 = linreg(src,len,1)
lrs = (lrc-lrc1)
TSF = linreg(src, len, 0)+lrs
fosc=100*(src-TSF[1])/src
col12 = fosc > fosc[1]
col32 = fosc < fosc[1]
color2 = col12 ? #21C400 : col32 ? #960012 : color.blue
plot(fosc, color = color2,linewidth=2, title = "TSF")
hline(0, linestyle=2, color=color.blue)