Exciting Update: Version 1.0.1 is now available, introducing the high-performance BacktestX Custom Script Editor. Read more

Data Feeds & Bounds

Documenting the structural fields of raw market feeds, canvas boundaries, mouse variables, and indicator collections.

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:

{
  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 JavaScript indicator scripts:

{
  id: "script_0",
  name: "EMA Cross Over",
  code: "// script code strings",
  enabled: true
}