Advertisement
Guest User

HH LH & HL LL

a guest
May 22nd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. //@version=3
  2.  
  3. study(title = "HH LH & HL LL", shorttitle = "HH & HL", overlay = true)
  4.  
  5. // === INPUTS ===
  6.  
  7. ShowHHLL = input(true)
  8. filterBW = input(false)
  9. ShowFractals= input(true)
  10.  
  11. // ||--- Fractal Recognition Functions: ---------------------------------------------------------------||
  12. isRegularFractal(mode) =>
  13. ret = mode == 1 ? high[4] < high[3] and high[3] < high[2] and high[2] > high[1] and high[1] > high[0] : mode == -1 ? low[4] > low[3] and low[3] > low[2] and low[2] < low[1] and low[1] < low[0] : false
  14.  
  15. isBWFractal(mode) =>
  16. ret = mode == 1 ? high[4] < high[2] and high[3] <= high[2] and high[2] >= high[1] and high[2] > high[0] : mode == -1 ? low[4] > low[2] and low[3] >= low[2] and low[2] <= low[1] and low[2] < low[0] : false
  17.  
  18. // ||--- Fractal Recognition:
  19.  
  20. // ||-----------------------------------------------------------------------------------------------------||
  21. filteredtopf = filterBW ? isRegularFractal(1) : isBWFractal(1)
  22. filteredbotf = filterBW ? isRegularFractal(-1) : isBWFractal(-1)
  23.  
  24. plotchar(ShowFractals? filteredtopf :na, char='⮝', location=location.abovebar, offset=-2, color=green, transp=75, title='Filtered Top Fractals')
  25. plotchar(ShowFractals? filteredbotf :na, char='⮟', location=location.belowbar, offset=-2, color=red, transp=75, title='Filtered Bottom Fractals')
  26.  
  27. // ||--- Higher Highs, Lower Highs, Higher Lows, Lower Lows -------------------------------------------||
  28. higherhigh = filteredtopf == false ? false : ( valuewhen(filteredtopf == true, high[2], 1) < valuewhen(filteredtopf == true, high[2], 0) and valuewhen(filteredtopf == true, high[2], 2) < valuewhen(filteredtopf == true, high[2], 0))
  29. lowerhigh = filteredtopf == false ? false : ( valuewhen(filteredtopf == true, high[2], 1) > valuewhen(filteredtopf == true, high[2], 0) and valuewhen(filteredtopf == true, high[2], 2) > valuewhen(filteredtopf == true, high[2], 0))
  30. higherlow = filteredbotf == false ? false : ( valuewhen(filteredbotf == true, low[2], 1) < valuewhen(filteredbotf == true, low[2], 0) and valuewhen(filteredbotf == true, low[2], 2) < valuewhen(filteredbotf == true, low[2], 0))
  31. lowerlow = filteredbotf == false ? false : ( valuewhen(filteredbotf == true, low[2], 1) > valuewhen(filteredbotf == true, low[2], 0) and valuewhen(filteredbotf == true, low[2], 2) > valuewhen(filteredbotf == true, low[2], 0))
  32.  
  33. plotchar(ShowHHLL ? higherhigh : na, title='Higher High', char='_', location=location.abovebar, color=red, text="[HH]", offset=-2)
  34. plotchar(ShowHHLL ? lowerhigh : na, title='Lower High', char='_', location=location.abovebar, color=red, text="[LH]", offset=-2)
  35. plotchar(ShowHHLL ? higherlow : na, title='High Low', char='_', location=location.belowbar, color=lime, text="[HL]", offset=-2)
  36. plotchar(ShowHHLL ? lowerlow : na, title='Lower Low', char='_', location=location.belowbar, color=lime, text="[LL]", offset=-2)
  37.  
  38. // Volume Bars //
  39.  
  40. length1=input(30, "Volume Bars Length", minval=1)
  41. avrg=sma(volume,length1)
  42.  
  43. vold1 = volume > avrg*1.5 and close<open
  44. vold2 = volume >= avrg*0.5 and volume<=avrg*1.5 and close<open
  45. vold3 = volume < avrg *0.5 and close<open
  46.  
  47. volu1 = volume > avrg*1.5 and close>open
  48. volu2 = volume >= avrg*0.5 and volume<=avrg*1.5 and close>open
  49. volu3 = volume< avrg*0.5 and close>open
  50.  
  51. cold1=#800000
  52. cold2=#FF0000
  53. cold3=orange
  54.  
  55. colu1=#006400
  56. colu2=lime
  57. colu3=#7FFFD4
  58.  
  59. color = vold1 ? cold1 : vold2 ? cold2 : vold3 ? cold3 : volu1 ? colu1 : volu2 ? colu2 : volu3 ? colu3 : na
  60.  
  61. barcolor(color)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement