Guest User

Instruments Correlation [TradingView Custom Indicator]

a guest
May 10th, 2014
10,301
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. //
  2. // @author LazyBear
  3. // If you use this code in its original / modified form, do drop me a note. Thx.
  4. //
  5. study(title = "Instruments Correlation [LazyBear]", shorttitle="CC_LB")
  6. ccSymbol=input("DOWI", title="Correlation Symbol", type=symbol)
  7. lengthCorrelation=input(20)
  8. lengthMA=input(10)
  9. s2=close
  10. s1=security(ccSymbol, period, close)
  11. c=correlation(s1, s2, lengthCorrelation)
  12.  
  13. plot(c, color=red, style=area)
  14. plot(sma(c, lengthMA), color=navy, linewidth=2)
  15. hline(0, color=gray)
  16. u=hline(0.2, color=maroon)
  17. l=hline(-0.2, color=maroon)
  18. fill(u,l, maroon)
  19. hline(1.0, color=green, linewidth=2, title="Perfect positive correlation")
  20. hline(-1.0, color=red, linewidth=2, title="Perfect negative correlation")
Advertisement
Comments
Add Comment
Please, Sign In to add comment