Exciting Update: Version 1.0.0 is now available, introducing high-performance technical indicators and custom drawing tools. Read more
Version: 1.0.0

Data Points & Custom Candles

The chart engine processes candle streams from the datafeed and renders them using batched drawing functions or custom developer render scripts.

Data Structure

The datafeed populates chart.bars, which contains array objects mapping to the selected scale:

// Standard OHLC Candle Format:
{{
  time: 1682880000000, // Unix epoch milliseconds
  open: 28000.50,
  high: 28500.00,
  low: 27950.00,
  close: 28250.75,
  volume: 145.2
}}

// Yield Curve Data Format:
{{
  x: 0,
  maturity: "3M",
  yield: 4.85
}}

Custom Candle Renderers

Developers can override the default batch drawing method by registering a custom candlestick renderer in custom-candle-type.js:

// C:\backtestx_lightweight_chart\custom-candle-type.js
window.ChartingAPI.registerCandleType('my_custom_candles', function(ctx, visibleBars, slot, bodyW, chartH, priceToY, themeColors, xOffset, chartInstance) {{
  ctx.save();
  ctx.strokeStyle = '#ff9800'; // Custom orange border
  ctx.lineWidth = 1.5;
  
  visibleBars.forEach((bar, index) => {{
    const x = xOffset + index * slot + slot / 2;
    const yOpen = priceToY(bar.open);
    const yClose = priceToY(bar.close);
    
    // Draw custom candle outline box
    ctx.strokeRect(x - bodyW / 2, Math.min(yOpen, yClose), bodyW, Math.max(1, Math.abs(yClose - yOpen)));
  }});
  ctx.restore();
}});