OPEN-SOURCE SCRIPT

Zero Phase Filtering [Repaint] - Experimental

Important !

The indicator is for experimental purpose only, it must not be used as a decisional tool but only as a visual one (like Zig-Zag, Fractal etc). The information this indicator display is uncertain and subject to drastic changes over time. If you have further question feel free to pm me.

Introduction

Most of the filters you will find are causal, this mean that they depend on present and past input values, this explain the lag they produce. Non causal filters however will use future input values. A well know way to get a zero-phase filter is by using the forward backward method, but this is not possible in pinescript as i recall. So we have to use some kind of function that will display future values, this is possible using the security function in version 2 or the one in version 3 using barmerge.lookahead_on.

The Use Of A Repainting Indicator

Its always better to filter data in order to have a clearer view of what is happening, this can be useful when doing some forecasting or doing less formal kind of analysis. However since it repaint you cant use it as a signal provider or use signals of other indicators using this filter as source.

For example if you want to forecast a smooth indicator, the forecast of this indicator under normal circumstances could still have lag associated with it, so you would have to react before your forecast, this wont happen if you apply this filter as your indicator source.

The Filter

We smooth with a simple moving average the price provided by the security function twice, length control the smoothing level. Since security depend on the time frame you are in you must select your time frame in the indicator parameter selection window.

สแนปชอต

Filtering using 45 minutes time frame close price in a 5 minutes chart, we fix this by selecting our time frame.

สแนปชอต

Consider the fact that the input of the indicator is just periodic price, so sometimes the lag can sometimes be less or more than 0 and the estimation not centered.

The indicator can work on time frames up to 1h, after that the filter have some lag, i tried fixing this and i ended up having data errors.

Applying our filter as source for the rsi oscillator.

สแนปชอต

Conclusion

It is possible to have a kind of zero-phase filters, but it would be better if pinescript could support backward indexing thus making us able to do forward backward filtering.
Since noise can affect our analysis, applying smoothing without having to use offset in plot can be considered useful.


experimentalfilterMoving Averagesnon-causalrepaintrepaintingSimple Moving Average (SMA)smasmoothingTrend Analysisvisualindicatorzero-lag

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?


Check out the indicators we are making at luxalgo: tradingview.com/u/LuxAlgo/
และใน:

คำจำกัดสิทธิ์ความรับผิดชอบ