Skip to Content
ChartIndicatorsRobustZScore

RobustZScore

RobustZScore shows how unusual a bar is compared with the recent past — by price change, volume or range. It uses the median and the median absolute deviation (MAD), which, unlike the mean and the standard deviation, are not shifted by the outliers themselves.

The indicator is drawn in a separate area below the chart.

How to read it

A value beyond the ±3.5 levels is an anomaly: a spike in the price change, volume or range of the bar. The sign tells whether the bar’s value is above or below the usual.

How it is calculated

  1. For each bar, the value set by Measure is taken:
    • Price change — ln(close / close of the previous bar);
    • Volume — the logarithm of the bar volume;
    • Bar range — ln(High / Low).
  2. Over the Window of past bars (without the current one), the median and the MAD — the median of absolute deviations from the median — are calculated.
  3. Z-score = 0.6745 × (value − median) / MAD.

If the MAD is zero (more than half of the window values are equal — a common case for price changes), the mean absolute deviation is used instead: Z = (value − median) / (1.2533 × mean deviation). If that is also zero, the line breaks; if the bar’s value then equals the median, the Z-score is 0.

Bars without volume (for volume) and bars with a price of 0 or below are left out of the window; the line breaks at such a bar itself.

The first value appears on bar number Window + 2 for the price change and Window + 1 for volume and range (bars 102 and 101 with the default settings).

Parameters

ParameterDescriptionDefault
MeasurePrice change, Volume or Bar range.Price change
WindowHow many past bars the current one is compared with, at least 2.100

Plots

ParameterDescriptionDefault
Z-scoreThe robust Z-score line.Orange, solid

Levels

ParameterDescriptionDefault
UpperAn abnormally high value.3.5, blue
LowerAn abnormally low value.−3.5, blue

Style

The Z-score line has the Plot (show the line), Label (show the last value on the right scale), Color, Width (1–5) and Style (Solid, Dashes, Dots) fields.

Each level has the Show, Value, Color, Width and Style fields.

How to add an indicator to the chart is described in Adding an indicator; parameters are changed in the indicator manager.

Last updated on