Skip to content

Pine Graphics Deep Dive

The strategy layer reads all indicator data through four Pine graphics MCP tools. These tools extract visual objects that Pine Script indicators draw on the chart -- labels, lines, tables, and boxes. This page documents the return format of each tool and shows practical examples for each indicator.


How Pine Graphics Reading Works

Pine Script indicators communicate visually. They draw labels with text, lines at price levels, boxes around zones, and tables with structured data. The tradingview-mcp server reads these graphics objects through Chrome DevTools Protocol, extracting their properties into JSON.

The strategy layer never reads indicator "plot" values or internal variables. Everything comes through graphics objects, which means the indicators do not need modification -- they just need to be on the chart.


data_get_pine_labels

Reads Pine Script label objects from the chart.

Default Return Format

{
  "labels": [
    {
      "text": "HUNT_LOW",
      "price": 5870.00
    },
    {
      "text": "Bullish SMT",
      "price": 5868.50
    }
  ]
}

Each label has text (the displayed string) and price (the y-axis position).

Verbose Return Format

With verbose: true:

{
  "labels": [
    {
      "id": "label_42",
      "text": "HUNT_LOW",
      "price": 5870.00,
      "x": 1713100800,
      "yloc": "price",
      "size": "normal",
      "textColor": "#00FF00",
      "color": "#00FF0033"
    }
  ]
}

Verbose adds: id (internal identifier), x (bar timestamp), yloc (positioning mode), size, textColor (text color hex), color (background color hex).

study_filter Parameter

Limits results to labels from a specific indicator:

{
  "tool": "data_get_pine_labels",
  "params": {
    "study_filter": "Session Hunt AI"
  }
}

The study_filter performs a substring match on the indicator's display name. "Session Hunt" would also match "Session Hunt AI".

Strategy Usage by Indicator

Bias AI: Labels mark the draw-on-liquidity level (PDH/PDL text) and bias direction markers.

Session Hunt AI: Labels show HUNT_HIGH, HUNT_LOW, or INVALID to indicate the current hunt state. Label price gives the swept level.

SMT Divergences: Labels mark divergence signals with text like "Bullish SMT" or "Bearish SMT". The label price indicates where the divergence occurred.


data_get_pine_lines

Reads Pine Script line objects from the chart. Returns horizontal levels -- price levels drawn as horizontal lines.

Default Return Format

{
  "horizontal_levels": [
    {
      "price": 5892.50
    },
    {
      "price": 5870.00
    }
  ]
}

Verbose Return Format

With verbose: true:

{
  "horizontal_levels": [
    {
      "id": "line_15",
      "y1": 5892.50,
      "y2": 5892.50,
      "x1": 1713090000,
      "x2": 1713110000,
      "style": "solid",
      "width": 2,
      "color": "#FF5252"
    }
  ]
}

Verbose adds: id, y1/y2 (start and end y-coordinates), x1/x2 (start and end bar timestamps), style ("solid", "dotted", "dashed"), width (pixel width), color (hex).

Key Detail: Line Style for OB Mitigation

OB AI uses line style to communicate order block state:

  • Solid line: OB boundary is unspent (valid for entry).
  • Dotted line: OB boundary is spent (price has returned to the zone).

The strategy layer reads style in verbose mode to determine the spent field on OrderBlock objects.

Strategy Usage by Indicator

Session Hunt AI: Draws horizontal lines at the session range high and low. The strategy reads these as hunt.target_high and hunt.target_low.

OB AI: Draws horizontal lines at OB boundaries. Line style (solid vs dotted) indicates spent/unspent status. When an OB is fully mitigated, OB AI deletes both lines.


data_get_pine_tables

Reads Pine Script table objects from the chart. Tables are structured grids of text, typically rendered in a corner of the chart.

Default Return Format

{
  "tables": [
    {
      "rows": [
        "Daily | Bullish | PDH",
        "Weekly | Bullish | --"
      ]
    },
    {
      "rows": [
        "ATR | 2.25",
        "QTY | 2"
      ]
    }
  ]
}

Each table contains rows, where each row is a string of column values joined by |.

Parsing Table Rows

The strategy layer splits each row on | to extract individual cell values:

const cells = row.split(' | ');
// "Daily | Bullish | PDH" -> ["Daily", "Bullish", "PDH"]

Strategy Usage by Indicator

Bias AI: Renders a table with rows for daily and weekly bias. Each row contains the timeframe label, the bias direction (Bullish/Bearish/0), and the draw-on-liquidity target (PDH/PDL/--).

Example Bias AI table:

Daily | Bullish | PDH
Weekly | Bullish | --

The strategy reads:

  • Row 0, cell 1: "Bullish" -> bias.daily = "bullish"
  • Row 0, cell 2: "PDH" -> bias.draw_on_liquidity = "PDH"
  • Row 1, cell 1: "Bullish" -> bias.weekly = "bullish"

OB AI: Renders an ATR banner table with stop distance and position sizing.

Example OB AI ATR table:

ATR | 2.25
QTY | 2
RISK | $225.00

The strategy reads:

  • Row 0, cell 1: "2.25" -> structure.atr.stop_points = 2.25
  • Row 1, cell 1: "2" -> structure.atr.position_size = 2

data_get_pine_boxes

Reads Pine Script box objects from the chart. Boxes represent rectangular zones on the chart defined by price range (high/low) and time range.

Default Return Format

{
  "zones": [
    {
      "high": 5878.00,
      "low": 5872.00
    }
  ]
}

Each zone has high (upper boundary) and low (lower boundary).

Verbose Return Format

With verbose: true:

{
  "zones": [
    {
      "id": "box_8",
      "high": 5878.00,
      "low": 5872.00,
      "x1": 1713095000,
      "x2": 1713110000,
      "borderColor": "#4CAF50",
      "bgColor": "#4CAF5033"
    }
  ]
}

Verbose adds: id, x1/x2 (time boundaries), borderColor (border hex), bgColor (background hex with alpha).

Key Detail: Box Color for OB Direction

OB AI uses box color to indicate order block direction:

  • Green-family colors (borderColor with green channel dominant): Bullish OB
  • Red-family colors (borderColor with red channel dominant): Bearish OB

The strategy layer reads borderColor in verbose mode to classify OBs into structure.order_blocks.bullish or structure.order_blocks.bearish.

Strategy Usage by Indicator

OB AI: Draws boxes around order block zones and FVG zones. Each OB appears as a box with high/low defining the price range. The strategy reads all OB AI boxes, classifies them by color (bullish/bearish), and pairs them with line data to determine spent/unspent status.


Practical Example: Full Scan Read

A single scan cycle reads all four indicators in parallel:

const [biasLabels, biasTable, sessionLabels, sessionLines,
       obBoxes, obLines, obTable, smtLabels] = await Promise.all([
  mcp.call('data_get_pine_labels', { study_filter: 'Bias AI', verbose: true }),
  mcp.call('data_get_pine_tables', { study_filter: 'Bias AI' }),
  mcp.call('data_get_pine_labels', { study_filter: 'Session Hunt AI', verbose: true }),
  mcp.call('data_get_pine_lines',  { study_filter: 'Session Hunt AI', verbose: true }),
  mcp.call('data_get_pine_boxes',  { study_filter: 'OB AI', verbose: true }),
  mcp.call('data_get_pine_lines',  { study_filter: 'OB AI', verbose: true }),
  mcp.call('data_get_pine_tables', { study_filter: 'OB AI' }),
  mcp.call('data_get_pine_labels', { study_filter: 'SMT', verbose: true }),
]);

All 8 calls are issued concurrently through Promise.all. The total scan time is bounded by the slowest individual call (typically 200--500ms), not the sum of all calls. Each call uses study_filter to ensure only the target indicator's graphics are returned.