When candles are missing in a backtest, the first thing to determine is whether the gap is caused by "no trades happening" or "data not being retrieved". Both can appear as a hole in the timeline in your data file, but they need to be handled in completely opposite ways. Gaps caused by no trading activity should not be artificially filled, otherwise your indicators will be distorted. Gaps caused by data loss need to be re-fetched from the original source, otherwise your backtest will run on wrong data. The way to tell them apart is not by looking at the gap itself, but by checking whether other related data exists in the same time period.

A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!
Check Volume and Trade Count First
If the missing candle's time window shows a volume of 0, or there is no record for that timestamp at all, while the same trading pair has normal trading activity in adjacent time windows, then this is very likely a genuine no-trading period. CoinAPI's technical documentation clearly states that when no BTCUSDT trades occur within a one-minute window and only order book changes exist with no executed volume, that period will appear as volume = 0, trades_count = 0, or it may be skipped in your charting library due to improper interpolation. For low-liquidity small-cap coins, 24 hours with zero trades is not uncommon. Korean exchanges Korbit and Coinone were reported to have over 100 altcoins with zero 24-hour trading volume, and some coins had no trades at all for an entire day. When backtesting such assets, encountering missing candles due to no trading is completely normal.
On the other hand, if order book activity or price movement exists in the missing time window but there is no corresponding OHLCV record, then it is data loss. CoinAPI's documentation mentions that its data pipeline obtains valid OHLC values from the order book when no trades occur, rather than fabricating data. If your data source did not even retain order book information, and the market clearly had activity at that time (for example, other exchanges or other trading pairs on the same exchange had trades during the same period), then the missing data is more likely caused by download interruption, API rate limiting, or storage issues.
A Practical Way to Distinguish: Compare Different Sources for the Same Period
The most direct verification method is to check the missing time period against another data source. If you find several minutes missing when pulling data from the Binance API, go to TradingView or another exchange's corresponding trading pair and check whether candles exist for that same time period. If another source has normal trade records during that period, it means your original data source lost data. If multiple independent sources all show no trade records during that period, then it is very likely that the market simply had no trading.
However, there is one important caveat: candles displayed on exchange UIs may not be strictly based on actual trades. CoinAPI points out that exchange interfaces often use mark prices, index prices, mid prices, or smoothed interpolation to draw candles, while raw API data only reflects actual executed trades. This means a "normal" candle you see on the UI may not have any corresponding trade records in the API data at all. When making judgments, you should rely on raw API data rather than exchange website charts.
No-Trade Gaps: Do Not Fill, But Handle Indicator Calculations
If you confirm that the gap is caused by no trading, the correct approach is not to generate synthetic candles. LumiBot's backtesting documentation explicitly states that you should not create fake intraday candles, as synthetic candles will distort indicators like ATR, RSI, and SMA, and may cause simulated fills at times when the real market was closed. Wealth-Lab discussions also touch on a similar issue: when a data source (such as KuCoin) does not return historical data for no-trade periods, the backtesting engine will look further back for more available data to gather the required number of bars when calculating indicators like Lowest(Low, 25), rather than filling in the missing bars. This means the indicator's calculation window is stretched on the calendar, but at least it is not polluted by fake data.
What you need to do is identify and mark these gaps in your backtest code or data preprocessing stage, so that your strategy logic knows "there was no trading during this period, so no signals should be triggered." If your strategy depends on a continuous time series (for example, calculating a moving average based on a fixed number of bars), you need to confirm how your backtesting engine handles such gaps: does it skip the gap and continue pulling data from further back, or does it treat the gap as a "no-action" period? Both approaches can be reasonable, but you need to know which one your engine uses.
Data Loss: Re-Fetch from the Original Source, Do Not Fill with Averages
If you confirm that the gap is data loss, there is only one way to fix it: re-fetch the missing period's data from the original source. An engineering article on SegmentFault describes a similar scenario: when the team detected a break in the candle timeline, their solution was not average filling, but rather obtaining tick data for the missing period and re-aggregating candles using a unified UTC time window. This approach is more reliable than "borrowing" candles from another exchange, because different exchanges may have different prices and volumes, and mixing them introduces bias.
If tick data is unavailable, the next best option is to aggregate from another time granularity on the same exchange (for example, aggregating 5-minute candles from 1-minute data) or re-download from official data archives. But be careful to confirm timezone consistency of timestamps when re-downloading. The SegmentFault article specifically mentions that data should always be converted to UTC when stored, to prevent secondary gaps caused by offset between exchange time and system time.
When You Should Simply Abandon the Data or Asset
If a coin frequently has missing candles caused by no trading, its backtest performance is inherently untrustworthy. 3Commas help documentation mentions that for illiquid charts, you can set a "minimum 24-hour volume" filter to avoid trading such coins. The same logic applies at the backtesting level: if an asset's trade records are so sparse that gaps appear frequently, then any strategy backtest built on it lacks a realistic basis for its fill assumptions (whether you could actually buy or sell at a given price). In this case, the more honest approach is to exclude that asset from your backtest pool rather than spending time repairing data.
Criteria for Completing the Diagnosis
After processing a round of missing data, you should be able to answer: for each missing candle gap, which time period, which asset, and based on what evidence was it classified as "no trades" or "data loss"; whether no-trade gaps were correctly marked and not filled with synthetic data; whether data loss gaps were re-fetched from the original source and had their timestamp consistency verified; and whether the data coverage rate after repair has returned to an acceptable level (for example, above 99%, with remaining gaps concentrated in explainable no-trade periods).
If you cannot confirm the nature of a gap, the most conservative approach is to treat it as data loss and attempt to re-fetch. If the gap still exists after re-fetching, and other sources also show no trade records during the same period, then classify it as no trades. It is better to pull data one more time than to let your backtest engine "guess" about the past under uncertainty.

A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!
References
- CoinAPI.io·Why Crypto Candles Don't Match Exchange Charts, 2026-11-03
- LumiBot·Backtesting Session Gaps and Data Gaps, 2026-11-03
- Wealth-Lab·A clarification about empty bars in backtest data, 2026-11-03
- SegmentFault·Quant Engineering Practice: How Algorithmic Trading Executors Handle Missing Crypto Candles, 2026-11-03
- 3Commas·Troubleshooting: Wrong Condition Triggered My Trade, 2026-11-03
- Gate.com·Korean Exchanges Korbit and Coinone Report 100+ Altcoins with Zero Trading Volume, 2026-11-03


