Ehlers NonLinear Filter [CC]The NonLinear Filter was created by John Ehlers and this one of his more unknown filters that work very well as a trendline and moving average. This is one of my favorites along with the instantenous trendlines that he created. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like to see me publish scripts for!
Nonlinear
Garch (1,1) ModelThe Garch (General Autoregressive Conditional Heteroskedasticity) model is a non-linear time series model that uses past data to forecast future variance.
The Garch (1,1) formula is:
Garch = (gamma * Long Run Variance) + (alpha * Squared Lagged Returns) + (beta * Lagged Variance)
The gamma, alpha, and beta values are all weights used in the Garch calculations. According to RiskMetrics by JP Morgan, the optimal beta weight is 0.94, but this figure is highly disputed in the academic realm. The biggest problem academics and economists have with the 0.94 figure is that JP Morgan used monthly data to come to this number, meaning it does not take other time frames into account. Because of the disputed nature of what beta should be, this script will automatically calculate the beta weight for you in real time, taking into account the time frame you're using and realized variance, by using the Minimum Sum of Squared Errors Method.
The gamma and alpha weights are also calculated for you.
Even though the Garch formula provides today's projected variance, today's projected deviation is also calculated. This is done by taking the square root of Garch.
Additionally, if you want to project the variance or deviation for as many days forward as you want, you can.
In order to project the variance and deviation beyond just today, these equations are used:
Projected Variance = Long Run Variance + (alpha + beta)^Days Forward * (Garch - Long Run Variance)
Projected Deviation = sqrt(Projected Variance)
How to use this model:
1st. Decide the type of data you want: Projected Variance in % or Projected Deviation in %.
2nd. Decide how many days you want projected forward. If you input 0, you will get projections for today. If you input 1, you will get projections for tomorrow, and etc.
That's it. If you have any further questions, I left detailed comments in the code explaining each step, as best as I could.