SHARE
TWEET

Untitled

a guest Jun 27th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=3
  2. study("Ask ya girl she tell ya", overlay=true)
  3.  
  4. p = input(defval=500, title='Correlation Lookback Period')
  5. inst1 = input(defval='BINANCE:BTCUSDT', type=symbol, title='Base coin for correlation')
  6. inst2 = input(defval='BINANCE:ETHUSDT', type=symbol, title='Alt 1')
  7. inst3 = input(defval='BINANCE:LTCUSDT', type=symbol, title='Alt 2')
  8. inst4 = input(defval='BINANCE:XRPUSDT', type=symbol, title='Alt 3')
  9. inst5 = input(defval='BINANCE:BNBUSDT', type=symbol, title='Alt 4')
  10. inst6 = input(defval='BINANCE:BCHABCUSDT', type=symbol, title='Alt 5')
  11.  
  12. inst1_data = security(inst1, period, close)
  13. inst2_data = security(inst2, period, close)
  14. inst3_data = security(inst3, period, close)
  15. inst4_data = security(inst4, period, close)
  16. inst5_data = security(inst5, period, close)
  17. inst6_data = security(inst6, period, close)
  18.  
  19. inst1_corr = correlation(close, inst1_data, p)
  20. inst2_corr = correlation(close, inst2_data, p)
  21. inst3_corr = correlation(close, inst3_data, p)
  22. inst4_corr = correlation(close, inst4_data, p)
  23. inst5_corr = correlation(close, inst5_data, p)
  24. inst6_corr = correlation(close, inst6_data, p)
  25.  
  26. positiveCorrelation=(0.7)
  27. negativeCorrelation=(-0.7)
  28.  
  29. alt1PC=(inst2_corr > positiveCorrelation)
  30. alt2PC=(inst3_corr > positiveCorrelation)
  31. alt3PC=(inst4_corr > positiveCorrelation)
  32. alt4PC=(inst5_corr > positiveCorrelation)
  33. alt5PC=(inst6_corr > positiveCorrelation)
  34.  
  35. alt1NC=(inst2_corr < negativeCorrelation)
  36. alt2NC=(inst3_corr < negativeCorrelation)
  37. alt3NC=(inst4_corr < negativeCorrelation)
  38. alt4NC=(inst5_corr < negativeCorrelation)
  39. alt5NC=(inst6_corr < negativeCorrelation)
  40.  
  41. //h1 = hline(1)
  42. //h2 = hline(-1)
  43. //h3 = hline(0)
  44. //h4 = hline(0.70)
  45. //h5 = hline(-0.70)
  46. //h6 = hline(-0.30)
  47. //h7 = hline(0.30)
  48.  
  49.  
  50. plotchar(alt1PC, title='Alt 1 Positive Correlation', char='+', location=location.abovebar, color=#EE3E05, transp=0, size=size.tiny)
  51. plotchar(alt2PC, title='Alt 2 Positive Correlation', char='+', location=location.abovebar, color=#07B4D6, transp=0, size=size.tiny)
  52. plotchar(alt3PC, title='Alt 3 Positive Correlation', char='+', location=location.abovebar, color=#7DBD41, transp=0, size=size.tiny)
  53. plotchar(alt4PC, title='Alt 4 Positive Correlation', char='+', location=location.abovebar, color=#B48F07, transp=0, size=size.tiny)
  54. plotchar(alt5PC, title='Alt 5 Positive Correlation', char='+', location=location.abovebar, color=#7507D6, transp=0, size=size.tiny)
  55.  
  56. plotchar(alt1NC, title='Alt 1 Negative Correlation', char='-', location=location.belowbar, color=#EE3E05, transp=0, size=size.tiny)
  57. plotchar(alt2NC, title='Alt 2 Negative Correlation', char='-', location=location.belowbar, color=#07B4D6, transp=0, size=size.tiny)
  58. plotchar(alt3NC, title='Alt 3 Negative Correlation', char='-', location=location.belowbar, color=#7DBD41, transp=0, size=size.tiny)
  59. plotchar(alt4NC, title='Alt 4 Negative Correlation', char='-', location=location.belowbar, color=#B48F07, transp=0, size=size.tiny)
  60. plotchar(alt5NC, title='Alt 5 Negative Correlation', char='-', location=location.belowbar, color=#7507D6, transp=0, size=size.tiny)
  61.  
  62. //fill(h4,h1, color=#35AA73, transp=30)
  63. //fill(h5,h2, color=#AA355A, transp=30)
  64. //fill(h6,h7, color=black, transp=0)
  65.  
  66. //plot(inst1_corr, style=stepline, title='Base pair', linewidth=1)
  67. //plot(inst2_corr, style=stepline, color=#EE3E05, title='Alt 1', linewidth=1, transp=0)
  68. //plot(inst3_corr, style=stepline, color=#07B4D6, title='Alt 2', linewidth=1, transp=0)
  69. //plot(inst4_corr, style=stepline, color=#7DBD41, title='Alt 3', linewidth=1, transp=0)
  70. //plot(inst5_corr, style=stepline, color=#B48F07, title='Alt 4', linewidth=1, transp=0)
  71. //plot(inst6_corr, style=stepline, color=#7507D6, title='Alt 5', linewidth=1, transp=0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top