Percentile trends
Rolling support and resistance at the 10th and 90th percentile of recent closes, plus each line's slope.
On every bar it takes the closes of the last window bars and reads two percentiles from them: the low_pct percentile (10th by default) becomes a support line and the high_pct percentile (90th) a resistance line. A percentile skips the extreme closes, so both lines sit inside the window's range rather than on its highest and lowest bar. Each line's percent change over the last half-window is also output as a slope.
How to read it
- The two price lines sit on the candles: the lower is support, the upper is resistance, both drawn from the same recent window.
- A close above the upper line is in the top tenth of the window; in a strong trend that happens on many bars.
- The lines move slowly because one new close shifts a percentile only slightly, so a sharp move shows as price pulling away from the lines.
- The two slope panes show each line's percent change over the last 50 bars: zero is flat, above zero rising, below zero falling.
What it outputs
- Support
- The low_pct percentile of the last window closes, drawn on the candles. About one close in ten in the window sits below it by construction.
- Resistance
- The high_pct percentile of the last window closes, drawn on the candles. About one close in ten in the window sits above it.
- Support slope
- Percent change of the support line over the last half-window (50 bars at default). Below zero means the floor is falling.
- Resistance slope
- Percent change of the resistance line over the same half-window. Above zero means the ceiling is rising, below zero that it is falling.
Settings
- window
- How many recent closes the two lines are drawn from. At 20 they hug price and move within about 20 minutes; at 500 to 2000 they are slow, wide and stable. The slope lookback is half this value, so it shortens and lengthens with it.
- low_pct
- The percentile of closes that forms the support line, as a decimal. Raising it toward 0.25 lifts support toward the middle of the window and narrows the band; lowering it toward 0.01 drops support to the window's lowest closes.
- high_pct
- The percentile of closes that forms the resistance line, as a decimal. Lowering it toward 0.75 pulls resistance toward the middle and narrows the band; raising it toward 0.99 pushes resistance to the window's highest closes.
Pitfalls
- low_pct and high_pct are decimals from 0 to 1, not percents. The sliders reach -11 to 11 and -91 to 91, but values outside 0 to 1 make numpy raise an error.
- The lines are percentiles of recent closes, not true support. In the SPY sample closes reached 749.8 while the lowest support value was 750.9.
- At default window 100 the first 99 bars have no value, about 0.5 percent of the sample. Nine in ten slope values fall between -0.17 and 0.17 percent, so they are easy to misread as large.