xmd79

Unraided Liquidity and S/R Pivots

Jan 12th, 2023
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1.  
  2. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  3. // © Texmoonbeam
  4.  
  5. //@version=5
  6. indicator("Unraided Liquidity and S/R Pivots", overlay=true, max_labels_count=500, max_lines_count=500)
  7. timeframe = input.timeframe(defval = '60')
  8. r = input.int(defval = 100, title = "Look back")
  9. leftbars = input.int(defval = 6, title = "Left Bars", minval = 1, tooltip="More bars left of the pivot means it came from a longer trend")
  10. rightbars = input.int(defval = 6, title = "Right Bars", minval = 1, tooltip="More bars right of the pivot means it went into a longer trend")
  11. untested = input.bool(defval = true, title = 'Untested Only?')
  12. HighCol = input.color(color.green, "Highs", inline="2")
  13. HighWidth = input.int(defval=1, title="Width", minval=1, maxval = 4, inline="2")
  14. LowCol = input.color(color.red, "Lows", inline="3")
  15. LowWidth = input.int(defval=1, title="Width", minval=1, maxval = 4, inline="3")
  16.  
  17.  
  18. get_highslows()=>
  19. highs= array.new_float(0)
  20. lows= array.new_float(0)
  21. starttimes= array.new_int(0)
  22. for n = 0 to r+leftbars
  23. array.push(highs, high[n])
  24. array.push(lows, low[n])
  25. array.push(starttimes, time[n])
  26. [highs, lows, starttimes]
  27.  
  28.  
  29. [highs, lows, starttimes] = request.security(syminfo.tickerid, timeframe, get_highslows(), lookahead = barmerge.lookahead_off, ignore_invalid_symbol = true)
  30.  
  31.  
  32.  
  33. if (barstate.islast)
  34. ishpivot = true
  35. highest = true
  36. a = 0
  37. x = 0
  38. for a = 0 to (array.size(highs)-leftbars-1)
  39. for b = a to 0
  40.  
  41. if (array.get(highs, a) < array.get(highs, b))
  42. highest := false
  43.  
  44. //label.new(x=bar_index[b], y=high[b], text=str.tostring(b)+'-'+str.tostring(highest)+' '+str.tostring(bar_index[b])+' '+str.tostring(high[b]))
  45. break
  46. else
  47. highest:= true
  48.  
  49.  
  50. for x = (a+leftbars) to (a-rightbars > 0 ? a - rightbars : 0)
  51. if (array.get(highs, x) > array.get(highs, a))
  52. ishpivot:=false
  53. break
  54. else
  55. ishpivot:= true
  56.  
  57. if (untested == true ? highest == true and ishpivot == true : ishpivot == true )
  58. //label.new(x=bar_index[a], y=high[a], text=str.tostring(high[a])+' '+str.tostring(ishpivot)+' '+str.tostring(x), color=color.lime)
  59. line.new(x1= array.get(starttimes, a), y1= array.get(highs, a), x2= array.get(starttimes, a)+86400000/4+(timenow-array.get(starttimes, a)), y2= array.get(highs, a), xloc= xloc.bar_time, color= HighCol, style= line.style_solid, width= HighWidth)
  60.  
  61. islpivot = true
  62. lowest = true
  63. c = 0
  64. n = 0
  65. for c = 0+rightbars to (array.size(lows)-leftbars)-1
  66. for b = c to 0
  67.  
  68. if (array.get(lows, c) > array.get(lows, b))
  69. lowest := false
  70.  
  71. //label.new(x=bar_index[b], y=high[b], text=str.tostring(b)+'-'+str.tostring(highest)+' '+str.tostring(bar_index[b])+' '+str.tostring(high[b]))
  72. break
  73. else
  74. lowest:= true
  75.  
  76.  
  77. for n = (c+leftbars) to (c-rightbars > 0 ? c - rightbars : 0)
  78. if (array.get(lows, n) < array.get(lows, c))
  79. islpivot:=false
  80. break
  81. else
  82. islpivot:= true
  83. if (untested == true ? lowest == true and islpivot == true : islpivot == true )
  84. //label.new(x=bar_index[a], y=high[a], text=str.tostring(high[a])+' '+str.tostring(ispivot)+' '+str.tostring(x)+' '+str.tostring(last_bar_index))
  85. line.new(x1= array.get(starttimes, c), y1= array.get(lows, c), x2= array.get(starttimes, c)+86400000/4+(timenow-array.get(starttimes, c)), y2= array.get(lows, c), xloc= xloc.bar_time, color= LowCol, style= line.style_solid, width= LowWidth)
  86.  
  87.  
  88.  
  89.  
Advertisement
Add Comment
Please, Sign In to add comment