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 “visible” bar. In PyneCore this is a heuristic:
current_bar_time - 20 × timeframe_seconds. There is no real viewport — the value approximates a 20-bar visible window ending at the current bar.
chart.right_visible_bar_time
- Type:
int - The timestamp (in milliseconds since epoch) of the rightmost “visible” bar. In PyneCore this is always the current bar’s timestamp.
Compatibility
Chart type properties (is_standard, is_renko, etc.) are fully supported. Visible range properties (left_visible_bar_time, right_visible_bar_time) use a static heuristic (20-bar window at the current bar) since PyneCore has no graphical viewport. Scripts that rely on precise visible range detection may behave differently than on TradingView.