OHLCV Data for Backtesting: A Beginner’s Guide

OHLCV Data for Backtesting: A Beginner’s Guide

If you are building a crypto trading bot or testing a strategy, OHLCV data is where you start. It is the standard historical format used by every major backtesting framework — freqtrade, vectorbt, backtrader, and Nautilus Trader all expect it.

What OHLCV Stands For

  • O — Open: price of the first trade in the period
  • H — High: highest price during the period
  • L — Low: lowest price during the period
  • C — Close: price of the last trade in the period
  • V — Volume: total quantity traded

Which Timeframe Should You Use?

  • 1m / 5m: scalping, market making — noisy, requires large datasets
  • 15m / 1h: most common for retail algo traders — balanced signal/noise
  • 4h / 1d: swing trading, trend following — clean signals, fewer trades

Loading OHLCV Data in Python

import polars as pl

df = pl.read_parquet("BTC_OHLCV_1h.parquet")
print(f"Candles: {len(df):,}")
print(f"Range: {df['candle_time'].min()} to {df['candle_time'].max()}")

The Backtesting Trap: Look-Ahead Bias

Using the close price of a candle to generate a signal that executes at that same close is impossible in live trading. Always shift your signal by one period: .shift(1). An audited OHLCV dataset verifies that every candle boundary is correct — no future information leaks into any candle.

How Many Candles Do You Need?

A Last Year Bitcoin OHLCV dataset at 1-minute resolution contains approximately 526,000 one-minute candles. At 1-hour resolution, around 57,000 — enough for statistically meaningful backtesting across multiple market regimes. Testing on less than two years risks overfitting to a single market regime.

Audited OHLCV Pack for BTC, ETH, XRP, SOL and more — 6 timeframes, Last Year (rolling 12 months), zero look-ahead bias. → Browse the catalog

Summary

OHLCV data is the practical starting point for almost every crypto backtesting project. It is compact, widely supported, and sufficient for the majority of strategies. A clean, audited OHLCV dataset with multiple timeframes is exactly what you need to start.