Skip to content
All library documents

Visible-Chart Pine Library for Range Statistics and Chart Anchors

Article TradingView scripts

Summary

This Pine library supplies functions that calculate values relative to the bars currently shown on a chart. It can identify visible-range boundaries, cumulative visible volume and bar count, and the running highest high and lowest low with their bar indices or times. Other helpers return visible OHLCV values and map percentages across the visible price, time, or bar-index ranges. These functions can support indicators whose drawings or summaries should adjust as the user pans or zooms the chart.

The accompanying example uses the library to display visible-range statistics, mark the visible extremes, and draw Fibonacci levels between chart anchors. The library’s running calculations are intended to execute on each visible bar; returned values can be unavailable outside the visible region. The results are viewport-dependent, so they describe the currently displayed chart rather than a fixed historical sample. This is utility code for chart analysis and visualization, not a trading signal or evidence of a trading strategy’s performance.

Key ideas

  • Visible-bar checks let scripts restrict calculations to the chart’s current viewport.
  • Running extrema helpers return the visible high and low along with their bar indices or timestamps.
  • The library can aggregate visible bar count and volume and return visible OHLCV values.
  • Percentage helpers map positions across visible price, time, and bar-index ranges.
  • Viewport-based results change when the user pans or zooms and do not represent fixed historical samples.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.