BB % Correlation

517 0 89
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)
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out