OPEN-SOURCE SCRIPT

Fast/Slow Degree Oscillator

Introduction

The estimation of a least squares moving average of any degree isn't an interesting goal, this is due to the fact that lsma of high degrees would highly overshoot as well as overfit the closing price, which wouldn't really appear smooth. However i proposed an estimate of an lsma of any degree using convolution and a new sine wave series, all the calculation are described in the paper : "Pierrefeu, Alex (2019): A New Low-Pass FIR Filter For Signal Processing."

Today i want to make use of this filter as an oscillator providing fast entry points. The oscillator would be similar to the MACD in the sense that is consist on the difference between two filters, with one faster than the other, however unlike the MACD which use two moving averages of different length, here i'll use two filters of same length but different degrees.

The Indicator

The indicator consist in 3 elements, one main line (in green) the trigger line (in orange) and the histogram which is the difference between the green line and the red one. The main line is made from the difference between two filters of both period length and different degrees (fast, slow), fast should always be higher than slow. The signal line is just the exponential moving average of the main line, the period of the exponential moving average can be adjusted from the settings.

Both fast/slow determine the degree of the filters, higher values will create a faster filter.

For those who are curious, the filter use a kernel who estimate a polynomial function, this is how an lsma work, the kernel of an lsma of degree p is a polynomial of degree p. I achieved this estimation using a sine wave series.

When fast = 1 and slow = 0, the oscillator appear less periodic, this equivalent to : lsma - sma

快照

Using 2/1 allow the indicator to highlight cycles more easily without being uncorrelated with the price. This is equivalent to qlsma - lsma, where qlsma is a quadratic least squares moving average. This is similar to my old indicator "Linear Quadratic Convergence Divergence Oscillator".

快照

By default the indicator use 3 for fast and 2 for slow, but you can increase both values, here 4/3 :

快照

In general higher values of fast/slow will create way more cyclical results, but they can be uncorrelated with the market price.

快照

Conclusion

This indicator was rather made to show the filter calculation rather than proposing something interesting. However it can be funny to see how the difference between low lag filters create more cyclical outputs, it often allow indicators to have more predictive capabilities.

I invite you to read the paper made about the filter, codes for both pinescript and python are provided.



Centered OscillatorsfilterleastsquaresLeast Squares Moving Average (LSMA)Trend Analysis

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?


Check out the indicators we are making at luxalgo: tradingview.com/u/LuxAlgo/
更多:

免责声明