Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. //@version=4
  2. //Full credit to AlexGrover: https://www.tradingview.com/script/fIvlS64B-G-Channels-Efficient-Calculation-Of-Upper-Lower-Extremities/
  3. study("G-Channel Trend Detection",shorttitle="G-Trend",overlay=true)
  4. length = input(100),src = input(close)
  5. //----
  6. a = 0.,b = 0.
  7. a := max(src,nz(a[1])) - nz(a[1] - b[1])/length
  8. b := min(src,nz(b[1])) + nz(a[1] - b[1])/length
  9. avg = avg(a,b)
  10. //----
  11. crossup = b[1] < close[1] and b > close
  12. crossdn = a[1] < close[1] and a > close
  13. bullish = barssince(crossdn) <= barssince(crossup)
  14. c = bullish ? color.lime : color.red
  15. //plot(a,"Upper",color=color.blue,linewidth=2,transp=100)
  16. //plot(b,"Lower",color=color.blue,linewidth=2,transp=100)
  17. p1=plot(avg,"Average",color=c,linewidth=1,transp=90)
  18. p2=plot(close,"Close price",color=c,linewidth=1,transp=100)
  19. fill(p1,p2,color=c,transp=90)
  20.  
  21. showcross = input(true)
  22. plotshape(showcross and not bullish and bullish[1] ? avg : na, location=location.absolute, style=shape.labeldown, color=color.red, size=size.tiny, text="Sell", textcolor=#ffffff, transp=0, offset=-1)
  23. plotshape(showcross and bullish and not bullish[1] ? avg : na, location=location.absolute, style=shape.labelup, color=color.lime, size=size.tiny, text="Buy", textcolor=#ffffff, transp=0, offset=-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement