XeL OnlineRecursion

3 157
XeL OnlineRecursion is a Pine Script library for online and streaming statistical estimation on continuous numerical and financial data.

The library is designed around recursive statistical populations whose retained state is updated observation by observation. Most recursive components use constant retained memory and O(1) work per observation, making them suitable for indicators and models that require adaptive statistics without repeatedly recalculating an entire historical window.

OnlineRecursion is statistical infrastructure rather than a trading signal, strategy, or standalone indicator. It is intended to be imported and composed by other Pine scripts.


CORE DESIGN

The library separates four conceptual layers:

  1. Streaming and population mechanics.
  2. Generic retained statistical state.
  3. Derived statistical interpretations.
  4. Finance-oriented evidence and recursive weighting models.


A central design principle is that retained state represents a statistical population. Statistics that can be derived from an existing population are computed from that state rather than introducing unnecessary independent recursions.


STATISTICAL TOOLS

The library includes:

  • First-order recursive filtering and recursive extrema estimation.
  • Sample-and-hold, settlement, accumulation, and exact rolling-sum tools.
  • Fixed-memory P2 cumulative quantile estimation.
  • Adaptive quantile and expectile estimation.
  • Adaptive conditional tail-mean estimation.
  • Adaptive Huber location estimation.
  • Adaptive MAD and Gaussian-equivalent robust scale.
  • Recursive univariate moments through fourth order.
  • Variance, sigma, skewness, kurtosis, and effective sample size.
  • Recursive covariance and correlation.
  • Recursive linear-regression views including beta, intercept, and R-squared.
  • Recursive Heavy-Tail distribution estimation.
  • Relative-return, relative-projection, and additive-moment transforms.
  • Recursive decay, anchored, participation, and composite-alpha constructors.
  • Market-participation models.
  • Market-dispersion models.



POPULATION SEMANTICS

OnlineRecursion treats population geometry as part of the mathematical definition of an estimator.

Depending on the component, the represented population may be:

  • Cumulative.
  • Finite rolling.
  • Exponentially weighted.
  • Anchored.
  • Conditional.
  • Observation-clock.
  • Event-clock.


These population interpretations are not assumed to be interchangeable.

Initialization, missing observations, reset behavior, recursive coefficients, and population boundaries are therefore explicit estimator semantics rather than incidental implementation details.

Where defined as a recursive feedback coefficient, alpha generally follows a [0,1] convention. Exact initialization behavior is defined by each estimator because creation of a new statistical population is not always equivalent to an ordinary recursive update.


FINANCE-ORIENTED EVIDENCE

The library includes reusable tools for constructing adaptive market evidence, including time-decay weighting, participation-based weighting, relative-return transformations, and recursive market-dispersion models.

Available dispersion interpretations include:

  • Mean displacement.
  • Realized movement.
  • Drawdown.
  • Upthrust.
  • Directional stress peaks.
  • Average directional stress.


Participation models allow recursive weighting to respond to different market-population relationships rather than treating every observation as equally informative.

The chart accompanying this publication demonstrates library mechanics on NQ continuous futures using hourly observations and Open Interest participation.

The upper and lower dispersion plots, recursive mean, and lower-pane statistic illustrate one possible composition of exported library functionality.

These plotted outputs are demonstrations of statistical mechanics. They are not trading signals or recommended parameter settings.


HEAVY-TAIL MODEL

The Heavy-Tail estimator combines generic recursive moment state with additional model-specific interpretations such as Student-t degrees of freedom, t-distribution scale, and absolute-innovation scale.

HeavyTail is one statistical interpretation built on the generic moment backbone. The library does not assume that this model is appropriate for every market, instrument, or application.


USAGE

Import the library from another Pine Script and use the exported state types, methods, enumerations, or functional interfaces required by the application.

Stateful interfaces provide explicit control over retained state and update timing. Functional interfaces are also provided where convenient for series-oriented use.

Some estimator compositions intentionally require caller-controlled timing.

For example, when one adaptive estimator supplies a threshold, center, or scale to another estimator, the caller may need to use the previously retained value to avoid unintended same-observation feedback.


MISSING DATA AND CALLER POLICY

Market-data-dependent functions can return na when required information is unavailable or when the requested statistical relationship is not currently defined.

Fallback behavior intentionally remains with the importing application when the library cannot define the relationship mathematically.

This prevents unavailable data from being silently converted into a different statistical assumption.


LIMITATIONS

OnlineRecursion does not provide:

  • Entry or exit logic.
  • Trading recommendations.
  • Profitability claims.
  • A guarantee that any estimator is appropriate for a particular market.


Recursive estimators depend on their coefficient policy, population definition, and initialization semantics.

A recursive population is not automatically equivalent to a finite rolling-window population merely because their outputs may appear similar.

Users should therefore select estimators and coefficient models according to their statistical meaning rather than treating all recursive parameters as interchangeable smoothing controls.


DESIGN INTENT

OnlineRecursion is intended to provide reusable statistical infrastructure from which higher-level models can be composed.

The architecture follows this separation:

  1. Foundational state represents the retained population.
  2. Derived statistics interpret that population.
  3. Models add model-specific assumptions.
  4. Applications decide how statistical evidence is used.


This separation is intended to keep generic statistical machinery independent from application-specific trading logic.


VERSION

This first TradingView library publication corresponds to XeL OnlineRecursion development release 1.0.0-rc.2, dated 2026-09-04.

TradingView library publication revisions such as /1 are independent of the project's development release numbering.

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。