chart

The chart namespace provides information about the current chart’s appearance, type, and visible range. Use these properties to detect which chart type is active, access the chart’s color scheme, and determine which bars are visible in the chart viewport.

Quick Example

  from pynecore.lib import chart, label, bar_index, high, script

@script.indicator(title="Chart Info", overlay=True)
def main():
    # Detect chart type
    is_standard: bool = chart.is_standard
    is_renko: bool = chart.is_renko
    is_kagi: bool = chart.is_kagi
    
    # Get the time range currently visible on the chart
    left_time: int = chart.left_visible_bar_time
    right_time: int = chart.right_visible_bar_time
    
    if is_standard:
        label.new(bar_index, high, "Standard Chart")
    elif is_renko:
        label.new(bar_index, high, "Renko Chart")
  

Variables

Colors

chart.bg_color

  • Type: Color
  • The background color of the chart from Chart settings → Appearance. When a gradient is selected, returns the color at the middle point of the gradient.

chart.fg_color

  • Type: Color
  • A color that contrasts well with the background, suitable for drawing text and UI elements that remain visible on any background.

Chart Type

chart.is_standard

  • Type: bool
  • True if the chart displays standard OHLC candles, False if an alternative chart type is active.

chart.is_renko

  • Type: bool
  • True if the chart type is Renko, False otherwise.

chart.is_kagi

  • Type: bool
  • True if the chart type is Kagi, False otherwise.

chart.is_linebreak

  • Type: bool
  • True if the chart type is Line break, False otherwise.

chart.is_pnf

  • Type: bool
  • True if the chart type is Point & figure, False otherwise.

chart.is_range

  • Type: bool
  • True if the chart type is Range, False otherwise.

chart.is_heikinashi

  • Type: bool
  • True if the chart type is Heikin Ashi, False otherwise.

Visible Range

chart.left_visible_bar_time

  • Type: int
  • The timestamp (in milliseconds since epoch) of the leftmost bar currently visible in the chart viewport. Updates as the user scrolls.

chart.right_visible_bar_time

  • Type: int
  • The timestamp (in milliseconds since epoch) of the rightmost bar currently visible in the chart viewport. Typically the current bar when viewing live data.

Compatibility

All chart properties are fully supported in PyneCore. They provide read-only access to chart state; chart properties cannot be modified from scripts.