Falling-Rising Filter


This is a modification of an old indicator i made. This filter aim to adapt to market trend by creating a smoothing constant using highest and lowest functions. This filter is visually similar to the edge-preserving filter, this similarity can make this filter quite good for MA cross strategies.

On The Filter Code

a = nz (a) + alpha*nz(error) + beta*nz(error)

The first 3 terms describe a simple exponential filter where error = price - a, beta introduce the adaptive part. beta is equal to 1 when the price is greater or lower than any past price over length period, else beta is equal to alpha, someone could ask why we use two smoothing variable (alpha, beta) instead of only beta thus having :

a = nz (a) + beta*nz(error)

well alpha make the filter converge faster to the price thus having a better estimation.

In blue the filter using only beta and in red the filter using alpha and beta with both length = 200, the red filter converge faster to the price, if you need smoother results but less precise estimation only use beta.


I have presented a simple indicator using rising/falling functions to calculate an adaptive filter, this also show that when you create an exponential filter you can use more terms instead of only a = a + alpha*(price - a). I hope you find this indicator useful.

Thanks for reading !
May 15
Sürüm Notları: Fixed a redundant error, thanks to @aaahopper for pointing it out.
Favori Komutlardan Çıkart Favori Komutlara Ekle
Show your support by donating

BTC : 1J5BQYnx5Wb2akoSfc3ykeShtvmXGsgP6W

ETH : 0xc418eE4039D16EDf44C52dFa292EAbdF117954B3


excellent work thanks
+1 Cevap Gönder
alexgrover kumarakshay
@kumarakshay, Thanks for your comment :)
Cevap Gönder
it was perfect ! thanks
+1 Cevap Gönder
alexgrover elvisforex
@elvisforex, Thanks for the support :)
Cevap Gönder
Hi @alexgrover
How would you change the script to have an opposite line?
I noticed by having a large length you can create lines similar to a band on which you can pick tops and bottoms for quick trades.
Could you assist?
+1 Cevap Gönder
alexgrover aaahopper
@aaahopper, Hi aahopper, thanks for commenting, the closest script i have for what you are asking is the flagging band indicator. But i can try to tweak the code for what you want.
Cevap Gönder
aaahopper alexgrover
Hi @alexgrover,

I found this line a lot smoother and direction of trend :).
I can't thank you enough for such great work.
You are amazing:)
(Note: Could you check my separate comment below)
+1 Cevap Gönder
alexgrover aaahopper
@aaahopper, You are very welcome, and thank you so much for pointing the line 7 redundancy problem, i will upgrade the code right now, i'm feeling really bad recently and my condition have some repercussion on my codes.
Cevap Gönder
Hi @alexgrover
Thank you again for a great indicator. Just Brilliant :).
Why is "close" in line 7, not the src?
+1 Cevap Gönder
Very neat! Thanks, friend!
+1 Cevap Gönder