Spinn29

Ehlers SuperSmoother

John F. Ehlers has provided the SuperSmoother filter in several of his works, including his book "Cyclical Analytics for Traders", Chapter 3.

The SuperSmoother filter is utilized whenever one might typically apply a moving average of any kind. The outcome is that the output signal from the SuperSmoother filter displays significantly less lag compared to an equivalent amount of smoothing from a moving average. The lag difference between a moving average and the SuperSmoother filter becomes even more pronounced when critical periods are extended.

Market data contains noise, and the purpose of smoothing filters is to mitigate this noise. In fact, there are various types of noise inherent in market data. One type of noise is systemic, originating from random trading activities. Another type is aliasing noise, which arises due to the use of discrete data. Aliasing noise dominates the data when considering shorter cycle durations.

It's tempting to perceive market data as a continuous wave, but that's a misconception. Taking the closing price as representative of a bar provides just a single data point. Whether you opt for the midpoint between the high and low instead of the closing price, you're still limited to one sample per bar. Given the discrete nature of this data, certain spectral implications must be considered. For instance, the shortest feasible analysis period (without aliasing) is a two-bar cycle. This is referred to as the Nyquist frequency, at 0.5 cycles per sample.

An ideally sampled two-beat sinusoidal cycle becomes rectified when discretized. However, peak sampling for the cycle isn't always guaranteed, and interference between the sampling rate and the data frequency results in aliasing noise. This noise decreases as the data period lengthens. For example, a four-beat cycle implies four samples per cycle. With more samples, the sampled data provides a better representation of the sinusoidal component. The replica becomes even more accurate for an eight-bar data component. The increased precision of discrete data signifies that aliasing noise decreases as cycle durations expand.

A smoothing filter should possess the selectivity to reduce the aliasing noise below systemic noise levels. Given that aliasing noise increases by 6 dB per octave above the filter's selected cutoff frequency and the SuperSmoother's attenuation rate is 12 dB per octave, the SuperSmoother filter emerges as an effective tool to virtually eliminate aliasing noise in its output signal.

There are already several SuperSmoother indicators on Tradingview, but I like to structure the code and highlight the main components as functions rather than hiding them in the code. I hope this is useful for those who are starting to learn Pine Script.
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?