Language

This page is an English translation of the Hungarian content. Charts, videos, code and downloadable source documents retain their original language. Original Hungarian text →

INDICATOR GUIDE / ILLUSTRATED EXPLANATION

MA Channel Optimizer: how does the pivot-fitted moving-average channel work?

The indicator shows a moving average and a channel fitted around it. It helps you examine where price sits relative to the trend and earlier turning points. The lines alone do not tell you where the market will move next.

Start with the picture!

The example uses EMA95 and the D1 timeframe with fictional prices. We drew the curves using the indicator's calculation method; this is an explanatory diagram, not a screenshot or forecast for an actual instrument.

Fictional daily candles, a gold EMA95 centre line, two steel-blue channel edges and numbered explanations; separate green and red conditional directions follow the candles. Fictional daily candles, a gold EMA95 centre line, two steel-blue channel edges and numbered explanations; separate green and red conditional directions follow the candles. Fictional daily candles, a gold EMA95 centre line, two steel-blue channel edges and numbered explanations; separate green and red conditional directions follow the candles.
Click the image to enlarge it. Blue: rising candle; gold: falling candle and the thick centre line. The two thin steel-blue curves are the channel edges. We added the green and red areas as explanations: the indicator does not calculate them, and they do not represent probabilities.

1 · Centre line

The selected moving average. Its direction provides a smoothed view of the trend; whether price is above or below it is one clue to the trend's state.

2 · Upper channel edge

A curve fitted above the centre line using distances of earlier highs. It can be examined as a possible resistance area, but it is not a compulsory turning point.

3 · Lower channel edge

A curve fitted below the centre line using distances of earlier lows. It can be examined as a possible support area, but price can break through it.

Marker 4 shows the closing price of the last completed candle.

How is the channel constructed?

  1. First, the moving average of the selected prices is calculated. In the example, this is the EMA95 of daily closing prices. The SMA gives equal weight to prices in its window, while the EMA gives more weight to recent data.
  2. The system looks for local highs and lows among the candles under examination. A pivot is a candidate turning point compared with surrounding candles. A pivot setting of 5 examines 5 candles on each side, so confirmation also requires 5 later candles.
  3. At highs, it measures the distance between that high and the moving average at that time; at lows, it measures the distance between the moving average at that time and the low. The upper and lower sides are searched separately.
  4. It groups similar distances and selects the group containing the most points. The offset is the mean of the selected distances. In this code, “Optimizer” means this fitting process, not a backtest that maximises profit.
  5. The upper edge is the centre line plus the upper offset; the lower edge is the centre line minus the lower offset. The two distances can differ, so the channel is not necessarily symmetrical. The curves follow the shape of the moving average.

The tolerance adapts to recent price movement: the ATR-based value considers both the high–low range and gaps relative to the previous close. By default, it uses the simple average of the last 14 True Range values; this can differ from another platform's smoothed ATR.

More precisely: what does tolerance mean?

The default tolerance multiplier is 0,20. The full width of the selected distance group is at most twice the tolerance. The group's mean determines the offset; this does not imply that every selected point also falls within a tolerance band around the mean line.

The touch count here is the number of points in the selected pivot group. It does not count all candle contacts or successful trades. The channel is not a statistical confidence band or a Bollinger Band.

What does each setting change?

The program defaults to SMA50 calculated from closing prices. The EMA95 shown is a separately chosen example: select EMA and a period of 95 to use it. The value 95 is not advantageous or optimal in every market.

Four average types are available: SMA (simple), EMA (exponential), SMMA (smoothed) and LWMA (linearly weighted). EMA95 also carries the influence of older candles forward with diminishing weight; it is not the same as the simple average of the last 95 closing prices.

Initial settings and their meanings
SettingDefault valueWhat does it affect?
Moving averageSMA · 50The average's type and period. The example uses EMA · 95; on D1, the period means 95 daily candles.
Applied priceClosing priceOpen, high, low and composite prices are also available. They can produce a different curve even with the same period.
Lookback window300 candlesIt searches this recent segment for pivots usable in the channel; earlier history is also needed to calculate the average.
Pivot strength5 + 5 candlesA higher value can produce less frequent turning points and a longer confirmation delay. On a daily chart, we count candles rather than calendar days.
ATR period14The average True Range window used to calculate tolerance.
Tolerance multiplier0,20Changes the permitted variation when grouping distances; a higher value allows a looser fit.
Minimum pivots3This many selected points are required to display the relevant channel edge. If there are too few suitable pivots, one edge may be absent.
Completed candles onlyEnabledThe TradingView version excludes the still-open candle. This does not prevent subsequent channel refitting.

How should you read price in relation to the lines?

Around the average

A rising average with the closing price above it can be consistent with an uptrend. Repeated crosses around a flat average may instead suggest a sideways, noisy environment. A single cross does not prove a trend reversal.

Near the upper edge

A touch of the upper edge can mark a pause or be part of further gains in a strong trend. A close above it followed by a held retest can support a breakout hypothesis. A return inside the band weakens it. This is an interpretation framework, not an automatic signal generated by the code.

Near the lower edge

Holding the lower edge can indicate a support reaction. A close below it and a failed reclaim can be consistent with a weakening scenario. A touch alone is not a buy signal, and a breakdown alone does not require selling.

A simple fictional numerical example

If the centre line is 100, the upper offset is 6 and the lower offset is 4, the two edges are 106 and 96. A closing price of 103 is 3% above the average but remains inside the channel. It is therefore not an upper-channel breakout.

Relative to the upper edge of 106 recorded at that moment, a close of 107 would be above it. This still provides no verified future profit; the channel's value may also change at the next calculation. The example contains no actual instrument, return calculation or trading offer.

Why can historical lines change as well?

The channel is always fitted to the latest lookback window. When a new turning point appears or an old point leaves the window, a different distance group may become the largest, changing both offsets. The program also redraws the previously displayed segment using the new offsets.

A line that fits neatly in today's picture therefore does not prove it was in the same place when an earlier decision was made. Using completed candles reduces uncertainty from changes in an open candle, but does not prevent this refitting. Pivots can also only be confirmed after later candles.

For before-and-after analysis, save dated images and the line values at the time. In a backtest, the fit must be recalculated at every historical point using the data available then; projecting today's channel backwards is unsuitable for this.

A practical sequence of checks

  1. Check the instrument, timeframe, average type, period and whether the candle under examination is completed.
  2. Look at the average's direction and the closing price's position. Distinguish being above the average from actually crossing the upper channel edge.
  3. Define the condition and invalidation in advance: what close or return would weaken the hypothesis? Record the levels at the time instead of adapting the old story retrospectively to the new channel.
  4. Assess the picture in its market context: another timeframe, important news, spreads and execution risk also matter. The indicator does not size positions or replace a complete trading plan.

This tool describes the state of the instrument currently open. Being above the 95-period average and breaking out of a channel are two separate conditions; the indicator alone is not a results list for the entire stock index.

Sources and related material

The channel's specific behaviour is based on the source code of the custom indicator; the external documentation explains the general background of moving averages and repainting. The example image is a mathematical illustration, not a trading result obtained by running the script on a platform.

How is this calculated?

What does it show?

Data, changes and classifications of the indicators above. The rules below explain how this view operates.

Formula and rule

distance=pivot−MA(pivot); tolerance=0.20×SMA(TR,14); max(distance)−min(distance)≤2×tolerance; offset=mean(selected distances); channel=MA+offset

Inputs and notation

The downloadable TradingView version fits a channel to the latest window. Defaults are SMA50, 300 bars, pivots with 5 bars on each side, and at least 3 touches. Here ATR is a simple average of 14 True Ranges, not Wilder smoothing. The mean of the sorted distance window containing the most pivots gives the offset; ties retain the first, smaller offset. Tolerance and minimum touches are user parameters. Not every selected point must fall within mean offset ±tolerance. New data can refit historical lines; this is not a historical backtest. The embedded chart uses the external provider’s own data and method.

Data and original source

Hypothetical inputs entered in the fields; original methodological sources are in the page source list.

Detailed explanation and sources on this page

Horizon, observation date and refresh

The horizon, cutoff and parameters on the original page apply. This description or historical example does not automatically update with later market data. An external chart’s own observation date is read separately.

Units

Field and result labels specify units. Percentage inputs use a scale of one hundred; /100 converts them to a fraction. A percentage-point difference × 100 gives basis points. Monetary amounts use the same currency and scale.

Fixed illustrative example

Illustrative numerical example; not current market data.

TR mean=10 ⇒ tolerance=2; distances=[5,6,8] ⇒ width=3≤4; offset=19/3≈6.3333

Interpretation and limitations

Observed data and editorial interpretation must be read separately. A classification follows the stated conditions; it does not by itself establish causality or future price direction. Further limitations in the original methodology also apply.

Missing and revised data

An empty or invalid input has no valid result; missing data must not be replaced with zero. A ratio is undefined when its denominator is invalid. The example does not update from market releases or overwrite historical snapshots.

Full calculation index →