Rolling Fn
Rolling Fn applies one of 30+ statistical functions over a sliding window of configurable length. At each bar, the function sees the most recent period values. Bars with fewer than period prior values produce null.
Algorithm
// For each bar i in [windowStart, len):
The window always has exactly period elements (or fewer near the start, which yields null). This makes it equivalent to a standard rolling indicator like a moving average.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| func | WinFuncType | 'max' | Statistical function applied to each rolling window. See the full list below. |
| period | number | 20 | Rolling window length in bars. Bars before index period − 1 produce null. |
Supported Functions
Descriptive Statistics
maxHighest value in the window.minLowest value in the window.averageArithmetic mean.medianMiddle value when sorted.sumTotal of all non-null values.countCount of non-null values.rangemax − min.Dispersion
stdSample standard deviation.varianceSample variance.madMean absolute deviation.cvCoefficient of variation (std/mean).rmsRoot mean square.iqrInterquartile range (q3 − q1).q125th percentile.q375th percentile.Trend & Regression
slopeLinear regression slope over the window.interceptLinear regression intercept.r_squaredCoefficient of determination.momentumLast value − first value of the window.accelerationChange in slope between first and second halves.Risk & Return
gainSum of positive changes in the window.lossSum of negative changes in the window.volatilityAnnualised volatility of returns.sharpeMean return / std of returns.sortinoMean return / downside deviation.max_drawdownPeak-to-trough maximum loss.Shape & Position
skewnessAsymmetry of distribution.kurtosisTail weight of distribution.argmaxIndex of maximum value within the window.argminIndex of minimum value within the window.Information
entropyShannon entropy (bin-based).autocorrLag-1 autocorrelation.rsiRelative Strength Index of the window.Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Input | ||
| input | (number | null)[] | Any numeric series with matching timestamps. |
| Outputs | ||
| values | (number | null)[] | Per-bar function result. Null for bars where the window extends before the first bar. |
| timestamps | number[] | Bar timestamps, aligned 1-to-1 with values. |
| func | WinFuncType | Active function name (mirrored for display). |
Use Cases
Rolling highest high / lowest low (Donchian channel)
Apply func = max to the high series and func = min to the low series, both with period = 20. The result is a Donchian channel you can compare against close for breakout signals.
Adaptive volatility for position sizing
Use func = std (or volatility) with a 20-bar window on close returns. Feed the output into Position Sizing as a dynamic stop multiplier: when volatility expands, the stop widens automatically.
Trend detection via slope
Apply func = slope with period = 14 to a moving average series. When slope > 0 the trend is rising; when < 0 it is falling. Feed this into a Compare node to generate a binary trend direction flag.