Systemicbeta

Percentile

systemic:core-percStatistics

Inputs

NameTypeDescription
PercentileWhole numberThe percentile to compute on each subset, a whole number from 1 to 100.
DataNumber seriesThe series of numbers to analyze.

Outputs

NameTypeDescription
PercentileNumber seriesFor each bar, the chosen percentile of all values in the series that are less than or equal to that bar's value.

Cost

13
credits per run
1,000
bars

0.194 + 0.0119·n + 0.0000000734·n² credits for n bars, rounded up. The marks are each plan's limit of bars.

The Percentile module computes a conditional quantile for each bar of a series. For every value, it keeps only the values of the whole series that are less than or equal to it. It then computes the chosen percentile of that subset.

Outputi=Qp({x∈Data∣x≤Datai})\text{Output}_i = Q_p\bigl(\{x \in \text{Data} \mid x \leq \text{Data}_i\}\bigr)

Where QpQ_p is the pp-th percentile, and pp is the Percentile input (1 to 100).


How It Works

flowchart TD
    subgraph Input["Input Data"]
        D["Data: [10, 25, 15, 30, 20]"]
        P["Percentile: 50"]
    end
    
    subgraph Process["For Each Value"]
        V["Current value = 25"]
        F["Filter: values ≤ 25<br/>[10, 25, 15, 20]"]
        Q["Compute 50th percentile<br/>of filtered set"]
    end
    
    subgraph Output["Result"]
        R["Output = 17.5"]
    end
    
    D --> V
    P --> Q
    V --> F --> Q --> R

Step by step for one bar:

  1. Take the current value (e.g., 25)
  2. Keep the values of the whole series that are ≤ 25: [10, 25, 15, 20]
  3. Compute the chosen percentile (e.g., 50th) of that subset
  4. Result: 17.5 (the median of [10, 15, 20, 25])

The same steps repeat for every bar in the series.


Understanding the Percentile Parameter

The Percentile input (1–100) sets which percentile to compute on the subset:

PercentileMeaning
25First quartile of values ≤ current
50Median of values ≤ current
75Third quartile of values ≤ current
100Maximum of values ≤ current (equals current value)

⚠️ Important: This is not a percentile rank (how the current value ranks against history). It is a percentile of a subset that changes with each value.


Practical Applications

1. Dynamic Support Level Detection

With a low Percentile (e.g., 25), the output approximates a dynamic support level: the lower quartile of all values that are not above the current price:

flowchart LR
    subgraph Concept["Support Level Logic"]
        Price["Current Price"]
        Filter["Values ≤ Price"]
        Q25["25th Percentile"]
        Support["Dynamic Support"]
    end
    
    Price --> Filter --> Q25 --> Support

2. Distribution Analysis

Compare the outputs at different Percentile settings:

SettingInterpretation
PERC(25) vs PERC(75)The spread of the lower values shows how skewed the distribution is
PERC(50)The middle of the subset
PERC(100)Always equals the input

3. Conditional Median Tracking

PERC(50) gives the median of all values that are not above each value. It shows where the "typical" lower value sits relative to each observation:

flowchart TD
    subgraph Strategy["Conditional Median Strategy"]
        Data["Price Series"]
        PERC50["PERC(50)"]
        Compare{"Price > PERC(50)?"}
        Above["Above conditional median<br/>Relative strength"]
        Below["At or below<br/>conditional median"]
    end
    
    Data --> PERC50 --> Compare
    Compare -->|Yes| Above
    Compare -->|No| Below

Example Walkthrough

Take the data series [100, 80, 120, 90, 110] with Percentile = 50:

IndexCurrent ValueFiltered Set (≤ current)50th PercentileOutput
0100[100, 80, 90]9090.0
180[80]8080.0
2120[100, 80, 120, 90, 110]100100.0
390[80, 90]8585.0
4110[100, 80, 90, 110]9595.0

Note: The filter uses the whole series, not only earlier values.


Key Characteristics

Whole-series analysis: The filter looks at all bars, not a rolling window. Each output depends on the whole input series.

Outputs depend on the distribution: How far the output sits below the input depends on the values in the subset.

Boundary behavior:

  • At Percentile = 100, the output always equals the input (the largest value ≤ a value is the value itself)
  • At Percentile = 1, the output is close to the lowest value in the series for most inputs

Advantages

  • Context-aware — The output describes the distribution below each observation
  • Flexible — Different Percentile settings show different aspects of the data
  • Non-parametric — No assumption about the shape of the distribution

Limitations

  • Not intuitive — The conditional filter is different from a standard percentile rank
  • Uses later data — see Non-Causality below
  • Sensitive to outliers — Extreme values change which values fall in each subset

Non-Causality

This module is not a running or rolling percentile. Every output is computed against the whole series of the run, including bars that come after it. The output on a past bar can change when later data changes its subset. Past outputs therefore use information that was not known at the time and are not tradeable signals. Only the newest bar's output uses no later data. Do not backtest a strategy that reacts to past PERC values: the result would not match what was knowable on those bars.


Missing Data

An empty (null) value in the data series is left out of every subset. It is never counted as zero or replaced by an earlier value. On the bar where the value itself is empty, the output is empty; no other bar is affected.


Further Reading

Rendering diagrams...
© 2026 WanoLabs. All rights reservedBeta v0.1.5