High - Low Distance Ratio - Trend Identifier (AlgoPoint)
High - Low Distance Ratio - Trend Identifier (AlgoPoint)
//@version=5
indicator('High/Low Distance Ratio | Trend Identifier [AlgoPoint]', precision=3,
overlay=false)
// Input//
length = input.int(defval = 34, title = 'Lengths', minval = 1, group = 'High/Low')
src = input.string(defval = 'High/Low', options = ['Close', 'High/Low'], group =
'High/Low')
show_maxmin = input.bool(defval = false, title = 'Show Maximum High Line ?', group
= 'High/Low')
show_table = input.bool(defval = true, title = 'Show table?')
show_retracement = input.bool(defval = false, title = 'Show Retracement Ratio?',
group = 'Retracement')
reverse_retracement = input.bool(defval = false, title = 'Reverse Retracement?',
group = 'Retracement')
hi_source = close
lo_source = close
if src == 'Close'
hi_source := close
lo_source := close
if src == 'High/Low'
hi_source := low
lo_source := high
//Var//
Distance_from_PH = 0.
Distance_to_PH = 0.
PH_reached = false
Distance_from_PL = 0.
Distance_to_PL = 0.
PL_reached = false
//Pivots//
highest_1 = ta.highest(high, length)
lowest_1 = ta.lowest(low, length)
if bar_index >= 1
Distance_from_PH := math.round(100 * (1 - (lo_source / highest_1)),2)
Distance_from_PL := math.round(100 * ((hi_source/lowest_1)-1),2)
if Distance_from_PH == 0
PH_reached := true
PH_reached
plotshape(PH_reached, title='Top renew', color=color.new(#94ee6d, 10),
style=shape.circle, location = location.top)
if Distance_from_PL == 0
PL_reached := true
PL_reached
plotshape(PL_reached, title='Bottom renew', color=color.new(#f18080, 10),
style=shape.circle, location = location.top)
//Retracement//
Retracement = 1-math.round((close-lowest_1)/(highest_1-lowest_1),2)
if reverse_retracement
Retracement := math.round((close-lowest_1)/(highest_1-lowest_1),2)
//Plots//
plot(Distance_from_PH, 'Distance from Bottom (%)', color=color.new(color.maroon,
0), linewidth=1)
plot(Distance_from_PL, 'Distance from Top (%)', color=color.new(color.green, 0),
linewidth=1)
plot(show_retracement ? Retracement*100 : na, 'REt', color=color.new(color.white,
0), linewidth=1)
if (barstate.islast)
line.new(bar_index[length], 0, bar_index[length], 0 * 1.01, extend =
extend.both, color=color.new(color.white, 30), style = line.style_dashed)
if show_table
var Table = table.new(position = position.top_right, columns = 4, rows = 4,
frame_width = 1, bgcolor = color.rgb(0,0,0, 50), border_width = 1, border_color =
color.gray, frame_color = color.gray)