0

TradingView has some indicators that stick to an edge of the chart window. An example of such indicator is the volume indicator and Visible Range Volume Profile indicator.

Is there a way to program my custom indicator so that it sticks to any of the four edges of the chart window?

Volume and Visible Range Volume Profile indicators

For now, the best option I've found is to plot the chart ahead of the last candlestick but obviously it isn't fixed and if I scroll the chard back then the plot disappears.

1 Answers1

1

Not all Tradingview indicators are written in pinescript. There are certain things they can do but you cannot. This is one of them.

You can try using the chart.right_visible_bar_time built-in variable. That will give you the time of the rightmost bar that is visible on your chart. Anytime you move, your script will be re-executed. So, if you use this variable, you can fix your output to the rightmost bar.

Something like this:

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

right_edge = chart.right_visible_bar_time
atr_val = ta.atr(14)

if barstate.islast
    box.new(right_edge - 60000000, open+ atr_val, right_edge, open- atr_val, xloc=xloc.bar_time, bgcolor=color.yellow)

When the last bar is visible. enter image description here

Same output even if I move to somewhere else: enter image description here

vitruvius
  • 15,740
  • 3
  • 16
  • 26
  • Thank you @vitruvius, I thought that would be the case but still decided to ask, maybe I was missing something. Would be a great feature though. – Andrei Stalbe Nov 21 '22 at 20:59