lonestar108

Kaufman Binary Wave [LazyBear] Non overlaid

451
LazyBear's KAMA, non-overlaid

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
//
// @author LazyBear
// If you use this code in its original/modified form, do drop me a note.
// My other indicators: https://www.tradingview.com/u/LazyBear/#published-charts
//
study(title = "Kaufman Binary Wave [LazyBear]", shorttitle="AMAWave_LB", overlay=false)
src=close
length=input(20)
filterp = input(10, title="Filter %", type=integer)
cf=input(true, "Color Buy/Sell safe areas?", type=bool)
dw=input(true, "Draw Wave?", type=bool)
 
d=abs(src-src[1])
s=abs(src-src[length])
noise=sum(d, length)
efratio=s/noise
fastsc=0.6022
slowsc=0.0645
 
smooth=pow(efratio*fastsc+slowsc, 2)
ama=nz(ama[1], close)+smooth*(src-nz(ama[1], close))
filter=filterp/100 * stdev(ama-nz(ama), length)
amalow=ama < nz(ama[1]) ? ama : nz(amalow[1])
amahigh=ama > nz(ama[1]) ? ama : nz(amahigh[1])
bw=(ama-amalow) > filter ? 1 : (amahigh-ama > filter ? -1 : 0)
s_color=cf ? (bw > 0 ? green : (bw < 0) ? red : blue) : maroon
plot(dw ? bw : na, color=s_color)
bgcolor(cf ? s_color : na)
hline(0)