daily pastebin goal
16%
SHARE
TWEET

Lin Reg Channel-add this to pinescript folder

memer9161998 Aug 10th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=3
  2. //created by sergko13
  3. study(title="LR Channel", overlay=true)
  4. src = close
  5. len = input(defval=100, minval=1, title="Linear Regression Period")
  6. mult = input(2.0, title = "")
  7. a = linreg(src, len, 0)
  8. a1 = linreg(src,len,1)
  9. b = (a-a1)
  10.  
  11. MD(a,b,shift)=>
  12.     md = pow(a-b*shift - close[shift], 2)
  13.  
  14. sum2 = 0.0
  15. for shift = 0 to len-1
  16.     sum2:=sum2+MD(a,b,shift)
  17.    
  18. range = sqrt(sum2/(len+1))*mult
  19. top = a+range
  20. bot = a-range
  21. clr = b>0? green:red
  22. plot(a, color=clr, linewidth=2, transp=0, title = "Middle line")
  23. plot(top, color=clr, linewidth=2, transp=0, title = "Upper Line")
  24. plot(bot, color=clr, linewidth=2, transp=0, title = "Lower Line")
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