OHLC Prediction
Publish Date: Fri Sep 05 2025
Predict valid future OHLC candles a few steps ahead from a sequence of past OHLCV (and optional features). “Valid” means H ≥ max(O, C), L ≤ min(O, C), and all four lie on the same price axis.
Goal
Predict valid future OHLC candles a few steps ahead from a sequence of past OHLCV (and optional features).
“Valid” means H ≥ max(O, C), L ≤ min(O, C), and all four lie on the same price axis.
- Inputs: sequences of OHLCV (and optional technical features) over a lookback window.
- Shared-price normalization for O/H/L/C:
- All four price channels use the same mean/std (e.g., Close stats from train set).
- Preserves candle geometry under a single affine transform.
- Non-price features: (e.g., Volume, indicators) are normalized per-feature (z-score from train only).
- Targets: future OHLC over a fixed horizon, normalized with the same shared-price normalization.
Parameterization
Our raw prediction consists of m/b/u/l/s, of shape [batch, horizon, 5]:
Encode OHLC
-
(m) Mid-level: the halfway point between open and close
-
(b) Body-size: the (absolute) difference between open and close
-
(u) Upper-wick: the distance from top of bar, to high
-
(l) lower-wick: the distance from bottom of bar, to low
-
(s) Direction Logit:
- tanh(direction_prediction)
Dimensions
- Raw-prediction = [Batch, Horizon, 5] —> [m, b, u, l, s]
- Target-prediction = [Batch, Horizon, 4] —> [O, H, L, C]
Loss Function
- Calculate loss mid (L_mid): Huber Loss between m_true and m_pred
- Calculate body/wicks:
Obstacle 1 - Direction Collapse
-
There isn’t enough of an incentive to properly learn the direction. Currently, collapsing to predicting a single class is sufficient
-
The validation dataset has the following distribution for direction:
-
The accuracy of predicted-direction converges in one of three ways:
- A) 51.19% —> all ‘Down’
- B) 49.29% —> all ‘Up’
- C) 50.24% —> average of A & B = (A+B)/2
Solution
- Class balanced BCE (w/ logits) loss:
- Magnitude-aware direction weighting: weigh larger movements more than smaller movements