handsheik

FIR Trend Filter (Sawtooth and Square Waves)

Experimental script!

Using sigma approximation with Sine wave to form Sawtooth and Square waves, for a Finite Impulse Response filter.
Higher harmonics make the sawtooth or square wave more "exact", at the expense of more computation. It also makes the filter more "sensitive". I wouldn't exceed 100, but you're the boss.
The default number of harmonics is 20. The length is 20, too. Why? Because we are currently in 2020. Silly, I know.

Feel free to play around with the settings and tune it to your liking.
How to use it is pretty straight forward: Green is trend-up and red is trend-down.

Credit to alexgrover for the template.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?