fx-chartingDocs
Data

Custom datafeed

For full control, pass any object with these four methods.

js
const datafeed = {
  async searchSymbols(query, type) { return [/* symbol infos */]; },
  async resolveSymbol(name) { return { symbol: name, description: "…", exchange: "…", type: "forex", pricescale: 100000 }; },
  async getBars(symbolInfo, interval, { to, countBack }) {
    // bars sorted oldest → newest, time in ms; strictly older than `to` when given; [] when nothing older
  },
  subscribeBars(symbolInfo, interval, onBar) {
    // call onBar(bar) with the forming bar (same time = update, newer = new bar)
    return () => {/* unsubscribe */};
  },
};

createDatafeed returns exactly this object, so you can also wrap one and override a method.