Advertisement
Guest User

Custom COG Channel Indicator

a guest
Apr 16th, 2014
3,352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. //
  2. // @author LazyBear
  3. //
  4. // This is my custom channel derived from BB/STARC. This uses both ATR/STDEV for plotting the bounds.
  5. // I use COG for the base line (normally it is SMA/EMA).
  6. //
  7. // If you use this code in its original/modified form, do drop me a note.
  8. //
  9. study("COG Double Channel [LazyBear]", shorttitle="COGChannel_LB", overlay=true)
  10. src = close
  11. length = input(34)
  12. median=0
  13. mult=input(2.5)
  14. offset = input(20)
  15. tr_custom() =>
  16. x1=high-low
  17. x2=abs(high-close[1])
  18. x3=abs(low-close[1])
  19. max(x1, max(x2,x3))
  20.  
  21. atr_custom(x,y) =>
  22. sma(x,y)
  23.  
  24. dev = (mult * stdev(src, length))
  25. basis=linreg(src, length, median)
  26. ul = (basis + dev)
  27. ll = (basis - dev)
  28. tr_v = tr_custom()
  29. acustom=(2*atr_custom(tr_v, length))
  30. uls=basis+acustom
  31. lls=basis-acustom
  32.  
  33. // Plot STDEV channel
  34. plot(basis, linewidth=1, color=navy, style=line, linewidth=1, title="Median")
  35. lb=plot(ul, color=red, linewidth=1, title="BB+", style=dashed)
  36. tb=plot(ll, color=green, linewidth=1, title="BB-", style=dashed)
  37. fill(tb,lb, silver, title="Region fill")
  38.  
  39. // Plot ATR channel
  40. plot(basis, linewidth=2, color=navy, style=line, linewidth=2, title="Median")
  41. ls=plot(uls, color=red, linewidth=1, title="Starc+", style=circles)
  42. ts=plot(lls, color=green, linewidth=1, title="Star-", style=circles)
  43. fill(ts,tb, green, title="Region fill")
  44. fill(ls,lb, red, title="Region fill")
  45.  
  46. // Mark SQZ
  47. plot_offs_high=0.002
  48. plot_offs_low=0.002
  49. sqz_f=(uls>ul) and (lls<ll)
  50. b_color=sqz_f ? teal : na
  51. plot(sqz_f ? lls - (lls * plot_offs_low) : na, color=b_color, style=cross, linewidth=2)
  52. plot(sqz_f ? uls + (uls * plot_offs_high) : na, color=b_color, style=cross, linewidth=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement