MultiCharts PowerLanguage Price-Channel Position: A 20-Bar Range Percentile Oscillator with Closed-Bar Zone Entries
Beginner Trading Tutorial | MultiCharts classic PowerLanguage | Range normalization
Price rising does not always mean it is near the top of its recent trading range. A market can recover several points yet remain in the bottom half of its last twenty candles, while another can look quiet but close right against its multi-bar high. A normalized channel-position reading answers a simple, reproducible question: where does the latest closing price sit between the highest high and lowest low of the chosen lookback window?
In this tutorial we build a full classic PowerLanguage indicator for MultiCharts (not the separate MultiCharts .NET C# edition). It plots a 0–100 oscillator, two configurable threshold lines, a 50 midline, and optional first-entry markers. It is not an automated trading system, does not predict direction, and never submits an order.
From dollars to a comparable percentage
Start with a rolling set of 20 bars. Let H20 be the highest high observed in that window, and L20 its lowest low. For a closing price C, compute 100 × (C − L20) ÷ (H20 − L20). The reading is 0 when the close is at the window low, 100 when it is at the window high, and 50 at the midpoint. As both the high and the low come from the same window, the value normally remains within 0–100.
The distinction from a raw price change is useful when comparing instruments with very different nominal prices. It does not make instruments comparable in volatility, liquidity, or risk. The oscillator captures location, not a forecast, fundamental valuation, or true purchase volume.

A numerical example you can reproduce
Assume the highest high over the past 20 completed bars is 112.00, the lowest low is 100.00, and the latest bar closes at 110.40. The lookback range spans 12 points. Position = (110.40 − 100.00) ÷ 12.00 × 100 = 86.67%. A default upper threshold of 80 is exceeded. If yesterday’s confirmed position was 77.5, the reading has entered the upper zone today. If yesterday was already 84.0, today’s reading is still in the zone but is not a new upper-entry event.
For a low-side example, a close of 102.00 in the same range produces (102 − 100) ÷ 12 × 100 = 16.67%. This marks a new lower-zone entry only if the prior confirmed reading was above 20. A position below 20 does not automatically imply an imminent bounce: prices can remain near the bottom of a falling channel for a long time.
Why entry markers need the previous reading
Without a transition rule, a strong market near its range high would show an “upper-zone” condition on every consecutive candle. That can make a chart look as if many independent events have occurred even though the market only entered the region once. Our code compares the current confirmed reading against the previous confirmed reading: current ≥ 80 and previous < 80 for upper entry; current ≤ 20 and previous > 20 for lower entry. Threshold values are adjustable; the inequalities are intentionally asymmetric to avoid counting a touch that never crosses from the opposite side as a new event.

Inputs and interpretation
| Input | Default | Effect |
|---|---|---|
| Length | 20 | Rolling high and low reference period. Shorter windows move faster but can be noisier. |
| UpperZone | 80 | First-entry threshold near the upper part of the channel. |
| LowerZone | 20 | First-entry threshold near the lower part of the channel. |
| ShowEntryMarkers | True | Draw separate plots for the first entry into either zone. |
Do not confuse this scale with the percentage change from yesterday or with a statistical percentile rank. Range position is a linear 0–100 mapping within a price channel; it does not say that 86.7% of observations are below the current close. The name “position percentile” is a useful label for the normalized coordinate, not an empirical cumulative-distribution calculation.
Complete PowerLanguage indicator
Paste the complete program below into a new Indicator in the PowerLanguage Editor. The source is identical in both language editions. It uses Highest, Lowest, Plot1–Plot6, NoPlot, and BarStatus(1) in the classic PowerLanguage syntax. BarStatus(1) = 2 gates output updates at a bar-closing event in ordinary data-series contexts. Configure chart and session settings consistently, because bars with unusual closing rules can behave differently.
{ PatternSmart: Rolling Price-Channel Position (classic PowerLanguage) }
{ Indicator study - NOT a Signal/strategy and sends NO orders. }
{ Use a single chart data series with enough history. }
Inputs:
Length(20),
UpperZone(80),
LowerZone(20),
ShowEntryMarkers(True);
Variables:
WindowHigh(0),
WindowLow(0),
ChannelRange(0),
PositionPct(50),
UpperEntry(False),
LowerEntry(False);
{ On a live chart, require a completed bar before updating the plots. }
If Length >= 2 and
UpperZone > LowerZone and
UpperZone <= 100 and LowerZone >= 0 and
BarStatus(1) = 2 Then
Begin
WindowHigh = Highest(High, Length);
WindowLow = Lowest(Low, Length);
ChannelRange = WindowHigh - WindowLow;
{ Neutral fallback for a zero-range lookback window. }
If ChannelRange > 0 Then
PositionPct = 100 * (Close - WindowLow) / ChannelRange
Else
PositionPct = 50;
{ Four plots for the oscillator panel. }
Plot1(PositionPct, "Position");
Plot2(UpperZone, "Upper");
Plot3(LowerZone, "Lower");
Plot4(50, "Mid");
{ A fresh entry requires a crossing from the opposite side. }
UpperEntry = PositionPct >= UpperZone and
PositionPct[1] < UpperZone;
LowerEntry = PositionPct <= LowerZone and
PositionPct[1] > LowerZone;
If ShowEntryMarkers and UpperEntry Then
Plot5(PositionPct, "EnterUpper")
Else
NoPlot(5);
If ShowEntryMarkers and LowerEntry Then
Plot6(PositionPct, "EnterLower")
Else
NoPlot(6);
End;
How the six plots work
Plot1 is the active oscillator value; Plot2 and Plot3 draw adjustable zone boundaries; Plot4 is the 50 midline. Plot5 and Plot6 hold one-bar upper and lower entry markers. On every other bar, NoPlot clears the event marker rather than drawing a continuous series of repeated signals. In the indicator Format dialog, assign a line style to plots 1–4 and a point/marker style to plots 5–6 for clearer interpretation.
The fallback PositionPct = 50 covers the mathematically undefined case in which all lookback highs and lows coincide and the denominator is zero. It is a deliberately neutral reading, not evidence that the market is balanced. The built-in lookback functions require adequate price history; set Maximum Bars Back to Auto-Detect or sufficiently high for the selected Length.
Install, review, and test in MultiCharts
- Open the PowerLanguage Editor and create a new Indicator study, not a Signal.
- Paste the entire source, verify and compile it with your installed platform build, then insert the study into a chart in a separate pane. The example has not been compiled against your local installation.
- Set Length = 20 and zones to 80/20. Confirm that you have enough historical bars and that MaxBarsBack does not suppress all output.
- For live use, compare behavior with “Update on every tick” disabled and check that the displayed value changes only when a completed bar is processed; consult the chart’s actual session and bar-close semantics.
- Check several bars manually: write down the prior 20 highs/lows and close; calculate the oscillator independently to two decimal places. Verify that markers occur only at new threshold crossings.
- Repeat on fast, choppy, thinly traded, and trending markets; document where the 80/20 interpretation becomes misleading.
Limitations and practical extensions
A rolling price channel moves with every new high or low; a threshold crossing can be caused by the range changing rather than by a dramatic current close. Volatility compression can also create apparently large swings in position from small price changes. A market above 80 can keep rising, consolidate, or reverse—this tool does not identify which future path will occur. It ignores spread, order-book quality, trading hours, volume and news. On historical reloads or with revised/adjusted bars, old plots may recalculate. Closed-bar gating reduces transient intrabar signals; it is not a promise that underlying data will never be corrected.
Use this as a research component: for example, compare repeated upper-entry events with trend context, or measure whether lower-entry markers coincide with high-volatility news sessions. Evaluate full samples, adverse excursions and costs before converting any condition into an execution rule. A sensible customization may add a volatility guard, alerts after confirmed threshold crossings, a separate screener column, or a larger-timeframe context filter. If you are interested in extending this free PowerLanguage indicator to your particular workflow, explore Custom Trading Software Development Services.
Educational example only, not investment advice or a claim of profitable performance. Verify the code and chart settings locally; no compilation or profitability test has been performed here.