For the Geeks

This page is for the reader who wants the mechanical picture behind the visuals — the pipeline at the slot level, the weighted-mean blend, the four structure features as constructions, and the timing model that keeps...

Written By Axiom Admin

Last updated 22 days ago

For the Geeks

This page is for the reader who wants the mechanical picture behind the visuals — the pipeline at the slot level, the weighted-mean blend, the four structure features as constructions, and the timing model that keeps repaint scoped where it belongs. The goal is a working mental model a curious reader can defend and adapt, not a spec sheet someone could rebuild the indicator from.

That line is not a hedge; it is the whole writing posture of the page. The pack is a manual for the person already using the tool, not a reconstruction kit for the person hoping to skip paying for it. Pro MA library internals, adaptive-kernel specifics, exhaustive parameter sweeps, and reproducible implementation recipes stay inside the script. What you get here is enough to know what is happening under your hands, enough to verify the instrument is telling you what you think it is telling you, and enough to tune the knobs deliberately instead of superstitiously.

The difference matters because a reader who only has surface-level descriptions ends up with two uncomfortable options: trust the visuals without understanding them, or simulate the maths somewhere else to "check." Neither builds real judgment. A mental model — one that names the shape and the tradeoff of each mechanic without giving you the source — builds judgment, because it lets you predict how the instrument will respond to a change before you make the change and then verify that prediction on your chart.

A short route map. Sections 1 and 2 cover the slot pipeline. Section 3 covers the blend construction. Section 4 covers the optional master smoothing pass. Section 5 covers the four structure features, one at a time. Section 6 covers timing, repaint, and the confirmation boundary that divergence respects. Section 7 covers verification paths you can run yourself to pin each of these mechanics to what you see on the chart.


1. The slot pipeline at a glance

Each of the five slots is a double-smoothed classical slow stochastic. The chain has three stages:

  1. A raw stochastic reading of the current bar's source against the bar's own high-low range, over a configurable lookback length.

  2. A first smoothing pass: the raw reading is smoothed by a user-chosen MA family and length into the slot's K line.

  3. A second smoothing pass: the K line is smoothed by another user-chosen MA family and length into the slot's D line.

Both outputs are clamped into the 0..100 range at the slot exit, so no slot value can overshoot the pane.

This is the classical slow stochastic structure at a high level. The standard reference settings — K length 14, K smoothing 3 SMA, D length 3 SMA — match the defaults. If you have used ta.stoch and smoothed it yourself, the slot pipeline is doing exactly what you would do by hand, wrapped in a layer that lets you run it on any timeframe, on any symbol, with any MA family, and with a deliberate choice about whether the slot returns the previous-bar confirmed value or the live forming-bar value.

1.1 The source and range asymmetry worth naming

The raw stochastic takes a source and a separate pair of high/low inputs. The script always passes the bar's own high and low for the range. Changing the source only changes where inside the range the current bar's value is located. The range denominator never changes as a function of source. The Settings page, Visuals and Logic page, and Troubleshooting page all name this because it is a recurring misread. Here, the mechanical reason is that ta.stoch's signature splits the two roles: one argument is "where is the current value in the range," and the other two arguments define the range itself.

The practical consequence: on quiet bars with small intra-bar ranges, changing Source barely moves the slot K. On wide-range bars it moves more. In no case does changing Source change the effective lookback or the effective range.

1.2 The MA family matters more than a single "length" parameter

The K smoothing pass and the D pass both read from the Axiom Moving Average Library Pro. The Pro library exposes a set of families: simple moving average, exponential, weighted, Hull, Arnaud Legoux, Kaufman's adaptive, fractal adaptive, Jurik, Laguerre, volume-adjusted, and variations thereof. Some families are fully defined by their length — SMA, EMA, WMA. Others have additional parameters — ALMA has offset, sigma, and floor; KAMA has fast and slow periods; FRAMA has its own fast/slow; Jurik has phase and power; Laguerre has alpha; VAMA has a volatility length — and those parameters live inside the Power User block for that family.

The mental model: the Power User block is dormant unless its paired family is selected. If your K smoothing MA is SMA and you tune ALMA's offset, nothing happens because ALMA is not in the compute path. When you select ALMA, the Power User block becomes live and its values flow into the smoother.

The reason the pack cross-references the Axiom MA Library Pro manual rather than re-teaching each family: each family's behaviour — how it weights recent data, how it responds to trends versus chop, what lag profile it produces — is a whole discussion of its own. Readers who want to tune Power User parameters should read that pack. Readers using SMA or EMA at defaults can ignore the Power User blocks entirely.


2. The slot's On Bar Close? choice, as a timing model

Each slot exposes an On Bar Close? boolean. Under the hood, after the slot has computed its clamped K and D, the final output selection is:

  • On Bar Close? = true. Return the previous bar's clamped K and D.

  • On Bar Close? = false. Return the current bar's live clamped K and D.

This one-line choice has a cascade of consequences because the slot's request.security call uses lookahead = barmerge.lookahead_on.

lookahead_on is a Pine option that tells request.security to fetch the most recent higher-timeframe value — including live values from a forming HTF bar. Used alone on a historical bar, lookahead_on pulls the HTF value that was actually current at that historical chart bar's close, which means the HTF value for the historical bar may reflect an HTF bar that had not yet closed at the historical chart bar. That can paint historical bars with future information.

The pairing lookahead_on + [1] solves this. The [1] shift returns the previous HTF bar's value — which is always a bar that had fully confirmed by the time the current chart bar was printing. Historical bars therefore plot against confirmed HTF values that were available at those historical chart bars. Nothing in the historical series repaints.

When On Bar Close? = false, the [1] shift is skipped. The slot uses the live HTF value. That makes the current forming HTF bar responsive, but it also means the safe historical pairing is gone. Historical false-branch values can differ from the confirmed branch because they are not offset to the prior confirmed HTF bar. Treat this as a live-read mode, not as a historical proof mode.

The mental model:

  • On Bar Close? = true is the safe HTF pattern. Historical bars are stable. The current forming bar shows the previous HTF bar's confirmed value, which is a one-bar lag on the HTF.

  • On Bar Close? = false is the live HTF pattern. The current forming bar shows the forming HTF bar's live value, which can change every tick until the HTF bar closes. Its historical values are not the safe non-repainting reference; use the true branch when you need confirmed-history evidence.

Neither is strictly better. They trade speed against stability in opposite directions. The mtf-and-repainting page walks through the consequences in detail, including the mixed-posture failure mode when different slots make different choices.


3. The blend as a weighted mean

The blend helper iterates the five slots' K values against five weights, and returns the weighted mean of the active slots' K. The same construction runs separately on the five slots' D values. Two mechanical properties matter.

3.1 Zero-weight and na-slot skipping

A slot contributes to the blend only if its weight is non-zero and its value is not na. The helper skips both cases in the accumulation. The total weight is the sum of the contributing slots' weights, not a fixed constant.

Consequence one: scaling every active slot's weight by the same factor produces the exact same blend, because the weighted sum and the total weight both scale by the same factor. Weights are relative, not absolute. You are not required to make weights sum to 100; they sum to whatever they sum to.

Consequence two: weight zero is not the same as Enable = false. A weight-zero slot still runs its full pipeline. Its K and D are computed, clamped, plotted if Hide Plot is off, and exposed to the per-slot alert logic. The blend simply skips the slot's contribution. The only thing weight zero silences is the slot's pull on the blend.

3.2 When the blend returns na

If no active slot contributes — either because every enabled slot has weight zero, or because every enabled slot is returning na, or because every slot is disabled — the total weight is zero and the blend returns na. Plots draw nothing on na. The pane will show reference guides and structure overlays but no blend K and no blend D line.

This is the failure path behind troubleshooting row 5 ("blend line disappears from the pane"). The fix is to restore at least one enabled slot with a non-zero weight and a valid value.


4. The master smoothing pass

Enable Smoothing applies a single MA pass to both blend K and blend D after the weighted mean. The same MA family and length are used for both. A final clamp into 0..100 runs after the smoothing.

Two practical notes.

First, the smoothed blend is the input that every structure feature reads. When you enable master smoothing, you are not just calming the visible blend plot — you are changing the input series that divergence, Keltner, BBWP, and Donchian all see. Their output shifts together. This is one of the clearest places the "one series, four lenses" fact becomes visible: toggle master smoothing and watch all four structure features move in lockstep.

Second, the smoothing adds lag in proportion to the MA length. A short EMA (length 2 or 3) adds minimal lag and gives a modest visual calm. A longer MA adds more lag and calms the plot more. The choice is yours. The tradeoff is symmetric: less lag, more chop on the plot; more lag, more calm and more delay on every downstream consumer including blend-based alerts.

The per-slot alerts do not read the smoothed blend. They evaluate slot K versus slot D. Enabling master smoothing does not affect per-slot alert timing.


5. The four structure features as constructions

All four structure features read the blended K after the master smoothing pass (if any) and after the final clamp. They run in parallel; the order in which the script evaluates them does not matter because none of them feeds any of the others.

5.1 Divergence — chart-price pivots against blended-K offsets

The divergence module detects pivots on chart price, not on the oscillator. It uses ta.pivotlow(low, n, n) on the chart bar's low and ta.pivothigh(high, n, n) on the chart bar's high, with symmetric left-and-right lookback n = Pivot Len (default 20). A pivot is only confirmed once n bars to the right of the candidate bar have printed.

When a new pivot confirms, the module pairs it with the previous confirmed pivot of the same kind (previous low for a new low, previous high for a new high). The check for a bullish divergence is:

  • The new chart-price pivot low must be strictly below the previous chart-price pivot low.

  • The blended K value at the new pivot's time offset must be strictly above the blended K value at the previous pivot's time offset.

Both conditions must hold on the same confirmation bar. The bearish divergence check mirrors this: new price high above previous, new blended-K high below previous.

The entire comparison is gated by barstate.isconfirmed — the Pine boolean that is true only on fully closed bars. No divergence evaluation runs on a forming bar.

Two facts worth holding:

  • The divergence uses chart-price pivots, not oscillator pivots. The oscillator reading at the pivot is a comparison value, not the pivot itself.

  • The pivot offset used for the blended-K comparison is the same n that defines the pivot's right-side lookback. The comparison is "blended K at the exact bar the pivot formed."

The triangle draws at the confirmation bar by default. With Plot On Pivot? on, the drawing's offset parameter is set to -n, which shifts the drawn shape n bars into the past so it sits over the pivot bar. The alert condition reads the divergence boolean on the confirmation bar, so alerts fire at bar T regardless of the drawing's shift.

5.2 Keltner envelope — MA basis plus range EMA on the blend

The Keltner construction has two pieces computed on the blended K.

First, a basis MA: the blended K is smoothed by a user-chosen MA family (KC Basis Type, default EMA) and length (KC Basis Len, default 20). This is the envelope's midline.

Second, a range estimator: the bar-to-bar absolute difference of the blended K is computed — |blendK_t - blendK_{t-1}| on each bar — and smoothed into an EMA over KC Length bars (default 20). This produces a per-bar average magnitude of bar-to-bar change in the blend.

The upper band is basis + rangeEma * KC Mult. The lower band is basis - rangeEma * KC Mult. The default multiplier is 2.0.

Two mental-model notes:

  • The range estimator uses bar-to-bar absolute difference on the blended K, not on price. The envelope is purely a function of the oscillator's own motion. A wide envelope means the blended K has been moving with large bar-to-bar jumps recently; a tight envelope means the blended K has been moving in small bar-to-bar steps.

  • A Keltner touch on the oscillator is an oscillator-stretch reading. It is not a price-overbought or price-oversold reading. The Limitations page and the Visuals and Logic page both call this out.

5.3 BBWP — matched-length Bollinger width, percentile-ranked

The BBWP construction runs in two stages.

Stage one: a matched-length Bollinger width on the blended K. The basis is an MA of the blended K, with the user's BBWP Length (default 20). The standard deviation is computed on the blended K with the same length. The width is upper - lower = (basis + k*stdev) - (basis - k*stdev) = 2*k*stdev for a Bollinger construction with multiplier k. The point worth making here is that the basis MA length and the standard deviation window share a single length input — BBWP Length — and changing that input changes both pieces at once. The code comment inside the width helper says so explicitly, and the Settings page repeats it.

Stage two: the current width is percentile-ranked against the prior BBWP Lookback widths (default 252). The percentile rank is a number between 0 and 100 — the percentage of prior widths that were less than or equal to the current width. That number is the column height on the pane.

The threshold input (BBWP Threshold, default 50) only controls the colour switch between aqua and blue. It does not affect the computed percentile.

Three mental-model notes:

  • BBWP here is computed on the blended K, not on price. This is the central trust boundary of the feature. Low BBWP means the blend's band width is at the low end of its own recent history; it does not mean price has been quiet.

  • The lookback window is 252 bars by default, which is roughly a year on a daily chart or a much shorter period on intraday charts. On a 5-minute chart, 252 bars is a little over a day of trading. The percentile rank is always relative to the current lookback window.

  • The percentile is a rank, not a measurement of absolute width. A BBWP of 30 on one symbol and a BBWP of 30 on another symbol do not mean the same absolute width; they mean the current width is at the 30th percentile of its own recent history in each case.

5.4 Donchian — highest and lowest of blended K with optional basis smoothing

The Donchian construction is straightforward. ta.highest(blendK, DC Len) is the upper stepline. ta.lowest(blendK, DC Len) is the lower stepline. The midpoint is the average of the two, optionally smoothed by a user MA family and length.

DC Basis Len defaults to 1, which is a passthrough. The midpoint is the raw average of the upper and lower steplines unless the user raises DC Basis Len above 1.

The visible plots use plot.style_stepline. Steps, not curves, because ta.highest and ta.lowest only change value when a new extreme is set. A curve between those step points would imply smooth motion that is not there.

The mental model: the steplines mark where the blended K has reached its highest and lowest values over the lookback window. When the blended K presses the upper stepline, it is making a new local high in oscillator space. When the steplines compress, the blended K has been range-bound. These are statements about the oscillator's own range, not about price.


6. The timing model

A few timing properties hold across the indicator that are worth stating once as a group, because they are easier to keep in your head as a single mental model than as five scattered facts.

6.1 Every output is clamped to 0..100

Slot K and slot D are clamped at the slot exit. Blend K and blend D are clamped at the blend exit. The structure features that wrap or derive from the blend respect the clamp because their inputs are already clamped. Divergence comparisons never see out-of-range values because the blended K fed to them is clamped. Plot coordinates never overshoot the pane.

This is defensive. It is also why the pane looks the same regardless of how extreme the inputs get — no overshoots, no underflows, just a bounded oscillator doing bounded things.

6.2 barstate.isconfirmed is the gating boolean for alerts and divergence

Pine exposes a barstate.isconfirmed boolean that is true only on fully closed bars. The indicator uses this boolean as the gate on every alert condition — per-slot, blend, alignment, and divergence — and on the divergence evaluation itself. No alert can fire on a forming bar. No divergence comparison can run on a forming bar.

This is what makes the alert surface predictable. Every alert reports on a confirmed bar. The divergence alerts in particular are guaranteed to fire on a bar where both the pivot and its comparison are fully formed.

6.3 lookahead_on + [1] is the safe HTF pattern

The slot's request.security call uses lookahead_on. The [1] shift in the On Bar Close? = true branch turns that into the safe HTF pattern: historical bars plot against confirmed HTF values, and the current forming bar shows the previous confirmed HTF bar's values. Without the [1] shift, the slot returns live values, the forming bar can update as new data prints in the HTF bar, and historical false-branch values should not be treated as confirmed-history evidence.

This is a standard Pine idiom. It is called out here for readers who want to see the mechanism: the [1] shift is why nothing in the historical series repaints under On Bar Close? = true, and the live behaviour under false is scoped to the forming bar.

6.4 The confirmation-bar semantic for divergence

The divergence module's barstate.isconfirmed gate means divergence evaluation runs on closed bars only. The pivot-confirmation semantic of ta.pivotlow/ta.pivothigh with symmetric n means a pivot is only visible to the evaluation once n bars to the right have formed. Both together produce the timing rule: a divergence confirms on bar T, and the pivot it describes formed at bar T minus Pivot Len.

The Plot On Pivot? offset only changes where the triangle draws. It does not change the confirmation timing, it does not change the alert timing, and it does not change the geometric fact that the pivot the triangle describes is Pivot Len bars to the left of the confirmation bar.


7. Verification paths you can run

The previous sections are mental model. This section is the part where you can pin each mental-model claim to what you see on the chart. None of these require more than a few minutes on a quiet chart.

7.1 Verify the 0..100 clamp holds under extreme inputs

Pick a symbol with a strong trending move. Watch the blended K during the trend. Confirm the blend never exits the 0..100 range. Zoom in to pivots where the blend is near 0 or 100. The line touches the boundary and stays inside.

This verifies that every clamp in the pipeline is doing its job.

7.2 Verify that scaling weights by a constant leaves the blend unchanged

On a 1m chart at defaults, note the blend K value on the current bar. Set every enabled slot's weight to 10 times its current value (so 33.3 becomes 333). Note the blend K again. The value is the same.

This verifies weighted-mean behaviour.

7.3 Verify that Hide Plot does not affect the blend

Unhide slot 03's K line. Note the blend K value. Re-hide slot 03. Note the blend K again. Same value.

This verifies Hide Plot is a visibility control, not a compute control.

7.4 Verify that weight zero leaves the slot running

Set slot 01's weight to 0 with Hide Plot unchecked and Enable true. The slot K line continues to draw. Per-slot alerts on slot 01 continue to fire on confirmed bars where K is above or below D.

This verifies weight zero only silences the blend contribution, not the slot itself.

7.5 Verify that master smoothing affects every structure feature

Enable master smoothing with EMA length 3. Watch the blend K line calm. Watch BBWP shift, Donchian shift, and if Keltner is enabled, watch its bands shift. All four move together.

This verifies that the four structure features share the smoothed blended K as their input — the single most important fact in the pack about the structure features.

7.6 Verify the divergence timing rule

Enable Plot On Pivot?. Wait for a confirmed divergence on a live chart. Note the bar where the alert fires — that is bar T. Count the bars from bar T back to the triangle's drawn position — that should be Pivot Len bars. Disable Plot On Pivot?; the triangle redraws at bar T (the confirmation bar). The alert timestamp does not change; only the drawing position moves.

This verifies the decoupling of drawing offset and alert timing.

7.7 Verify On Bar Close? = true stability on historical bars

Set slot 03's On Bar Close? to true. Note the slot 03 value on a bar 200 bars in the past. Wait one chart bar to close. Check the same 200-bars-ago bar. Same value. Flip slot 03's On Bar Close? to false, wait one bar, re-check the 200-bars-ago bar. The value is likely different. Flip back to true; the value returns.

This verifies the lookahead_on + [1] safe HTF pattern.


8. What this page does not publish

For completeness, a short statement of what is deliberately not here and why. Each omission has a reason, and knowing the reason is itself part of the mental model.

  • Pro MA library internals. Specific family coefficients, adaptive-kernel step rules, proprietary smoother variants: not reproduced. The Axiom MA Library Pro pack covers the safe-to-disclose family descriptions. The full internals live inside the script because they are the product's own work. Describing them at the level of "this family weights recent data more heavily and lags less in trend" gives you the tuning vocabulary you need; publishing the coefficients would hand a reconstruction to anyone willing to read.

  • Parameter sweeps and performance heuristics. "K length 7 works best on scalping, length 21 works best on swing." "ALMA offset 0.85 is ideal for crypto." Any sentence of that shape is tuning disguised as teaching. The tuning belongs to you; a pack that handed you a number would be selling you a belief, and beliefs are expensive on this side of the market. Defaults are explained because they are legible, not because they are optimal.

  • Comparative performance claims against other methods. "This beats classical stochastic by X%." "BBWP here is more reliable than vanilla BBW." Those require measurement. The pack does not measure for you; a measurement run on one timeframe, one symbol, and one regime does not generalize, and you would be right to distrust it if it claimed to.

  • Reconstruction recipes. "Implement this yourself with these steps." Not here. The mental model above is enough to defend and adapt the instrument; it is deliberately not enough to rebuild it from scratch. If you find yourself reading this page with a blank script open beside it, you are reading it for the wrong reason — no amount of careful description on the manual side will produce the thing the indicator does, because the description is not the implementation.

The safe-to-disclose boundary is simple in principle: describe the shape and the tradeoff, keep the recipe. Everywhere a reader would benefit from knowing what a feature does and how to verify it, the page tells them. Everywhere a reader would only benefit by being able to reproduce the feature, the page stops.


Where to go next: Visuals and logic for the reading order the mechanics feed, MTF and repainting for the timing model applied to per-slot behaviour, Limitations and trust boundaries for the honest edges of this mechanical picture, Settings for the input-by-tier breakdown that exposes each mechanic to the user.