📢
Loading...
On this page
candlestick_chart
chart
Chart properties — type, colors, visible range
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 Trueif the chart displays standard OHLC candles,Falseif an alternative chart type is active.
chart.is_renko
- Type:
bool Trueif the chart type is Renko,Falseotherwise.
chart.is_kagi
- Type:
bool Trueif the chart type is Kagi,Falseotherwise.
chart.is_linebreak
- Type:
bool Trueif the chart type is Line break,Falseotherwise.
chart.is_pnf
- Type:
bool Trueif the chart type is Point & figure,Falseotherwise.
chart.is_range
- Type:
bool Trueif the chart type is Range,Falseotherwise.
chart.is_heikinashi
- Type:
bool Trueif the chart type is Heikin Ashi,Falseotherwise.
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.