For the Geeks
This page is for the reader who wants enough mental model of the pipeline to trust what the rest of the manual claims. It is not a reference implementation. It does not contain formulas for any moving average. It does...
Written By Axiom Admin
Last updated 22 days ago
For the Geeks
This page is for the reader who wants enough mental model of the pipeline to trust what the rest of the manual claims. It is not a reference implementation. It does not contain formulas for any moving average. It does not contain pseudocode of the slot pipeline. It does not contain library internals or numeric recipes presented as recommendations. What it does contain is the chain of operations the indicator runs, in ordinary language β precise enough to reason about edge cases without having to read Pine, bounded enough that a reader cannot reproduce the instrument from what is here.
If you came looking for the math of ALMA, KAMA, FRAMA, Jurik, Laguerre, or VAMA, this is not the page for it. Those families live inside the shared Axiom MA library. This page uses them by name and stops there, on purpose.
Why this page exists
A trader who acts on a composite needs to be able to defend the composite in their own words. That is the plain version of what the product calls trust. Trust built only from "it works on my chart" is fragile under pressure; the first bar the pane surprises you, the trust snaps. Trust built from a working mental model of the pipeline holds, because you can reason about what the pane is doing when the pane does something you have not seen before.
The trick for a serious product is to give the reader enough of the pipeline that the reasoning is possible, without handing them a clone-ready blueprint. That is the line this page tries to walk. If the page were too detailed, it would be a parts list for anyone who wanted to rebuild the instrument. If it were too shallow, it would be marketing copy pretending to be technical. The middle β "enough to think with, not enough to clone" β is the target.
The pipeline in ordinary language
For each enabled slot, the indicator does the following, in this order:
Choose the symbol. If the slot has Optional Ticker set, the slot reads from that symbol. If not, it reads from the chart symbol.
Choose the higher-timeframe context. The slot requests its source, its high, and its low at the slot's configured TimeFrame. An empty TimeFrame means "same as the chart." These three series β source, high, low β all come from the same symbol and same higher-timeframe context. That is the mechanical reason Optional Ticker reroutes the full stochastic context, not just the source.
Compute raw %K. At each higher-timeframe bar, the slot computes where the source sits inside the high/low range over the last K Length bars. The result is a 0..100 number representing position within the recent range.
Smooth %K into the slot's K line. The raw %K is passed through the moving-average family chosen by K Type, over the length chosen by K Smoothing, using the slot's power-user tunings for that family (ALMA offsets, KAMA/FRAMA fast/slow, Jurik phase/power, Laguerre alpha, VAMA vol length β whichever the chosen family consults). While that smoothing stage is not ready, the slot uses raw %K as its K.
Smooth K into the slot's D line. The K line is passed through a second moving-average family, chosen by D Type, over the length chosen by D Length, using the slot's K-and-D-independent power-user tunings for that family. While that smoothing stage is not ready, the slot uses K as its D.
Clamp. Both the K and D lines are clamped into 0..100. Normal operation rarely touches the clamp; unusual inputs or aggressive tunings can cause brief pinning.
Repaint gate. The slot's
On Bar Close?switch decides what the slot returns for this chart bar: either the previous confirmed higher-timeframe bar's K and D (switch on), or the current higher-timeframe bar's live K and D (switch off). The switch applies to K and D together; they cannot disagree on it.
That is one slot. The script repeats this for each enabled slot in parallel.
After every slot has produced its K and D for this chart bar, the composite stage runs:
Weighted average. For each of K and D separately, the composite accumulates each slot's value times its
Blended Weight, summed across enabled slots whose weight is non-zero and whose K is non-NA. Zero-weight slots are skipped. Slots without a usable K are skipped. The denominator is the total of the active weights.Clamp. The resulting blended K and blended D are each clamped into 0..100.
Optional master smoothing. If master smoothing is enabled, the blended K and blended D are passed through the master MA family, over the master length, with the master power-user tunings. The pass is applied to each of K and D independently.
Clamp again. The final blended pair is clamped into 0..100 one more time.
Finally:
Color and plot. Slot K lines are colored bright or faded based on K-versus-D. The K-versus-50 fallback only matters if D is unavailable; once K exists, D normally has a K fallback of its own. The blended K is colored lime when above the blended D and red otherwise, so equality draws in the not-above state even though it does not satisfy a bullish or bearish alert. The blended D is colored constant gray. The fill between them follows the blended K's color at faint opacity. Everything is drawn inside the 0..100 frame defined by the reference lines.
Twelve steps. Everything else in the script is input wiring, alert gating, and pane configuration around this core.
Why the clamp exists
A natural question: stochastic is by construction a 0..100 number. Why clamp anything?
Two reasons.
The first is safety against the smoothing chain. Some moving-average families, under unusual inputs (especially short series or aggressive tunings), can briefly produce values that overshoot the input series's range. A smoothed stochastic's instantaneous value can therefore drift outside 0..100 by a small amount during transient conditions. Clamping keeps every plotted line honest to the frame the rest of the indicator draws against.
The second is honesty about the blend. A weighted average of values inside 0..100 is itself inside 0..100 when the weights are non-negative and the values are non-NA β and both of those conditions hold by construction here. The clamp on the blended pair is a defensive boundary more than a daily necessity. It ensures the pane's visible composite stays inside the frame no matter what unusual edge cases arrive.
Practically: if you see a line pinned at 0 or 100 for one or more bars, the clamp is doing its work. A pinned value does not mean "extremely strong" β it means "at or beyond the frame this computation can represent." The instrument cannot tell you how far beyond the frame the smoothed value went. It can only draw the frame.
Why the weighted blend ignores zero-weight slots and slots without K
The blend is built by summing each slot's value times its weight and dividing by the total active weight. Two slots drop out of the sum:
Zero-weight slots. A slot with weight zero contributes zero to the numerator and zero to the denominator. It cannot move the blend. The script also explicitly skips zero-weight slots so they do not show up in the total-weight computation. The practical effect: an enabled slot with weight zero is invisible to the blend but still draws on the pane (unless hidden), still contributes to alignment counts, and still fires its own alerts.
Slots without K. A slot whose K is NA β typically before raw stochastic has enough higher-timeframe history β has no value to average. The script skips that slot in both the numerator and the denominator. Once K exists, D has a K fallback while its own smoothing catches up.
The consequence for your mental model: the blend is not a fixed-denominator average over ten slots. It is an average over the slots that are currently eligible to contribute. As slots warm up, the denominator grows. As you toggle slots on and off, the denominator changes. As you change weights, the denominator changes. The blend's sensitivity depends on which slots are currently in the sum.
Two corollaries worth holding:
All weights at zero produces an NA blend. The script does not silently fall back to equal weights. If you said no slot should steer the blend, the blend has nothing to steer with. This is expected behavior, not a bug.
A single slot dominating the blend is not visually obvious from the blend alone. The slot lines tell that story. The blend can look smooth and coherent while one slot is doing all the work and the others are small corrections. If the reading matters, check the weights before you trust the composite.
What master smoothing is doing, and what it compounds with
Master smoothing applies one additional smoothing pass to the blended pair after the weighted average and the first clamp, using its own MA family, its own length, and its own tunings β all independent of the per-slot smoothings.
The compounding pattern:
Each slot's K is raw stochastic smoothed once (by the K MA).
Each slot's D is the K smoothed again (by the D MA) β so the slot's D is two smoothings away from raw price movement.
The weighted blend is a third operation on top of a mixture of those smoothings.
Master smoothing is a fourth operation on top of the blend.
The total responsiveness of the master-smoothed blended pair is a non-linear combination of all four operations. Any one of them can dominate the latency under specific settings. A master length that is long relative to the per-slot smoothings will dominate; a master length that is short will mostly pass the blend through.
Two implications that matter on the pane:
A long master length compounded with long per-slot smoothings will produce a blended pair that is meaningfully later than the underlying slots. During a regime change, the slots can turn several bars before the master-smoothed blend visibly turns. The slots are the ground truth; the smoothed blend is a processed summary that trades timing for calm.
Running master at length 1 with most MA families is effectively a pass-through. Disabling master smoothing entirely is the cleaner and more honest choice β fewer parts in your mental model.
Do not read the master-smoothed blend as "the raw blend, just cleaner." It is a different series, derived from the raw blend but no longer sharing its responsiveness. Cross-check against the slot lines whenever the smoothed blend's behavior is the thing doing work in your read.
There is a subtler point worth naming: by the time master smoothing is active, the visible blended K is sitting behind four sequential smoothing operations from the raw price series. The information content of the visible line is still the same information β each step is deterministic, and none of the steps destroys information in the signal-processing sense β but the distance between "what price did this minute" and "what the master-smoothed blended K shows you about it" is larger than most readers intuit. The blend feeling numbed during active tape is usually not the market; it is the chain you built.
Why on-bar-close returns the previous bar, not NA or a held value
A reader who has used other multi-timeframe tools might notice that this indicator does not implement non-repainting by hiding the slot until its higher-timeframe bar closes. Instead, the slot returns the previous confirmed higher-timeframe bar's value continuously, until the next close provides a new one.
Three reasons this is the right choice here:
Continuous plotting. A slot that hides between closes would draw as disconnected segments separated by gaps. That is visually noisy and creates a false impression of unreliability. Returning the previous confirmed value keeps the slot's line continuous on every chart bar. The line is honest β each reported value is a value the instrument can defend β and the pane stays readable.
Consistent semantics across slots. With
On Bar Close?on, every such slot reports a confirmed previous-bar value. That is a single semantic across the pane. With the switch off, the slot reports a live value. The two semantics sit side by side per-slot without contaminating each other, because the switch is per-slot.Alert evaluability. Alerts are gated on confirmed chart bars. A slot that hides between higher-timeframe closes would either force the alert layer to fire on phantom states or miss them entirely. Returning the previous confirmed bar gives the alert layer something concrete to evaluate every chart bar, which is the only time-axis the alerts live on.
A design that hid or held-to-NA between closes would change the pane in ways that are hard to undo. The chosen design keeps the tradeoff concentrated in one per-slot switch, which is the entire point.
What the script does and does not do with the higher-timeframe request
A short, honest description of the higher-timeframe data path at the mental-model level:
Each slot makes one higher-timeframe request per chart bar. The request asks TradingView for the slot's chosen source, high, and low at the slot's chosen timeframe on the slot's chosen symbol.
The request is configured with lookahead. On its own, lookahead lets the script see, on a historical bar, the value of the higher-timeframe bar that contains that historical bar. This is the mechanism behind most naive repaint behavior in multi-timeframe implementations.
The
On Bar Close?switch is the gate between the lookahead-enabled request and what the slot actually returns to the rest of the pipeline. With the switch on, the slot returns the previous confirmed higher-timeframe bar's value, effectively fencing the lookahead. With the switch off, the slot returns the live higher-timeframe bar's value, exposing the user to live-bar movement they explicitly asked for.
The technical takeaway: the script is explicit about which side of the gate you are on, per slot. It does not smuggle live values into a "confirmed" slot, and it does not pretend the switch stops the live higher-timeframe value from moving. The switch names the tradeoff; it does not erase it.
Why the Optional Ticker path reroutes more than the source
A property worth naming in its own section, because the manual mentions it several times and this is where the mental model lives.
When the slot requests its higher-timeframe context, the request pulls three series: the chosen source, the high, and the low. These are all read in the context of the slot's chosen symbol. When Optional Ticker is set, that symbol is the other ticker β not the chart symbol. All three series therefore come from the other ticker.
Stochastic is constructed on (source, high, low): it asks where the source sits inside the high/low range. If all three inputs come from another market, the slot's stochastic is a stochastic of that other market. The slot is not the chart symbol's stochastic benchmarked against the other market; it is the other market's stochastic, plotted alongside the chart symbol's stochastic in the same pane.
This is why the rest of the manual frames Optional Ticker as a category change rather than a tuning change. It is not a stylistic phrasing choice; it is a direct consequence of how the higher-timeframe request is wired. A slot with Optional Ticker set is answering a different question than a slot without it, and a reader who thinks of it as "the same stochastic, just on a different ticker" will misinterpret the slot's line every time the two markets diverge.
Why the alignment counts use enabled slots, not weighted slots
The alignment alerts (All Stoch Slots Bullish and All Stoch Slots Bearish) and the invisible counts (Active Bullish Count and Active Bearish Count) iterate over the enabled slots, regardless of weight.
This is a design choice, not an oversight. Two reasons:
The blend already expresses weighting. The blended pair is the place in the pane where weight is visible. The alignment count is a different question: do the slots, considered as separate observations, agree with each other? If alignment also weighted by weight, the count would collapse into a function of the blend, and the reader would lose the ability to ask "how do my slots compare, independent of steering?"
Disable is the cleaner mental model for alignment membership. A slot that is enabled is a slot the reader intentionally watches. A weight of zero says "do not let this slot steer the blend." Those are two different statements. Keeping alignment over enabled slots forces the reader to choose the right mechanism for the right question.
The cost of this choice: a reader who expects alignment to mirror the composition of the blend is surprised the first time a zero-weight slot breaks alignment. The correct response is to disable rather than zero-weight when the question is "which slots should count toward alignment?" The wrong response is to zero-weight everything you do not want in alignment and then wonder why the blend is empty.
What warm-up looks like, stage by stage
When the indicator is first added to a chart, or when a chart is reloaded, the pipeline needs a short warm-up before every stage has data to work with.
The raw stochastic needs at least K Length higher-timeframe bars to produce a value. Before that, the slot's raw %K is NA, so K and D are unavailable.
The K MA can need more raw %K history before it produces a smoothed value. During that gap, the slot uses raw %K as its K rather than hiding the K line.
The D MA can need more K history before it produces a smoothed D. During that gap, the slot uses K as its D rather than leaving D empty.
Because of those fallbacks, early bars can look calmer than expected: K and D may be equal until the D smoothing has enough history to separate. Equality draws as the not-above visual state, but it is neutral for alerts and alignment counts.
The blended pair has a parallel warm-up. While an enabled slot's K is still NA, the blended computation excludes that slot. If no non-zero-weight slot has a usable K yet, the blend is NA. Once K exists for a contributing slot, its D side has the same K fallback described above.
Practical consequence: do not over-read the first handful of bars after a chart load. Let the warm-up complete before treating the pane as the instrument intends.
What is intentionally not on this page
Every absence is deliberate.
Formulas for any moving-average family. The math lives in the shared Axiom MA library. This page does not reproduce it, by design.
Pseudocode of the slot pipeline. The script implements the pipeline; this page describes its mental model. A code-adjacent rendering would blur the line between teaching and cloning.
Library-side parameter semantics. The power-user knobs are listed on Settings by name, with the statement that they apply when the corresponding family is selected. The internal meaning of each parameter inside the library is not part of this product's publishable surface.
"Optimal" numeric recipes. No combination of length, weight, MA type, or smoothing parameter is offered here as a recommendation. The instrument is a workbench; the configuration depends on what the reader is doing with it. A recipe would contradict the trim's core posture.
Internal function or variable names from the script. The mental-model language on this page is written so a reader can reason about behavior without knowing how it is named in code.
A self-test for whether the model landed
Reading this page passively is not the same as holding the mental model it is trying to build. The difference shows up the moment a real chart does something unexpected and you have to reason about why in under a minute. Below are four questions you can pose to yourself after closing this page. If you can answer each one without flipping back, the model is in your head. If you stall on any of them, the section that covers that question is worth a second read before you act on the pane.
A slot's line is flat for twenty minutes on a 5-minute chart. Nothing about the market looks flat. What two settings could cause this, and how would you tell them apart in ten seconds? (Answer lives in the higher-timeframe request and Optional Ticker sections.)
Master Length is set to 20 and the underlying slots just flipped. Roughly how many chart bars will pass before the master-smoothed blended K visibly turns, and why? (Answer lives in the master-smoothing compounding section.)
A bullish enabled slot is visible on the pane, but the blended pair does not include it. How? (Answer lives in the zero-weight/NA skip section and the alignment-over-enabled-slots section, together.)
A slot's K is pinned at 100 for three bars. Does that mean the underlying stochastic is 100, or something else? What does the instrument actually know about the magnitude during those three bars? (Answer lives in the clamp section.)
The four questions are not a quiz. They are the four shapes of "pane behavior I need to explain fast" that come up most often in real reading. If the model works, these are routine. If the model has a gap, the gap shows up here before it shows up in a live decision.
A mental model of a pipeline is not a permanent possession; it fades with disuse the same way any half-remembered chain of reasoning does. If the last time you read this page was six months ago and the pane starts doing something you cannot immediately account for, skim the pipeline section once before chasing a setting. The re-read is cheap. The wrong-cause diagnosis is not.
Where to go next
For the knobs the pipeline is built around, return to Settings.
For the trust framing that the pipeline sits inside, return to Limitations and Trust Boundaries.
For the per-slot timing behavior in particular, return to MTF and Repainting.