For the Geeks

This page is for users who want to understand what is happening inside the indicator, not just how to use it. It covers three mechanics that shape the indicator's behavior in ways that are not immediately obvious from...

Written By Axiom Admin

Last updated About 1 month ago

For the Geeks

This page is for users who want to understand what is happening inside the indicator, not just how to use it. It covers three mechanics that shape the indicator's behavior in ways that are not immediately obvious from the settings panel:

  1. Cross-ticker close-ratio scaling β€” how the indicator brings an alternate ticker's MA into your chart's price space

  2. Weighted-vote blended trend β€” how the blended trend color is determined

  3. Confirmed-bar HTF requests β€” how the indicator prevents future leak

Each section explains the mechanic in plain language, tells you why the design choice was made, describes the tradeoff, and gives you a way to verify the behavior yourself.

None of this page is required for normal use. You can configure and read the indicator perfectly well without knowing any of this. But if the indicator ever does something that surprises you β€” a scaled line drifting unexpectedly, a blend trend color that seems wrong, or a history that looks different from what you remember β€” this page will help you understand why.


Cross-ticker close-ratio scaling

What it does

When you set a slot's Optional Ticker to a different symbol (say, SPY on an AAPL chart), the indicator computes the MA on SPY's data rather than AAPL's. But SPY trades at $550 while AAPL trades at $200. If the indicator plotted SPY's raw MA value on AAPL's chart, the line would sit at $550 β€” far above AAPL's price action and completely useless as a visual overlay.

The scaling mechanism solves this by computing a ratio between the chart symbol's price and the alternate ticker's price on the same higher timeframe. The alternate MA is then multiplied by this ratio to bring it into the chart's price region.

How to think about it

Imagine two ships sailing in the same direction. The chart symbol is one ship and the alternate ticker is the other. The ratio measures how far apart they are at any given moment. The scaling uses that distance to translate the alternate ship's position into terms that make sense from the first ship's deck.

When the two ships sail in rough formation β€” moving together, roughly the same direction, roughly the same pace β€” the ratio stays more stable and the translation is more reliable. The alternate MA stays readable in the chart's price region, and the ratio distorts the plotted line less.

When one ship veers off β€” a stock drops while the index holds, or the index surges while the stock consolidates β€” the distance between them changes. The ratio stretches. The translated position drifts, not because the alternate asset's MA changed direction, but because the conversion factor itself shifted.

Why this approach instead of something more sophisticated

A ratio of two closes is the simplest normalization that produces a usable visual overlay. More rigorous approaches exist β€” z-score normalization, regression-based alignment, rolling correlation adjustments β€” but they add complexity and opacity for a marginal improvement that only matters during the exact conditions (sharp divergence) where cross-ticker context becomes less reliable anyway.

The close ratio has a useful property: it degrades gracefully. When the relationship between the two assets weakens, the scaled line drifts visibly. You can see the drift happening. A more sophisticated normalization might mask the drift for longer, making you trust the line during exactly the period when it is least trustworthy. The ratio's honesty β€” its willingness to look wrong when the relationship breaks down β€” is a feature.

When the scaling is useful vs. when it is noise

Useful: When the chart symbol and the alternate ticker have a real structural relationship. Stocks in the same sector. An individual stock against its sector ETF. An individual stock against a broad index. Assets that share macro drivers. In these cases, the scaled MA provides genuine cross-market context.

Noise: When the two assets have no structural relationship, or when a structural relationship has temporarily broken down. The scaling still produces a line, and the line still appears on the chart in the right price region. But the line's movements are driven by the ratio shifting, not by any meaningful relationship between the two assets' structures.

How to tell the difference: Watch the scaled line over several sessions. If it stays readable without persistent ratio-driven drift, the relationship is intact enough for the overlay to be informative. If the line is drifting steadily in one direction while the chart goes the other way, the ratio is stretching and the overlay is showing you ratio noise, not trend context.

Verification exercise

  1. Open a chart for any stock (e.g., AAPL) on a 5-minute timeframe.

  2. Set MA 03's Optional Ticker to SPY. Keep the other settings at default.

  3. Observe the purple line (MA 03). It should sit near AAPL's price region, not at SPY's raw price level (~$550). This confirms the scaling is working.

  4. Open a second chart window showing SPY on the same 5-minute timeframe with a regular SMA 20. Compare SPY's own SMA to the slot's color changes and the scaled line's broad behavior on AAPL's chart. The scaled line should stay readable, but do not expect its exact slope to match the raw SPY SMA tick for tick.

  5. If you watch during a period where AAPL and SPY diverge (AAPL sells off while SPY holds), you should see the scaled line drift β€” it may move away from AAPL's price action even though SPY's own MA is stable. That drift is the ratio stretching. This is the most important thing the exercise teaches: the drift looks like trend information but it is not. The slot's trend state still comes from SPY's MA, but the plotted line itself can be bent by the changing ratio. Understanding this difference is what separates useful cross-ticker reading from misleading cross-ticker reading.


Weighted-vote blended trend

What it does

The blended MA line has two independent components: its value (where the line sits) and its trend color (lime or red). The value is a standard weighted average β€” each slot's MA value is multiplied by its weight, summed, and divided by total weight. That part is straightforward.

The trend color is different. It is not based on whether the blended value itself is rising or falling. Instead, each enabled slot with a non-zero weight casts a "vote" for its current trend direction, and that vote is proportional to the slot's weight. The side (uptrend or downtrend) that accumulates more total weight determines the blend color. Ties go to uptrend.

Why a vote instead of the blended value's own direction

This is a deliberate design choice that confuses people until they understand the reasoning.

If the blended trend were based on the blended value's own slope (is the blended MA rising or falling?), it would lag behind individual slot trend changes. The weighted average smooths out individual flips. A single slot could change from uptrend to downtrend, and the blended value might keep rising for several bars because the other two slots are still pulling it up. The blended trend color would not flip until the blended value itself starts falling β€” by which time the original slot has been in downtrend for a while.

The vote mechanism responds immediately when enough weight-bearing slots change direction. The moment a slot flips, its weight shifts from one side of the vote to the other. If that weight is enough to tip the balance, the blend color changes on the same bar. No smoothing delay.

The tradeoff: the vote can produce color changes that seem disconnected from the blended line's visible movement. The blended value might be rising while the blended trend shows red, because a heavy slot just flipped to downtrend even though the blended average has not caught up yet. This looks like a bug until you understand that the value and the trend are computed independently.

The weight math in plain terms

Suppose you have three slots:

  • MA 01: weight 40, currently in uptrend

  • MA 02: weight 35, currently in uptrend

  • MA 03: weight 25, currently in downtrend

The uptrend side has 40 + 35 = 75 total weight. The downtrend side has 25. The blend shows lime (uptrend wins).

Now MA 01 flips to downtrend:

  • Uptrend side: 35 (only MA 02)

  • Downtrend side: 40 + 25 = 65 (MA 01 + MA 03)

The blend flips to red. A single slot's flip changed the blend color because that slot carried enough weight to shift the balance.

If the weights were equal (33.3 each) and the same flip happened:

  • Before: uptrend 66.6 (MA 01 + MA 02) vs. downtrend 33.3 (MA 03). Lime.

  • After: uptrend 33.3 (MA 02) vs. downtrend 66.6 (MA 01 + MA 03). Red.

Even with equal weights, losing one slot out of three is enough to flip the vote from 2-to-1 to 1-to-2.

What a weight of zero does

If a slot's weight is set to zero, it does not participate in the vote at all. Its trend state is ignored. It also does not contribute to the blended value. The slot still computes its own MA, determines its own trend, plots its own line, and fires its own alerts β€” but it is invisible to the blend in every way.

This is useful when you want a slot on the chart for visual reference without letting it influence the composite.

Verifying the weighted vote

This exercise lets you see the vote mechanism in action:

  1. Load the indicator with default settings (equal weights, all three slots enabled).

  2. Find a moment when two slots are in uptrend and one is in downtrend. The blend should show lime (two slots with combined weight ~66.6 vs. one with ~33.3).

  3. Now change the downtrend slot's weight to 80 and the other two to 10 each.

  4. The blend should flip to red β€” because the downtrend slot now carries 80% of the weight, overwhelming the two uptrend slots' combined 20%.

  5. Set the weights back to equal and confirm the blend returns to lime.

This proves that the blend color follows weight, not slot count. The exercise also reveals something less obvious: the threshold where the blend flips depends entirely on the weight distribution. With equal weights, any single flip changes the vote from 2-to-1 to 1-to-2. With unequal weights, a light-weight slot's flip might not change the blend at all. Knowing your weight distribution is not just a configuration detail β€” it determines how sensitive the blend is to each slot, and which slots can single-handedly change the composite reading.


How confirmed-bar requests work

The problem

TradingView's higher-timeframe data request function has a behavior that catches many Pine Script developers off guard. When you ask for data from a higher timeframe and enable the "lookahead" option (which lets the data appear on chart bars before the HTF bar actually closes), the function returns the HTF bar's final value on the first chart bar of that HTF period.

On live charts, this is fine β€” the HTF bar has not closed yet, so the function returns whatever data is currently available. But on historical bars, the HTF bar has already closed, and the function "sees" the final value. This means historical chart bars display a value that was not yet known at the time the bar was live. The chart's past is rewritten with information from the future.

The solution

The indicator uses a standard TradingView best practice to eliminate this future leak when On Bar Close is on. Instead of requesting the current HTF bar's data, it requests the previous HTF bar's data β€” one bar back in the HTF context. Since the previous bar is fully closed by the time any current bar is executing, its data is stable and was genuinely available at the time.

The "lookahead" option remains enabled because it ensures the data arrives at the correct chart-bar alignment. But the one-bar offset means the data being "looked ahead" is the previous bar's data β€” which is already confirmed. The lookahead gives you alignment. The offset gives you integrity.

What this means practically

With On Bar Close on:

  • Every chart bar in history shows the HTF MA value from the last fully-closed HTF bar at that point in time.

  • The most recent chart bars show the same confirmed value until the current HTF bar closes and becomes "the previous bar."

  • The visual result is a stepped line that updates once per HTF bar close.

With On Bar Close off:

  • The offset is removed. The function returns the current building bar's data.

  • On historical bars, the lookahead causes the final value to appear early. This is the future leak.

  • The visual result is a smooth line that updates on every chart bar β€” but is historically dishonest.

Why both options exist

Some users need the live, responsive view and understand the implications. They are watching in real time, making decisions based on current data, and they accept that the historical chart picture is unreliable. For those users, the speed of the live data matters more than the integrity of the history.

Most users need the opposite β€” they need to trust that what they see in history would have looked the same in real time. For those users, the one-bar delay is a small price to pay for data they can study and learn from honestly.

The On Bar Close switch makes this tradeoff explicit and puts the choice in the user's hands, rather than hiding it behind a default that most people never think to question. Most multi-timeframe indicators on TradingView do not surface this choice at all β€” they either repaint silently (the common case) or they use confirmed data without explaining why the lines step. Understanding the mechanism behind On Bar Close is not just about this indicator. It is a concept that applies to every tool that requests higher-timeframe data on a lower-timeframe chart.

Verification

The full verification routine is documented in MTF & Repainting. In summary: toggle On Bar Close on a live 1-minute chart, observe the stepped vs. smooth behavior, scroll back in history, and compare the two views. The difference is visible and verifiable.


What this page does not cover

This page explains the three mechanics that are most likely to surprise or confuse an advanced user. It does not cover:

The goal here is to build your understanding of why the indicator behaves the way it does, so you can make better judgments about when to trust what it shows you. Every surprising behavior β€” the blend color disagreeing with the majority of slots, the cross-ticker line drifting during divergence, the stepped lines on recent bars β€” has a mechanical explanation. Understanding the mechanics does not make the surprises go away. It gives you a framework for deciding whether the surprise is the indicator telling you something important or the indicator reaching the edge of what it can measure.