Data Feeds & Bounds
Documenting raw market feeds, canvas boundaries, mouse variables, built-in Pine price & calendar series, syminfo / barstate / session metadata, and ctx.log telemetry.
ctx.bars
An array of objects representing the historical market price feed loaded on the chart.
{
open: 101.25, // Open price
high: 103.50, // High price
low: 99.80, // Low price
close: 102.10, // Close price
volume: 240500, // volume units
time: 1784931200 // Unix epoch in milliseconds
}
ctx.bounds
An object describing viewport boundaries and sizing metrics for the active price chart pane:
{
chartW: 960, // Pixel width of drawing area
chartH: 480, // Pixel height of drawing area
startIndex: 45, // Leftmost visible bar index
endIndex: 125, // Rightmost visible bar index
numVisible: 80, // Total visible bars
candleSlot: 8, // Width of each candle slot
xOffset: 0 // Scroll offset in pixels
}
ctx.mouse
Real-time coordinates and action state of the mouse cursor over the canvas (also available in Direct Pine Mode as mouse.x, mouse.y, mouse.is_down, and mouse.clicked):
{
x: 242.5, // Pixel X relative to canvas
y: 150.0, // Pixel Y relative to canvas
isDown: false, // Left mouse button is down
clicked: false // Click action occurred
}
ctx.drawings
An array of active drawing tools placed on the chart.
// Shape of entries:
{
id: "line_1",
type: "trend_line",
points: [ { barIndex: 50, price: 105.0 } ],
style: { color: '#ff0000', width: 2 },
locked: false
}
ctx.indicators
An array representing all standard active indicators configured on the chart.
{
type: "rsi",
params: { period: 14 },
color: "#9c27b0",
enabled: true,
values: [ /* calculated numerical values */ ]
}
ctx.customScripts
Array of all loaded custom scripts. As of v1.0.6, entries preserve editable sourceCode, lang, langMode, and pane placement (overlay=false allocates a sub-pane):
{
id: "script_0",
name: "EMA Cross Over",
code: "// compiled JS code",
sourceCode: "//@version=5...",
lang: "pine",
langMode: "auto",
enabled: true
}
Built-in Price & Calendar Series (v1.0.6)
Direct Pine Mode exposes derived price series, bar-count bounds, and UTC/chart calendar components natively on every bar:
- Derived Prices:
hl2(high + low)/2,hlc3(high + low + close)/3,ohlc4, andhlcc4(high + low + 2*close)/4. - Dataset Endpoints:
last_bar_index,last_bar_time, and wall-clocktimenow. - Calendar Variables & Functions:
year,month,weekofyear,dayofmonth,dayofweek(plus constantsdayofweek.sunday..dayofweek.saturday),hour,minute, andsecond.
syminfo, barstate & session (v1.0.6)
Metadata-backed globals replace hardcoded placeholders so scripts adapt cleanly to any market or session:
syminfo.*:ticker,tickerid,prefix,root,description,currency,basecurrency,timezone,mintick,pointvalue, andtyperead live chart instrument metadata.barstate.*:isfirst,islast,ishistory,isrealtime,isnew,isconfirmed, andislastconfirmedhistory.session.*:session.in_range(sessionSpec, tz)(wired toctx.session.in_range), plussession.ismarket,session.ispremarket,session.ispostmarket,session.regular, andsession.extended.
ctx.log & is_hovered() (v1.0.6)
Scripts can stream structured per-bar telemetry and react directly to cursor proximity on canvas:
ctx.log/ Pinelog.*: Exposesinfo(),warn()/log.warning(), anderror()with{0}formatting, storing up toMAX_SCRIPT_LOGS = 500entries synced viacl:script-logs. See Pine Logs Telemetry.- Hover Hit-Testing:
ctx.isHovered(...)and Pineis_hovered(barIndex, priceLevel, width, height)test if the cursor is over a price coordinate without manual geometry math.