Resampling pitfalls: label, closed, and the off-by-one bar
Posted: Sat Oct 31, 2026 7:03 pm
Converting ticks to bars looks trivial, but options in resampling functions change the result. The choice of whether the bar is labeled by its start or its end, and whether the interval is closed on the left or the right, determines which ticks belong to which bar.
A mismatch between the convention used in data preparation and the one assumed in the strategy creates off-by-one errors. A signal calculated on a bar labeled with its end time may be treated as available at its start, producing look-ahead.
Platform candles use a convention: the bar is labeled with its open time and includes ticks from that time up to, but not including, the next bar's open. Replicating it in a data pipeline requires explicit settings.
Check by comparing the resampled bars with those from the platform for the same period. Open, high, low, and close should match.
Also watch for bars with no ticks. Some methods drop them, others fill them with the previous close, and the choice affects indicators.
Document the conventions in the code. Subtle mismatches have caused many discrepancies between research and live results.
Do the bars built from ticks match the platform's candles exactly?
A mismatch between the convention used in data preparation and the one assumed in the strategy creates off-by-one errors. A signal calculated on a bar labeled with its end time may be treated as available at its start, producing look-ahead.
Platform candles use a convention: the bar is labeled with its open time and includes ticks from that time up to, but not including, the next bar's open. Replicating it in a data pipeline requires explicit settings.
Check by comparing the resampled bars with those from the platform for the same period. Open, high, low, and close should match.
Also watch for bars with no ticks. Some methods drop them, others fill them with the previous close, and the choice affects indicators.
Document the conventions in the code. Subtle mismatches have caused many discrepancies between research and live results.
Do the bars built from ticks match the platform's candles exactly?