Direct Answer

Machine learning features from price and volume are engineered numeric inputs, such as returns, rolling volatility, RSI, moving-average ratios, and volume-based measures, computed from raw OHLCV (open, high, low, close, volume) data so a predictive model has stable, comparable signals to learn from. Feature engineering matters because raw prices drift in scale over time and are poorly suited as direct model inputs, while normalized, stationary transformations of price and volume tend to generalize better across different market conditions.

Key Takeaways

  • A "feature" is a single engineered number derived from raw price/volume history, used as model input.
  • Raw closing prices are non-stationary; returns, ratios, and normalized indicators are typically preferred inputs.
  • Common price features include log returns, rolling volatility, RSI, and moving-average distance ratios.
  • Common volume features include relative volume, on-balance volume slope, and VWAP deviation.
  • Feature leakage, accidentally using future information, is one of the most common and damaging mistakes in this process.
  • More features is not automatically better; unfiltered feature sets raise overfitting risk.
  • Feature engineering choices should be validated with out-of-sample and walk-forward testing, not in-sample fit alone.
  • These features feed models used for tasks like direction classification, volatility forecasting, or regime detection.

What Are Machine Learning Features from Price and Volume?

In a machine learning context, a "feature" is any individual measurable input a model uses to make a prediction. For market data, the raw material is a time series of open, high, low, close, and volume (OHLCV) values. Feature engineering is the process of transforming that raw series into a set of derived numbers, features, that better expose patterns a model can learn from than the raw prices themselves would.

This distinction matters because a model trained directly on raw closing prices tends to perform poorly outside the exact price range it was trained on. A stock trading near $50 during a training period gives the model no basis for generalizing to that same stock trading near $200 later, or to a different stock entirely. Features built from ratios, returns, and normalized indicators are designed to describe market behavior in a way that's comparable across price levels, securities, and time periods.

How Price and Volume Features Are Constructed

Most price and volume features fall into a few recurring categories, each built with a defined calculation:

  • Return-based features, log return over a lookback window: rt = ln(Pt / Pt-n). Log returns are additive across time and tend to be more stationary than raw prices.
  • Volatility features, rolling standard deviation of returns over a fixed window (e.g., 20 periods), often annualized, capturing how dispersed recent price changes have been.
  • Momentum/oscillator features, indicators like RSI or a moving-average distance ratio (Pt / SMAn − 1), which compress a price trend into a bounded or centered number.
  • Volume-based features, relative volume (current volume ÷ average volume over n periods), on-balance volume slope, or the percentage deviation of price from VWAP, which describe participation and conviction rather than price alone.
  • Range-based features, measures like the high-low range as a percentage of price, or Bollinger Band position, which describe intrabar or intraday dispersion.

Each feature is typically computed on a rolling basis using only data available up to and including the current bar, so that at every point in the historical series the feature reflects only information that would have actually been known at that time.

A Hypothetical Worked Example

Consider a hypothetical illustration, not real market data. Suppose a hypothetical stock's closing prices over five consecutive daily bars are $100.00, $101.50, $100.80, $103.20, and $104.00, with daily volume of 1.2 million, 1.1 million, 1.4 million, 2.6 million, and 1.3 million shares, against a 20-day average volume of roughly 1.3 million shares.

From this hypothetical data, a feature set for the final bar might include: a 1-day log return of ln(104.00 / 103.20) ≈ 0.0077 (about +0.77%); a 4-day log return of ln(104.00 / 100.00) ≈ 0.0392 (about +3.92%); and a relative volume reading for the fourth bar of 2.6 million ÷ 1.3 million = 2.0, meaning that day's volume ran at roughly twice the recent average. None of these figures are drawn from any real security, they exist only to show how raw OHLCV values become normalized feature inputs a model could use.

Why Feature Engineering Matters to Traders

For traders building or evaluating quantitative and algorithmic strategies, the choice of features is often more consequential than the choice of model architecture. A well-constructed feature set encodes a specific, economically motivated hypothesis, for example, that abnormal relative volume tends to precede continuation moves, or that extended distance from a moving average tends to mean-revert. A poorly constructed feature set, by contrast, can let a model appear to perform well in a backtest purely by fitting noise or by inadvertently accessing information that would not have been available at trade time.

Because these features are also the same building blocks used in traditional technical analysis, returns, RSI, VWAP deviation, relative volume, understanding feature engineering gives traders a bridge between classic chart-based indicators and the inputs used in more systematic, model-driven approaches to reading price and volume.

Limitations and Common Mistakes

  • Feature leakage. Computing a feature using information not actually available at prediction time (such as a full session's closing price to predict that same session's direction) inflates backtest performance in a way that does not hold up live.
  • Overfitting to noise. Adding a large number of correlated or redundant features increases the risk that a model fits historical coincidence rather than a persistent relationship.
  • Non-stationarity left unaddressed. Using raw price levels instead of returns or ratios can cause a model to perform well only within the price range it was trained on.
  • Ignoring regime dependence. A feature's predictive relationship can differ meaningfully across trending, ranging, high-volatility, and low-volatility regimes; a feature validated in one regime may not transfer to another.
  • Survivorship and data-quality issues. Features built on incomplete or adjusted-after-the-fact price/volume history can quietly bake in look-ahead bias.
  • Treating engineered features as guarantees. Even well-constructed features describe historical statistical relationships, not certainties about future price behavior.

Leakage Improves Your Results, Which Is Why It Survives

Most modelling mistakes announce themselves by making results worse. Feature leakage does the opposite: it makes the backtest better, sometimes dramatically, which removes every incentive to go looking for it. A feature computed with information that would not have been available at prediction time produces a model that appears to work and cannot, and the more impressive the result, the more carefully the feature definitions deserve reading.

The habit worth building is to state, for every feature, the exact moment it becomes knowable. Using a session closing price in a feature meant to predict that same session is the obvious version. The subtle versions involve normalisation constants, scaling parameters or thresholds computed across the full history, all of which quietly carry future information into every row.

The stationarity point is the other one that separates working feature sets from decorative ones. Raw price levels drift, so a model trained inside one price range learns relationships tied to that range. Returns, ratios and normalised indicator readings keep the input distribution comparable across time, which is what allows anything learned to transfer.

And resist the instinct to add features. A large set of correlated inputs increases the chance that the model fits historical coincidence, and every additional feature is another opportunity for a leak to enter unnoticed. Validation has to be out-of-sample and forward-walking; in-sample fit measures nothing you can use.

Frequently Asked Questions

What are machine learning features from price and volume?

Machine learning features from price and volume are engineered numeric inputs derived from raw OHLCV (open, high, low, close, volume) data, such as returns, rolling volatility, momentum oscillators, and volume-based ratios, that are fed into a predictive model instead of raw prices themselves.

Why not just feed raw price and volume into a model?

Raw prices are non-stationary, their scale drifts over time, which makes them poor inputs for most learning algorithms. Engineered features like returns, ratios, and normalized indicators tend to have more stable statistical properties across different price regimes, helping a model generalize instead of memorizing a specific price range.

What are common examples of price and volume features?

Common examples include log returns over various lookback windows, rolling volatility, RSI, moving-average distance ratios, deviation from VWAP, on-balance volume slope, relative volume, and Bollinger Band position. Each condenses raw price or volume history into a single normalized number.

What is feature leakage in this context and why does it matter?

Feature leakage occurs when a feature is calculated using information not actually available at the time a prediction would be made, such as using a full-day's closing price to build a feature meant to predict that same day's direction. It produces backtest results that look strong but do not hold up in live trading.

Do more features always improve a model?

No. Adding many correlated or noisy features increases the risk of overfitting, where a model fits historical noise rather than a real, persistent relationship. Practitioners commonly favor a smaller set of well-understood, economically motivated features validated with out-of-sample testing over an unfiltered, large feature set.

How should features be scaled when assets trade at very different price levels?

By converting to quantities that do not depend on the level: returns, ratios, distances expressed in volatility units, or cross-sectional percentile ranks. A feature built from raw currency amounts encodes the price level itself, so a model trained across a universe learns to distinguish expensive assets from cheap ones rather than learning the intended relationship. The transformation choice is part of the feature definition, not a preprocessing detail.

What is the difference between a feature and a label?

A feature is an input the model can observe at the moment a decision would be made. A label is the outcome it is being trained to associate with that input, and it necessarily lies in the future relative to the feature. The boundary between them is where the timestamp discipline has to be exact, because any information that crosses from the label side into the feature side is leakage regardless of how it got there.

How do corporate actions affect price and volume features?

Splits, reverse splits and large distributions create discontinuities in an unadjusted series that look like enormous returns and volume changes. A model trained on unadjusted data will learn those artefacts. Adjusted data solves the price problem but introduces its own: adjustment factors are applied retroactively, so a series downloaded today does not match what was observable in the past.

Should volume features be transformed differently from price features?

Usually yes, because volume has different statistical properties. It is non-negative, heavily right-skewed, and carries strong intraday and day-of-week seasonality that price returns do not. Common treatments express it relative to a rolling average of its own recent values, or take logarithms, so that the feature captures unusual activity rather than the asset baseline turnover.

References

Disclaimer

This page is for educational purposes only and does not constitute investment, financial, or trading advice. Any figures, prices, or calculations shown are illustrative and hypothetical, not live or historical market data. Machine learning models and technical features reflect historical statistical relationships and do not guarantee future results. Swoopr Investment is not a licensed investment advisor; consult a qualified professional before making investment decisions.