kinetix360

Bollinger Bands %RSI

622
Hi All,
I am not a programmer, but I tried to buid BB% of RSI , base of John Bollinger' book. I cut and paste the function from LazyBear MFI/RSI BB indicator and original BB% scripts. Now, I need help for 2 things :

1. I already check by side with LazyBear indicator for the OB/OS, and all are good. One thing I don't understand is why we build the Basis for bb using "sma" ? any one can help me to understand with this?

2. I am happy with this, but I need to make the Source Price become customisable (close, hl/2, hlc/3, etc). and I don't know how to set it up. please help me with this.

Thank you.

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יכולים להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?
study(title = "Bollinger Bands %RSI", shorttitle = "BB %RSI")

source = hlc3
length = input(14, minval=1), mult = input(2.0, minval=0.001, maxval=50)
HighlightBreaches=input(true, title="Highlight Oversold/Overbought?", type=bool)

//Define RSI
rsi_s = rsi(source, length)


// BB of RSI

basis = sma(rsi_s, length)
dev = mult * stdev(rsi_s, length)
upper = basis + dev
lower = basis - dev

bbr = (rsi_s - lower)/(upper - lower)
plot(bbr, color=teal)
band1 = hline(1, color=gray, linestyle=dashed)
band0 = hline(0, color=gray, linestyle=dashed)
fill(band1, band0, color=teal)

//p1 = plot(upper, color=blue)
//p2 = plot(lower, color=blue)
//fill(p1,p2, blue)

b_color = (rsi_s > upper) ? red : (rsi_s < lower) ? green : na
bgcolor(HighlightBreaches ? b_color : na)