# Min-max Scaling

A Statistics concept (Normalization & distribution) in the LuxAlgo Library, with 2 indicator implementations.

## What is Min-max Scaling?

Min-max scaling rescales a series to a fixed interval, usually 0 to 1 or 0 to 100, by subtracting the window minimum and dividing by the window range (maximum minus minimum). On charts it is almost always rolling: the extremes are taken over a trailing lookback, so each value states where the series sits inside its recent range. The Stochastic oscillator's %K is exactly this transform, min-max scaling the close against the highest high and lowest low of the lookback.

The transform predates charting software. Rescaling data to a unit interval is one of the oldest normalization steps in statistics, and machine-learning practice knows it as feature scaling. Technical analysis absorbed it early: the stochastic oscillator popularized by George Lane in the late 1950s is a min-max scale of the close, and Williams %R is the same measurement flipped upside down. The formula is one line, scaled = (value - window minimum) / (window maximum - window minimum), multiplied by 100 when a 0-100 display is wanted. The only real parameter is the window, which decides what counts as the range each value is judged against.

The appeal is comparability: once everything lives on the same bounded scale, oscillators with unlike units can share a panel, feed a composite score, or enter a model without one input dominating on magnitude alone. The cost is outlier sensitivity: a single extreme print stretches the range and compresses everything else toward the middle, which is why a [Z-score](https://www.luxalgo.com/library/concept/z-score/) or [percentile rank](https://www.luxalgo.com/library/concept/percentile-rank/) is often preferred when the input has fat tails.

Two practical details matter in implementation. First, the degenerate window: when the lookback's maximum equals its minimum the denominator is zero, so indicators must clamp, hold the prior value, or skip the bar, and a nearly flat window makes the output twitchy, since tiny price moves traverse the whole scale. Second, the choice of transform should follow the distribution of the input: examining the series first, in the spirit of [distribution-of-returns profiling](https://www.luxalgo.com/library/concept/distribution-of-returns-profiling/), tells you whether the tails are thin enough for min-max to behave. For heavy-tailed inputs, rank-based scaling keeps resolution where the data lives, while min-max spends most of its scale on a few extreme prints.

## How to recognize min-max scaling on a chart

Min-max scaling is a transform rather than a pattern, so identifying it means recognizing its signature in an indicator pane.

1. Look for hard bounds: a pane whose readings touch exactly 0 and 100 (or 0 and 1) rather than approaching them asymptotically is min-max scaled; unbounded oscillators drift to arbitrary extremes instead.
2. Watch new extremes: every new lookback high maps to exactly the top bound and every new low to the bottom, so a trending market pins the line flat at an extreme. That pinning is the transform's fingerprint.
3. Find the lookback input in the settings: shortening it makes the line reach the bounds constantly, while lengthening it makes extremes rare and the line smoother.
4. Compare the scaled pane with the raw series: turning points align bar for bar, but the scaled version discards amplitude, so a huge move and a modest one can both read as 100.
5. Check flat-range behavior: if the pane goes erratic or blank when price compresses into a very tight range, you are seeing the zero-range denominator being handled.

## How traders use it

- To normalize unlike indicators onto one 0-100 panel or dashboard, so momentum, volume, and volatility readings can be compared, averaged, or scored side by side.
- As a position-in-range read on price itself: values near 1 mean the market is trading at the top of its N-bar range and values near 0 at the bottom, which is the raw material of stochastic-style logic.
- As feature scaling before model fitting, where bounded, comparable inputs keep distance-based and gradient-based methods from being dominated by whichever raw series has the largest units, and keep the higher-order terms of a [polynomial regression](https://www.luxalgo.com/library/concept/polynomial-regression/) numerically well behaved.
- To bound an unbounded oscillator: normalizing MACD or rate-of-change output onto a fixed scale gives it stochastic-style thresholds, which is what normalized-MACD constructions do, making alert levels transferable across symbols and timeframes.
- As the aggregation step in composite dashboards: sentiment spider charts and circular barplots min-max scale each component oscillator first, so a single average or shape can summarize many unlike readings without unit mismatch.

## Min-max scaling vs other normalizations

- **Z-score** (https://www.luxalgo.com/library/concept/z-score/): A Z-score centers on the window mean and divides by standard deviation, so it is unbounded and reads in how-unusual units rather than position-in-range. It degrades more gracefully with outliers, but offers no fixed floor or ceiling for panels and thresholds that need one.
- **Percentile Rank** (https://www.luxalgo.com/library/concept/percentile-rank/): Percentile rank replaces each value with the share of window values below it, so it is bounded like min-max but rank-based: one extreme print cannot compress the rest of the scale. The cost is that distances lose meaning, since the gap between the 98th and 99th percentile may be tiny or enormous in raw units.
- **Distribution-of-returns Profiling** (https://www.luxalgo.com/library/concept/distribution-of-returns-profiling/): Profiling examines the shape of the data, its tails, skew, and concentration, rather than rescaling anything. It is the diagnostic that tells you which normalization is safe: thin-tailed inputs suit min-max, while fat tails argue for ranks or robust scalers.

## FAQ

### When should I use min-max scaling instead of a Z-score?

Use min-max when you need a hard bounded range, for plotting several indicators on one panel or feeding a model that expects 0-to-1 inputs, and when the window's extremes are meaningful. Prefer a [Z-score](https://www.luxalgo.com/library/concept/z-score/) or [percentile rank](https://www.luxalgo.com/library/concept/percentile-rank/) when outliers are common, because one extreme print stretches the min-max range and squashes every other value toward the middle.

### Why does a min-max scaled indicator keep hitting 0 or 1?

By construction. Every new high of the lookback maps to exactly 1 and every new low to exactly 0, so a trending market pins the reading at an extreme for as long as it keeps printing new extremes. That is position-in-range information, not an automatic overbought or oversold signal; lengthening the window makes the extremes rarer.

### What is the formula for min-max scaling?

Scaled value = (value - minimum) / (maximum - minimum), which lands on a 0-to-1 scale; multiply by 100 for a 0-to-100 display. On charts the minimum and maximum are usually the lowest and highest values of a rolling lookback window rather than the whole history, so the reading means position within the recent range.

### Is the stochastic oscillator just min-max scaling?

Essentially yes. %K min-max scales the close against the highest high and lowest low of the lookback, and %D smooths the result. Everything layered on top, signal crossings, 20/80 zones, divergence reads, is interpretation of that scaled series. Recognizing this makes it easy to build stochastic-style logic on any input series, not just price.

### What happens when the window maximum equals the minimum?

The denominator is zero and the value is undefined. Implementations guard the case by outputting a neutral 50, holding the last value, or skipping the bar. Nearly flat windows are almost as awkward: with a tiny denominator, negligible price changes swing the output across its full scale, so readings during tight compressions deserve skepticism.

### Does min-max scaling remove the trend from a series?

Within the window, yes: the output states position relative to the rolling range rather than absolute level, so a steady uptrend reads as a value hovering near the top instead of a rising line. Across windows, trend information survives only as that persistent top-of-range reading. The window length effectively decides which movements count as trend and which as range.

## Implementations in the Library

- Circular Barplot - Oscillators Sentiment (LuxAlgo): https://www.luxalgo.com/library/indicator/circular-barplot-oscillators-sentiment/
- Normalized Oscillators Spider Chart (LuxAlgo): https://www.luxalgo.com/library/indicator/normalized-oscillators-spider-chart/

## Related concepts

- Distribution-of-returns Profiling: https://www.luxalgo.com/library/concept/distribution-of-returns-profiling/
- Percentile Rank: https://www.luxalgo.com/library/concept/percentile-rank/
- Sigmoid/softmax Transforms: https://www.luxalgo.com/library/concept/sigmoid-softmax-transforms/
- Standard Deviation: https://www.luxalgo.com/library/concept/standard-deviation/
- Z-score: https://www.luxalgo.com/library/concept/z-score/
- Winsorization: https://www.luxalgo.com/library/concept/winsorization/
- Distribution Moments: https://www.luxalgo.com/library/concept/distribution-moments/
- Normality Testing: https://www.luxalgo.com/library/concept/normality-testing/
- Outlier Detection: https://www.luxalgo.com/library/concept/outlier-detection/

---

Source: https://www.luxalgo.com/library/concept/min-max-scaling/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/