Beginner Trading Tutorial — Measuring confirmed range compression in MultiCharts
A narrow candle can be an ordinary feature of a quiet market or an unusually small observation in a volatile market. A fixed price threshold cannot distinguish these situations across instruments. This PowerLanguage indicator compares the range of the most recently completed candle with the average range of earlier candles. The result is a dimensionless ratio that helps describe local contraction without making assumptions about the next price direction.
Define the reference window
The range of a candle is its high minus its low. At chart bar t, the signal range is the range at t−1. The reference is the arithmetic mean of N ranges ending at t−2. The signal candle is intentionally excluded from its own reference. Divide the signal range by that mean when the mean is positive. A ratio of one means the signal range equals the reference average; 0.5 means it is half as large; two means it is twice as large. The default threshold is 0.60, which classifies a range at or below sixty percent of its reference as compressed. The threshold is illustrative, not an optimized trading parameter.

Worked examples
Set Lookback to three. Suppose three consecutive completed candles have ranges of 8, 10 and 6 points. Their average is 8. The next completed candle has a range of 4 points. Its ratio is 4/8 = 0.50, so it meets the default compression threshold. A signal range of 8 would instead produce 1.00, while a range of 12 would produce 1.50. These are alternative hypothetical signal candles against the same reference, not sequential observations.
On the following chart bar, the reference window advances. If the original signal range of 4 becomes part of the next reference, the three reference ranges become 10, 6 and 4. Their average is approximately 6.667. A new signal range of 4 would then produce approximately 0.60. This illustrates why an unchanged absolute range can receive a different classification as local volatility changes. A zero signal range is valid when the reference is positive; a zero reference is undefined and should not be interpreted as compression.
Complete PowerLanguage indicator source
Inputs: Lookback(10), Threshold(0.60);
Variables: BarRange(0), RefRange(0), Ratio(0);
{ Use only completed bars; exclude the signal bar
from the reference average. }
BarRange = High - Low;
If Lookback >= 1 and Threshold > 0 and
CurrentBar > Lookback + 1 then begin
RefRange = Average(BarRange, Lookback)[2];
If RefRange > 0 then begin
Ratio = BarRange[1] / RefRange;
Plot1(Ratio, "Ratio");
Plot2(Threshold, "Limit");
If Ratio <= Threshold then
SetPlotColor(1, Green)
else
SetPlotColor(1, Blue);
end
else begin
NoPlot(1);
NoPlot(2);
end;
end
else begin
NoPlot(1);
NoPlot(2);
end;
How the implementation works
Inputs exposes the reference length and the classification threshold in the study settings. BarRange stores the high-low difference for each bar. Average computes the rolling arithmetic mean, and the historical offset of two selects the mean ending two bars before the current chart bar. BarRange[1] selects the last completed candle. This indexing convention prevents the current forming candle from influencing either the numerator or the denominator. The CurrentBar guard adds a conservative startup delay after the platform's own historical warm-up. It is not a substitute for setting sufficient Maximum Bars Back.
Plot1 displays the dimensionless ratio in a separate pane. Plot2 displays the threshold for comparison. Green indicates compression and blue indicates a larger range. The colors are classifications of range size, not bullish and bearish signals. NoPlot suppresses both outputs when the reference is invalid or the input parameters fail basic validation. No persistent trading state is needed, so the indicator can reconstruct the same value from the same historical window on each calculation.
Installation and chart settings
Open PowerLanguage Editor, create a new Indicator, name it ConfirmedRangeCompression and paste the source. Compile it and insert it into a separate chart subgraph in MultiCharts. This example is for classic MultiCharts PowerLanguage, not MultiCharts .NET C#. Configure Maximum Bars Back to accommodate at least Lookback+2 historical bars, especially if you increase the input. Use a positive integer lookback and a positive threshold. The code has not been compiled or executed in the platform here; confirm syntax, plotting and historical reference behavior in your installed version.
Closed-bar timing and repainting
The value drawn at bar t describes the completed candle t−1, not the current candle. With intrabar indicator calculation enabled, the result can become available on the first update of the next bar and remain stable as that bar develops. With close-only calculation it may become visible later. This deliberate one-bar alignment is important when comparing the indicator with a chart study that uses the current candle at its close. No future data is referenced. Under ordinary updates of the current candle, the inputs to the displayed value are unchanged. Historical data corrections, changed session templates or reconstructed non-time-based bars can still change historical results.
Testing and practical interpretation
Start with Lookback=3 and compare the Data Window with a manual spreadsheet of high-low ranges. Check the example above, a ratio exactly equal to the threshold, a zero signal range, and a window of entirely flat bars. Verify that the undefined reference produces no plot. Increase the lookback and confirm that historical data settings remain sufficient. Reload the chart and compare results using identical data and session settings. Observe a live forming candle to confirm that changes to its high and low do not change the previous-bar ratio.
A sequence of compressed ranges may be useful for describing consolidation, but it does not establish whether a breakout will occur or which direction it will take. A narrow candle can appear during a trend, around a session boundary or in an illiquid market. Unlike ATR, this range definition excludes gaps between candles. A gap followed by a narrow candle can therefore be classified as compression even when the overall price displacement is large. Different bar types and session templates can produce very different distributions. A mean can also be influenced by a single unusually large reference candle. Consider a median reference or an ATR-based alternative if these properties are unsuitable. Test any downstream rule on independent data, with realistic spreads, commissions and slippage.
For custom alerts, alternative reference windows or integration into an existing study, contact our Custom MultiCharts indicator Development Services.
Risk disclosure: educational material only. Trading involves risk of loss. Hypothetical calculations do not demonstrate profitability.