The indicator on the chart displays multiple high/low price indicators, even if the asset price simply breaks it. Price values ​​are displayed as a comment on the chart, but they need to be displayed as price coordinates on the price scale, where the current price is displayed! I can’t add yet, indicators of levels relative to price - display only those support levels (green) that are below the current price, and resistance levels above the current price - this should help remove noise from the chart - but the problem is that it cannot calculate the price (coordinates ) levels since they are not displayed on the price coordinate scale.

 //@version=5
indicator('LVLES', shorttitle='S/R Lines with Price Labels', overlay=true)

var float supportPrice = na
var line supportLine = na
var bool greenCandleSupport = na

var float monthlyHigh = na
var line resistanceLine = na
var bool redCandleResistance = na

if close < open
supportPrice := low
greenCandleSupport := false
greenCandleSupport

if not na(supportLine) and not greenCandleSupport
line.delete(supportLine)

if not na(close[1]) and close[1] < open[1]
greenCandleSupport := true
supportLine := line.new(x1=bar_index[1], y1=supportPrice, x2=bar_index, y2=supportPrice,         color=color.green, width=1, extend=extend.right)
supportLine

if month != month[1] and close > open
monthlyHigh := high
redCandleResistance := false
redCandleResistance

if not na(resistanceLine) and not redCandleResistance
line.delete(resistanceLine)

if not na(close[1]) and close[1] > open[1]
redCandleResistance := true
resistanceLine := line.new(x1=bar_index[1], y1=monthlyHigh, x2=bar_index, y2=monthlyHigh,     color=color.red, width=1, extend=extend.right)
resistanceLine


label.new(x=bar_index, y=supportPrice, text=str.tostring(supportPrice), color=color.green,     style=label.style_label_down, yloc=yloc.belowbar)


label.new(x=bar_index, y=monthlyHigh, text=str.tostring(monthlyHigh), color=color.red, style=label.style_label_up, yloc=yloc.abovebar)

The indicator implies a strategy for automatically constructing support and resistance levels! The rule is that resistance lines are built at the highs of green candles if the next candle was or will be red and support lines are built at the lows of the red candle if the next candle was or will be green! I tried to display the indicators of these levels through: label.new(x=bar_index, y=supportPrice, text=str.tostring(supportPrice), color=color.green, style=label.style_label_down, yloc=yloc.belowbar)

label.new(x=bar_index, y=monthlyHigh, text=str.tostring(monthlyHigh), color=color.red, style=label.style_label_up, yloc=yloc.abovebar)

but the price appears on the chart and I cannot transfer it to the price coordinate scale

1

There are 1 best solutions below

5
vitruvius On

You cannot directly manipulate the price scale.

If you can plot your line, you can have its value and plot's name on the price scale.

//@version=5
indicator("My script", overlay=true)

daily_high = request.security(syminfo.tickerid, "D", high)

plot(daily_high, "Daily High")

enter image description here