OPEN-SOURCE SCRIPT
Kalman Exponential SuperTrend

The Kalman Exponential SuperTrend is a new, smoother & superior version of the famous "SuperTrend". Using Kalman smoothing, a concept from the EMA (Exponential Moving Average), this script leverages the best out of each and combines it into a single indicator.
How does it work?
First, we need to calculate the Kalman smoothed source. This is a kind of complex calculation, so you need to study it if you want to know how it works precisely. It smooths the source of the SuperTrend, which helps us smooth the SuperTrend.
Then, we calculate "a" where:
n = user defined ATR length
a = 2/(n+1)
Now we calculate the ATR over "n" period. Classical calculation, nothing changed here.
Now we calculate the SuperTrend using the Kalman smoothed source & ATR where:
kalman = kalman smoothed source
ATR = Average True Range
m = Factor chosen by user.
Upper Band = kalman + ATR * m
Lower Band = kalman - ATR * m
Now we just smooth it a bit further using the "a" and a concept from the EMA.
u1 = Upper Band a bar ago
l1 = Lower Band a bar ago
u = Upper Band
l = Lower Band
Upper = u1 * (1-a) + u * a
Lower = l1 * (1-a) + u * a
When the classical (not Kalman) source crosses above the Upper, it indicates an uptrend. When it crosses below the Lower, it indicates a downtrend.
Methodology & Concepts
When I took a look at the classical SuperTrend => It was just far too slow, and if I made it faster it was noisy as hell. So I decided I would try to make up for it.
I tried the gaussian, bilateral filter, but then I tried kalman and that worked the best, so I added it. Now it was still too noisy and unconsistent, so I revisited my knowledge of concepts and picked the one from the EMA, and it kinda solved it.
In the core of the indicator, all it does is combine them in a really simple way, but if you go more deeply you see how it fits the puzzlé really well.
It is not about trying out random things´=> but about seeking what it is missing and trying to lessen its bad side.
That is the entire point of this indicator => Offer a unique approach to the SuperTrend type, that lessen the bad sides of it.
I also added different plotting types, this is so everyone can find their favorite
Enjoy Gs!
How does it work?
First, we need to calculate the Kalman smoothed source. This is a kind of complex calculation, so you need to study it if you want to know how it works precisely. It smooths the source of the SuperTrend, which helps us smooth the SuperTrend.
Then, we calculate "a" where:
n = user defined ATR length
a = 2/(n+1)
Now we calculate the ATR over "n" period. Classical calculation, nothing changed here.
Now we calculate the SuperTrend using the Kalman smoothed source & ATR where:
kalman = kalman smoothed source
ATR = Average True Range
m = Factor chosen by user.
Upper Band = kalman + ATR * m
Lower Band = kalman - ATR * m
Now we just smooth it a bit further using the "a" and a concept from the EMA.
u1 = Upper Band a bar ago
l1 = Lower Band a bar ago
u = Upper Band
l = Lower Band
Upper = u1 * (1-a) + u * a
Lower = l1 * (1-a) + u * a
When the classical (not Kalman) source crosses above the Upper, it indicates an uptrend. When it crosses below the Lower, it indicates a downtrend.
Methodology & Concepts
When I took a look at the classical SuperTrend => It was just far too slow, and if I made it faster it was noisy as hell. So I decided I would try to make up for it.
I tried the gaussian, bilateral filter, but then I tried kalman and that worked the best, so I added it. Now it was still too noisy and unconsistent, so I revisited my knowledge of concepts and picked the one from the EMA, and it kinda solved it.
In the core of the indicator, all it does is combine them in a really simple way, but if you go more deeply you see how it fits the puzzlé really well.
It is not about trying out random things´=> but about seeking what it is missing and trying to lessen its bad side.
That is the entire point of this indicator => Offer a unique approach to the SuperTrend type, that lessen the bad sides of it.
I also added different plotting types, this is so everyone can find their favorite
Enjoy Gs!
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.