Advertisement
JustUncleL

Pivot Tool R3

Mar 27th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. //@version=2
  2.  
  3. study(title="Pivot Hilo Support n Resistance Levels R3 by JustUncleL", shorttitle="PVTLVLS R3", overlay=true)
  4.  
  5. // By: JustUncleL
  6. // Date: 20-Mar-2017
  7. // Version: R3
  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. // R3 - added code to force Pivot to be always complete before drawing.
  22. // R2 - added option for different length test for each side of Pivot.
  23. // R1 - original.
  24. //
  25.  
  26. // - INPUTS
  27. ShowPivots = input(true,title="Show Pivot Points")
  28. pvtLenL = input(7,minval=1,title="Pivot Length Left Hand Side")
  29. pvtLenR = input(7,minval=1,title="Pivot Length Right Hand Side")
  30. ShowSRLevels = input(true,title="Show S/R Level Extensions")
  31. ShowPivotLabels = input(false)
  32. maxLvlLen = input(0,minval=0, title="Maximum S/R Level Extension Length")
  33.  
  34. // - /INPUTS
  35.  
  36.  
  37. // Get High and Low Pivot Points
  38. pvthi = pivothigh(pvtLenL,pvtLenR)
  39. pvtlo = pivotlow(pvtLenL,pvtLenR)
  40.  
  41.  
  42. // If Selected Display Pivot points
  43. plotchar(ShowPivots and not ShowPivotLabels? pvthi[1] :na, title='High Pivot *', location=location.abovebar, color=green, offset=-pvtLenR-1,transp=0,size=size.auto)
  44. plotchar(ShowPivots and not ShowPivotLabels? pvtlo[1] :na, title='Low Pivot *', location=location.belowbar, color=red, offset=-pvtLenR-1,transp=0,size=size.auto)
  45. plotshape(ShowPivotLabels? pvthi[1]: na, title='Pivot High Label', style=shape.diamond, location=location.abovebar, color=green, text="[P.H]", offset=-pvtLenR-1,transp=0)
  46. plotshape(ShowPivotLabels? pvtlo[1]: na, title='Pivot Low Label', style=shape.diamond, location=location.belowbar, color=red, text="[P.L]", offset=-pvtLenR-1,transp=0)
  47.  
  48. //Count How many candles for current Pivot Level, If new reset.
  49. counthi = pvthi[1] ? 0 : nz(counthi[1])+1
  50. countlo = pvtlo[1] ? 0 : nz(countlo[1])+1
  51.  
  52. pvthis = pvthi[1] ? high[pvtLenR+1] : pvthis[1]
  53. pvtlos = pvtlo[1] ? low[pvtLenR+1] : pvtlos[1]
  54.  
  55. hipc = (pvthis != pvthis[1]) ? na : green
  56. lopc = (pvtlos != pvtlos[1]) ? na : red
  57.  
  58. plot(ShowSRLevels and (maxLvlLen==0 or counthi<maxLvlLen)? pvthis : na, color=hipc, transp=0, linewidth=2, offset=-pvtLenR-1, title="Top Levels")
  59. plot(ShowSRLevels and (maxLvlLen==0 or countlo<maxLvlLen)? pvtlos : na, color=lopc, transp=0, linewidth=2, offset=-pvtLenR-1, title="Bottom Levels")
  60.  
  61. //
  62. //EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement