BB % Correlation

149 0 14
BB% of Correlation, is the indication frequently used by Quant Traders to define the momentum for their Arbitrage Trading Strategy. If anyone here is a Quant Trading and find this is not a correct script, please feel free to fix it, because I am not a programer. Thank you.
Remove from Favorite Scripts Add to Favorite Scripts
study(title = "BB % Correlation", shorttitle = "BB % Correl")

source = hlc3
//length = input(14, minval=1, title="RSI Period") 
//corlength = input(30, minval=1, title="Correlation Period)
bblength = input(20, minval=1, title="BB Period")
mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
HighlightBreaches=input(false, title="Highlight Oversold/Overbought?", type=bool)

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

//Define Correlation
sym = input(title="Symbol", type=symbol, defval="XAUUSD", confirm=true)
src = input(close, title="Source")
//corlength = input(20, minval=1)
corlength = input(30, minval=1, title="Correlation Period")


ovr = security(sym, res, src)
correl = correlation(src, ovr, corlength)

// BB of RSI

basis = sma(correl, bblength)
dev = mult * stdev(correl, bblength)
upper = basis + dev
lower = basis - dev

bbr = (correl - 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 = (correl > upper) ? red : (correl < lower) ? green : na
//b_color = (bbr > band1) ? red : (bbr < band0) ? green : na
bgcolor(HighlightBreaches ? b_color : na)
Ideas Scripts Chart
United States
United Kingdom
Home Stock Screener 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 Billing Sign Out