Skip to content

chart - PineScript Variable

The chart record exposes read-only information about the user’s current chart configuration, such as whether a non-standard price style is active or which bars are visible. Use these fields to adapt overlays to the user’s environment.

FieldTypeDescription
chart.bg_colorseries colorBackground color of the pane where the script runs.
chart.fg_colorseries colorForeground color (text/axes) of the pane.
chart.is_standardseries booltrue when the chart uses standard candles/bars.
chart.is_heikinashiseries booltrue on Heikin Ashi charts.
chart.is_renkoseries booltrue on Renko charts.
chart.is_linebreakseries booltrue on Line Break charts.
chart.is_kagiseries booltrue on Kagi charts.
chart.is_rangeseries booltrue on Range charts.
chart.is_pnfseries booltrue on Point & Figure charts.
chart.left_visible_bar_timeseries intUNIX timestamp (ms) for the leftmost visible bar.
chart.right_visible_bar_timeseries intUNIX timestamp (ms) for the rightmost visible bar.
  • Only one of the style flags (chart.is_*) is typically true at a time; use them to adjust calculations for synthetic chart types.
  • Visible range timestamps update as the user scrolls or zooms, enabling dynamic filters (e.g., show labels only inside the viewport).
  • Colors reflect user theme settings, letting you adjust overlay elements for contrast.
//@version=5
indicator("Chart metadata", overlay=true, max_labels_count=1)
description = str.format(
"Style: {0}\nLeft: {1}\nRight: {2}",
chart.is_heikinashi ? "Heikin Ashi" :
chart.is_renko ? "Renko" :
chart.is_linebreak ? "Line Break" :
chart.is_kagi ? "Kagi" :
chart.is_range ? "Range" :
chart.is_pnf ? "Point & Figure" : "Standard",
str.format_time(chart.left_visible_bar_time, "yyyy-MM-dd HH:mm"),
str.format_time(chart.right_visible_bar_time, "yyyy-MM-dd HH:mm"))
if barstate.islastconfirmedhistory
label.new(bar_index, high,
text=description,
textcolor=color.white,
bgcolor=chart.bg_color,
style=label.style_label_left)