Three ways to use external data
What you write depends on what is in the file:- If the file contains OHLCV candles, write a
@sec_contextcallback and attach it withContext.calc_on(source=...), the same way you attach an additional instrument. See External candles from CSV. - If the rows have their own shape and each row needs processing, describe the row with a
@dataclassand write a@data_contextcallback forContext.calc_on(source=...). See Typed external data. - If you only need the latest row value on each chart bar, skip the callback and read the rows directly with
request_series[T](source=...).
Quick example
This indicator plots the daily close prices from an external candle CSV on any chart:External candle close
The data is a snapshot
The file is fetched once, when the indicator instance is created. After that the data is frozen: the indicator works with the file’s history and receives no live updates, even if the file changes on your server. To pick up a new version, re-add the indicator to the chart. A cached copy may be served for up to about 10 minutes after the previous fetch.The platform does not archive your file. If it changes, the next run of the indicator or backtest can see different
data. Keep a stable copy of the file if you need reproducible backtests.
Rules common to all external sources
- External sources count toward the same limit as additional instruments requested with
Context.calc_on(). Identical requests are counted once; a request that differs in URL,time_column, time frame orlookaheadcounts as a separate instrument. - The time frame belongs to the call site, not to the file: you pass
time_frame=toContext.calc_on()orrequest_series(). For candle CSVs it is required, for typed data it is optional, and tick time frames are not supported. - The file must be a public HTTPS URL with a valid certificate; authentication headers cannot be sent. See CSV format and limits for the full requirements, size limits and error reference.
Indicators that use external data sources cannot be published to the TakeProfit marketplace.