Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- //@author=LucF
- // Correlation Ribbon [LucF]
- // v1.2, 2019.09.11 08:21 — LucF
- // Thx to midtownsk8rguy for colors.
- study(title="Correlation Ribbon [LucF]", shorttitle="Correlation Ribbon")
- otherSymbol = input(true, "Correlate against other symbol")
- symb = input("SP:SPX", type = input.symbol)
- singleLine = input(false, "Single Line instead of ribbon")
- price = input(close, "Source")
- offset = input(0, "Offest", minval=0)
- period = input(50, "Period", minval=3)
- invert = input(false, "Invert")
- step = input(1, "Bar Step between lines", minval=1)
- // Correlation with same symbol.
- Corr(Series, _i, Offset, Period, Invert) =>
- correlation(Series, Series[_i + Offset], Period) * (Invert ? -1.0 : 1.0)
- // Correlation with another symbol.
- CorrS(Series, _i, Offset, Period, Invert) =>
- correlation(Series, security(symb, timeframe.period, Series)[_i + Offset], Period) * (Invert ? -1.0 : 1.0)
- plot( singleLine ? otherSymbol ? CorrS(price, 0 , offset, period, invert) : Corr(price, 0 , offset, period, invert) : na, " 0", color=#00FF00FF, linewidth=2)
- plot(not singleLine ? otherSymbol ? CorrS(price, 2 + step, offset, period, invert) : Corr(price, 2 + step, offset, period, invert) : na, " 2", color=#00FF00FF, linewidth=2)
- plot(not singleLine ? otherSymbol ? CorrS(price, 3 + step, offset, period, invert) : Corr(price, 3 + step, offset, period, invert) : na, " 3", color=#0FFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price, 4 + step, offset, period, invert) : Corr(price, 4 + step, offset, period, invert) : na, " 4", color=#1FFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price, 5 + step, offset, period, invert) : Corr(price, 5 + step, offset, period, invert) : na, " 5", color=#2FFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price, 6 + step, offset, period, invert) : Corr(price, 6 + step, offset, period, invert) : na, " 6", color=#3FFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price, 7 + step, offset, period, invert) : Corr(price, 7 + step, offset, period, invert) : na, " 7", color=#4FFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price, 8 + step, offset, period, invert) : Corr(price, 8 + step, offset, period, invert) : na, " 8", color=#5FFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price, 9 + step, offset, period, invert) : Corr(price, 9 + step, offset, period, invert) : na, " 9", color=#6FFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,10 + step, offset, period, invert) : Corr(price,10 + step, offset, period, invert) : na, "10", color=#7FFF00FF, linewidth=2)
- plot(not singleLine ? otherSymbol ? CorrS(price,11 + step, offset, period, invert) : Corr(price,11 + step, offset, period, invert) : na, "11", color=#8FFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,12 + step, offset, period, invert) : Corr(price,12 + step, offset, period, invert) : na, "12", color=#9FFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,13 + step, offset, period, invert) : Corr(price,13 + step, offset, period, invert) : na, "13", color=#AFFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,14 + step, offset, period, invert) : Corr(price,14 + step, offset, period, invert) : na, "14", color=#BFFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,15 + step, offset, period, invert) : Corr(price,15 + step, offset, period, invert) : na, "15", color=#CFFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,16 + step, offset, period, invert) : Corr(price,16 + step, offset, period, invert) : na, "16", color=#DFFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,17 + step, offset, period, invert) : Corr(price,17 + step, offset, period, invert) : na, "17", color=#EFFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,18 + step, offset, period, invert) : Corr(price,18 + step, offset, period, invert) : na, "18", color=#FFFF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,19 + step, offset, period, invert) : Corr(price,19 + step, offset, period, invert) : na, "19", color=#FFEF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,20 + step, offset, period, invert) : Corr(price,20 + step, offset, period, invert) : na, "20", color=#FFDF00FF, linewidth=2)
- plot(not singleLine ? otherSymbol ? CorrS(price,21 + step, offset, period, invert) : Corr(price,21 + step, offset, period, invert) : na, "21", color=#FFCF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,22 + step, offset, period, invert) : Corr(price,22 + step, offset, period, invert) : na, "22", color=#FFBF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,23 + step, offset, period, invert) : Corr(price,23 + step, offset, period, invert) : na, "23", color=#FFAF00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,24 + step, offset, period, invert) : Corr(price,24 + step, offset, period, invert) : na, "24", color=#FF9F00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,25 + step, offset, period, invert) : Corr(price,25 + step, offset, period, invert) : na, "25", color=#FF8F00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,26 + step, offset, period, invert) : Corr(price,26 + step, offset, period, invert) : na, "26", color=#FF7F00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,27 + step, offset, period, invert) : Corr(price,27 + step, offset, period, invert) : na, "27", color=#FF6F00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,28 + step, offset, period, invert) : Corr(price,28 + step, offset, period, invert) : na, "28", color=#FF5F00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,29 + step, offset, period, invert) : Corr(price,29 + step, offset, period, invert) : na, "29", color=#FF4F00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,30 + step, offset, period, invert) : Corr(price,30 + step, offset, period, invert) : na, "30", color=#FF3F00FF, linewidth=2)
- plot(not singleLine ? otherSymbol ? CorrS(price,31 + step, offset, period, invert) : Corr(price,31 + step, offset, period, invert) : na, "31", color=#FF2F00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,32 + step, offset, period, invert) : Corr(price,32 + step, offset, period, invert) : na, "32", color=#FF1F00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,33 + step, offset, period, invert) : Corr(price,33 + step, offset, period, invert) : na, "33", color=#FF0F00FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,34 + step, offset, period, invert) : Corr(price,34 + step, offset, period, invert) : na, "34", color=#FF0000FF)
- plot(not singleLine ? otherSymbol ? CorrS(price,35 + step, offset, period, invert) : Corr(price,35 + step, offset, period, invert) : na, "35", color=#FF000FFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,36 + step, offset, period, invert) : Corr(price,36 + step, offset, period, invert) : na, "36", color=#FF001FFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,37 + step, offset, period, invert) : Corr(price,37 + step, offset, period, invert) : na, "37", color=#FF002FFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,38 + step, offset, period, invert) : Corr(price,38 + step, offset, period, invert) : na, "38", color=#FF003FFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,39 + step, offset, period, invert) : Corr(price,39 + step, offset, period, invert) : na, "39", color=#FF004FFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,40 + step, offset, period, invert) : Corr(price,40 + step, offset, period, invert) : na, "40", color=#FF005FFF, linewidth=2)
- plot(not singleLine ? otherSymbol ? CorrS(price,41 + step, offset, period, invert) : Corr(price,41 + step, offset, period, invert) : na, "41", color=#FF006FFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,42 + step, offset, period, invert) : Corr(price,42 + step, offset, period, invert) : na, "42", color=#FF007FFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,43 + step, offset, period, invert) : Corr(price,43 + step, offset, period, invert) : na, "43", color=#FF008FFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,44 + step, offset, period, invert) : Corr(price,44 + step, offset, period, invert) : na, "44", color=#FF009FFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,45 + step, offset, period, invert) : Corr(price,45 + step, offset, period, invert) : na, "45", color=#FF00AFFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,46 + step, offset, period, invert) : Corr(price,46 + step, offset, period, invert) : na, "46", color=#FF00BFFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,47 + step, offset, period, invert) : Corr(price,47 + step, offset, period, invert) : na, "47", color=#FF00CFFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,48 + step, offset, period, invert) : Corr(price,48 + step, offset, period, invert) : na, "48", color=#FF00DFFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,49 + step, offset, period, invert) : Corr(price,49 + step, offset, period, invert) : na, "49", color=#FF00EFFF)
- plot(not singleLine ? otherSymbol ? CorrS(price,50 + step, offset, period, invert) : Corr(price,50 + step, offset, period, invert) : na, "50", color=#FF00FFFF, linewidth=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement