← All projects

Wick-Reversal Classifier for Gold

XGBoost model that scores wick-reversal setups on gold using bar, higher-timeframe and tick-microstructure features built from 292 million raw ticks.

Client
Independent gold trader
Year
2026
Category
Quant & ML
Stack
  • Python
  • XGBoost
  • LightGBM
  • pandas
  • Parquet
  • scikit-learn
  • Pine Script

The problem

Wick-heavy candles often mark short-term reversals, but most of them fail. The goal was a filter that says which wick setups are worth taking. It had to be judged on data the model never saw.

What I built

  • Tick data pipeline: a downloader that decodes compressed hourly tick files into daily Parquet (3.9 GB, 292M ticks, 2020 to 2026), then resamples them to 5-minute and 15-minute bars.
  • Signal definition: a wick-dominant candle with a shrinking body and a range of at least one ATR. The direction comes from the longer wick. Entry, stop and target are set with fixed ATR rules.
  • 86 features: bar-level wick geometry, trend, volatility and time of day; 1-hour and 4-hour context joined with merge_asof so only closed bars are used; and 22 intra-bar tick features.
  • Tick microstructure: recovery from the wick extreme, reversal speed over 1 to 60 seconds, tick density and spread widening at the extreme. These were the strongest predictors.
  • Target study: labels compared for fixed risk multiples and ATR multiples. Targets tied to ATR carried signal; targets tied to wick size behaved like a random walk.
  • Validation: train on 2020 to 2024, one untouched holdout from 2025 onward, and TimeSeriesSplit walk-forward CV to check stability.
  • Delivery: several production models for different trade frequencies, an inference function that returns entry, stop, target and probability per signal, and a Pine Script indicator for the chart.

Details

The main lesson: if a system uses a multiple of risk as its target, tie that multiple to volatility, not to the size of the wick.