Advertisement
JustUncleL

Pivot HiLo SR Levels R2

Mar 20th, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. //@version=2
  2.  
  3. study(title="Pivot Hilo Support n Resistance Levels R2 by JustUncleL", shorttitle="PVTLVLS R2", overlay=true)
  4.  
  5. // By: JustUncleL
  6. // Date: 20-Mar-2017
  7. // Version: R2
  8. //
  9. // Description:
  10. // This Pivot Points marked with "star" and with Optional Support and Resistance extension Levels.
  11. //
  12. // Options:
  13. // - Show Pivot Points (default true)
  14. // - Pivot Length Left Side (default 7), the number of bars left hand side of the Pivot candle.
  15. // - Pivot Length Right Side (default 7), the number of bars right hand side of the Pivot candle.
  16. // - Show S/R Extension Levels (default true)
  17. // - Maximum S/R Extension Length (default 0, no limit)
  18. // - Show Pivot Labels (instead of "star") "[P.H]" and "[P.L]"
  19. //
  20. // Modifications:
  21. // R2 - added option for different length test for each side of Pivot.
  22. // R1 - original.
  23. //
  24.  
  25. // - INPUTS
  26. ShowPivots = input(true,title="Show Pivot Points")
  27. pvtLenL = input(7,minval=1,title="Pivot Length Left Hand Side")
  28. pvtLenR = input(7,minval=1,title="Pivot Length Right Hand Side")
  29. ShowSRLevels = input(true,title="Show S/R Level Extensions")
  30. ShowPivotLabels = input(false)
  31. maxLvlLen = input(0,minval=0, title="Maximum S/R Level Extension Length")
  32.  
  33. // - /INPUTS
  34.  
  35.  
  36. // Get High and Low Pivot Points
  37. pvthi = pivothigh(pvtLenL,pvtLenR)
  38. pvtlo = pivotlow(pvtLenL,pvtLenR)
  39.  
  40.  
  41. // If Selected Display Pivot points
  42. plotchar(ShowPivots and not ShowPivotLabels? pvthi :na, title='High Pivot *', location=location.abovebar, color=green, offset=-pvtLenR,transp=0,size=size.auto)
  43. plotchar(ShowPivots and not ShowPivotLabels? pvtlo :na, title='Low Pivot *', location=location.belowbar, color=red, offset=-pvtLenR,transp=0,size=size.auto)
  44. plotshape(ShowPivotLabels? pvthi: na, title='Pivot High Label', style=shape.diamond, location=location.abovebar, color=green, text="[P.H]", offset=-pvtLenR,transp=0)
  45. plotshape(ShowPivotLabels? pvtlo: na, title='Pivot Low Label', style=shape.diamond, location=location.belowbar, color=red, text="[P.L]", offset=-pvtLenR,transp=0)
  46.  
  47. //plotshape(ShowPivots? toppvt :na, title='TOPPVT', style=shape.triangleup, location=location.abovebar, color=green, offset=-3,transp=0,size=size.tiny)
  48. //plotshape(ShowPivots? botpvt :na, title='BOTPVT', style=shape.triangledown, location=location.belowbar, color=red, offset=-3,transp=0,size=size.tiny)
  49.  
  50.  
  51. //Count How many candles for current Pivot Level, If new reset.
  52. counthi = pvthi ? 0 : nz(counthi[1])+1
  53. countlo = pvtlo ? 0 : nz(countlo[1])+1
  54.  
  55. pvthis = pvthi ? high[pvtLenR] : pvthis[1]
  56. pvtlos = pvtlo ? low[pvtLenR] : pvtlos[1]
  57.  
  58. hipc = (pvthis != pvthis[1]) ? na : green
  59. lopc = (pvtlos != pvtlos[1]) ? na : red
  60.  
  61. plot(ShowSRLevels and (maxLvlLen==0 or counthi<maxLvlLen)? pvthis : na, color=hipc, transp=0, linewidth=2, offset=-pvtLenR, title="Top Levels")
  62. plot(ShowSRLevels and (maxLvlLen==0 or countlo<maxLvlLen)? pvtlos : na, color=lopc, transp=0, linewidth=2, offset=-pvtLenR, title="Bottom Levels")
  63.  
  64. //
  65. //EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement