Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © Texmoonbeam
- //@version=5
- indicator("Unraided Liquidity and S/R Pivots", overlay=true, max_labels_count=500, max_lines_count=500)
- timeframe = input.timeframe(defval = '60')
- r = input.int(defval = 100, title = "Look back")
- leftbars = input.int(defval = 6, title = "Left Bars", minval = 1, tooltip="More bars left of the pivot means it came from a longer trend")
- rightbars = input.int(defval = 6, title = "Right Bars", minval = 1, tooltip="More bars right of the pivot means it went into a longer trend")
- untested = input.bool(defval = true, title = 'Untested Only?')
- HighCol = input.color(color.green, "Highs", inline="2")
- HighWidth = input.int(defval=1, title="Width", minval=1, maxval = 4, inline="2")
- LowCol = input.color(color.red, "Lows", inline="3")
- LowWidth = input.int(defval=1, title="Width", minval=1, maxval = 4, inline="3")
- get_highslows()=>
- highs= array.new_float(0)
- lows= array.new_float(0)
- starttimes= array.new_int(0)
- for n = 0 to r+leftbars
- array.push(highs, high[n])
- array.push(lows, low[n])
- array.push(starttimes, time[n])
- [highs, lows, starttimes]
- [highs, lows, starttimes] = request.security(syminfo.tickerid, timeframe, get_highslows(), lookahead = barmerge.lookahead_off, ignore_invalid_symbol = true)
- if (barstate.islast)
- ishpivot = true
- highest = true
- a = 0
- x = 0
- for a = 0 to (array.size(highs)-leftbars-1)
- for b = a to 0
- if (array.get(highs, a) < array.get(highs, b))
- highest := false
- //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]))
- break
- else
- highest:= true
- for x = (a+leftbars) to (a-rightbars > 0 ? a - rightbars : 0)
- if (array.get(highs, x) > array.get(highs, a))
- ishpivot:=false
- break
- else
- ishpivot:= true
- if (untested == true ? highest == true and ishpivot == true : ishpivot == true )
- //label.new(x=bar_index[a], y=high[a], text=str.tostring(high[a])+' '+str.tostring(ishpivot)+' '+str.tostring(x), color=color.lime)
- 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)
- islpivot = true
- lowest = true
- c = 0
- n = 0
- for c = 0+rightbars to (array.size(lows)-leftbars)-1
- for b = c to 0
- if (array.get(lows, c) > array.get(lows, b))
- lowest := false
- //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]))
- break
- else
- lowest:= true
- for n = (c+leftbars) to (c-rightbars > 0 ? c - rightbars : 0)
- if (array.get(lows, n) < array.get(lows, c))
- islpivot:=false
- break
- else
- islpivot:= true
- if (untested == true ? lowest == true and islpivot == true : islpivot == true )
- //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))
- 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)
Advertisement
Add Comment
Please, Sign In to add comment