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

Custom load drawings

The CustomLoadDrawings module provides two lifecycle hooks — loadCustomDrawings and saveCustomDrawings — for persisting drawings to any storage backend.

Overview

Implement both hooks in custom-load-drawings.js. The chart engine automatically calls loadCustomDrawings on startup and saveCustomDrawings on every drawing change.

loadCustomDrawings(chart)

Called once on chart initialization. Use this hook to restore drawings from your storage:

window.ChartingAPI.loadCustomDrawings = function(chart) {
  const key = `backtestx_drawings_${chart.symbol || 'default'}`;
  const saved = localStorage.getItem(key);
  if (saved) {
    chart.drawings = JSON.parse(saved);
  }
};

saveCustomDrawings(chart, drawings)

Called whenever drawings are created, moved, or deleted. Persist the drawings array to your backend:

window.ChartingAPI.saveCustomDrawings = function(chart, drawings) {
  const key = `backtestx_drawings_${chart.symbol || 'default'}`;
  localStorage.setItem(key, JSON.stringify(drawings));
};

You can replace localStorage with any async backend (e.g. fetch to a REST API or IndexedDB) without changing the chart engine.