OPEN-SOURCE SCRIPT

Sequential Filter - An Original Filtering Approach

Removing irregular variations in the closing price remain a major task in technical analysis, indicators used to this end mostly include moving averages and other kind of low-pass filters. Understanding what kind of variations we want to remove is important, irregular (noisy) variations have mostly a short term period, fully removing them can be complicated if the filter is not properly selected, for example we might want to fully remove variations with a period of 2 bars and lower, if we select an arithmetic moving average the filter output might still contain such variations because of the ripples in the frequency response passband, all it would take is a variation of high amplitude for that variation to be clearly visible.

Although all it would take for better filtering is a filter with better performance in the frequency domain (gaussian, Butterworth, Bessel...) we can design innovative approaches that does not rely on the model of classical moving averages, today a new technical indicator is proposed, the technical indicator fully remove variations lower than the selected period.

The Indicator Approach

In order for the indicator output to change the closing price need to produce length consecutive up's/down's, length control the variation threshold of the indicator, variations lower than length are fully removed. Lets see a visual example :

ảnh chụp nhanh

Here length = 3, the closing price need to make 3 consecutive up's/down's, when the sequence happen the indicator output is equal to src, here the closing price, else the indicator is equal to its precedent value, hence removing other variations. The value of 3 is the value by default, this is because i have seen in the past that the average smallest variations period where in general of 3 bars.

Because the indicator focus only on the variation sign, it totally ignore the amplitude of the movement, this provide an effective way to filter short term retracement in a fluctuation as show'n below :

ảnh chụp nhanh

The candle option of the indicator allow the indicator to only focus on the body color of a candle, thus ignoring potential gaps, below is an example with the candle option off :

ảnh chụp nhanh

If we activate the "candle" option we end up with :

ảnh chụp nhanh

Note that the candle option is based on the closing and opening price, if you use the indicator on another indicator output make sure to have the candle option off.

Length and Indicator Color

The closing price is infected by noise, and will rarely make a large sequence of consecutive up's/down's, the indicator can therefore be useful to detect consecutive sequence of length period, here 6 is selected on BTCUSD :

ảnh chụp nhanh

A consecutive up's/down's of period 6 can be considered a relatively rare event.

It is important to note that the color of the indicator used by default has nothing to do with the consecutive sequence detected, that is the indicator turning red doesn't necessarily mean that a consecutive down's sequence has occurred, but only that this sequence has occurred at a lower value than the precedent detected sequence. This is show'n below :

ảnh chụp nhanh

In order to make the indicator color based on the detected sequence check the "Color Based On Detected Sequence" option.

ảnh chụp nhanh

Conclusion

An original approach on filtering price variations has been proposed, i believe the indicator code is elegant as well as relatively efficient, and since high values of length can't really be used the indicator execution speed will remain relatively fast.

Thanks for reading !
candleconsecutivefilternoisepatternTrend Analysisup-down

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?


Check out the indicators we are making at luxalgo: tradingview.com/u/LuxAlgo/
Ngoài ra, trên:

Thông báo miễn trừ trách nhiệm