lonestar108

Kaufman Binary Wave [LazyBear] Non overlaid

615 0 88
LazyBear's KAMA , non-overlaid
Remove from Favorite Scripts Add to Favorite Scripts
//
// @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)
United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
日本
한국
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out