Skip to main content

๐ŸŒพ Slope Distribution Fan

Core Question:
Given the current slope magnitude and direction,
what is the historical distribution of slope values over the next N bars?


๐Ÿงญ Conceptโ€‹

The Slope Distribution Fan measures the conditional likelihoods of future slope values, conditioned on the current slope.
It answers questions like:

โ€œWhen the current slope is +0.15, what distribution of slopes historically followed over the next 1, 2, or 3 bars?โ€

This creates a โ€œfanโ€ of possible slope outcomes โ€” a probabilistic envelope that describes how slope typically evolves.

๐Ÿ–ผ๏ธ Placeholder: Distribution Fan Visualization
Visual: central slope at time t, with multiple translucent curves fanning out to show slope distributions at +1, +2, +3 bars.


๐Ÿ”ข Mathematical Definitionโ€‹

Let sts_t be the slope of a smoothed price series (e.g., SMA or EMA).

For each observation sts_t, collect the next N slope values:

{st+1,st+2,โ€ฆ,st+N}\{s_{t+1}, s_{t+2}, \ldots, s_{t+N}\}

Group all observations by current slope bin (e.g., rounded or quantized values),
and compute the empirical distributions of future slopes within each bin:

P(st+hโˆฃst)P(s_{t+h} \mid s_t)

for horizons h=1,2,โ€ฆ,Nh = 1, 2, \ldots, N.

Each horizon forms one layer of the โ€œfan.โ€


โš™๏ธ Usageโ€‹

  1. Compute slopes from your smoothed series.
  2. Define current-slope bins (e.g., quantiles or fixed-width buckets).
  3. For each bin:
    • Collect all subsequent slope values up to horizon N.
    • Record the empirical distribution P(st+hโˆฃstโˆˆbin)P(s_{t+h} \mid s_t \in \text{bin}).
  4. Visualize or summarize these conditional distributions.

๐Ÿ–ผ๏ธ Placeholder: Workflow Diagram
Visual: pipeline showing โ€œCompute slope โ†’ Group by slope bin โ†’ Aggregate future slopes โ†’ Plot fan.โ€


๐Ÿ’ก Example (Pseudocode)โ€‹

import pandas as pd
import numpy as np

df["sma"] = df["close"].rolling(10).mean()
df["slope"] = df["sma"].diff()

H = 3 # lookahead horizon
bins = np.linspace(df["slope"].min(), df["slope"].max(), 20)
df["slope_bin"] = pd.cut(df["slope"], bins=bins)

records = []
for h in range(1, H + 1):
df[f"slope_future_{h}"] = df["slope"].shift(-h)
grouped = df.groupby("slope_bin")[f"slope_future_{h}"].describe()
grouped["horizon"] = h
records.append(grouped)

fan = pd.concat(records)

๐Ÿ–ผ๏ธ Placeholder: Code Output Visualization Visual: heatmap showing slope_bin (y-axis) vs. horizon (x-axis) with color for mean or median future slope.


๐Ÿ“ˆ Distributional Interpretationโ€‹

Each horizon defines its own conditional slope distribution:

HorizonWhat It DescribesVisualization
+1Immediate slope reactionNarrow distribution; high autocorrelation
+2Short-term continuation/decayBroader fan; transitional dynamics
+3+Medium-term reversion or persistenceWidest spread; slope โ€œfanโ€ shape visible

This lets you ask:

  • How does slope persistence vary with slope magnitude?
  • Do extreme slopes tend to revert faster?
  • How asymmetric is the fan (e.g., more downside slope expansion than upside)?

๐Ÿ–ผ๏ธ Placeholder: Multi-Layer PDF Chart Visual: multiple probability curves fanning out with horizon.


๐Ÿงฎ Feature Outputsโ€‹

FeatureDescription
slope_fan_mean_h1Mean of slope distribution at +1 bar given current slope
slope_fan_std_h1Standard deviation at +1 bar
slope_fan_median_h3Median slope at +3 bars
slope_fan_skew_h2Skewness of slope distribution at +2 bars
slope_fan_decay_rateRate of slope mean reversion with horizon

These features describe the shape and decay of slope behavior through time.

๐Ÿ–ผ๏ธ Placeholder: Feature Heatmap Visual: table or heatmap of mean/variance/skew by slope bin and horizon.


๐Ÿ“Š Relation to Slope Persistenceโ€‹

  • Slope Persistence measures whether slopes tend to continue increasing in magnitude.
  • Slope Distribution Fan shows how the entire distribution shifts as a function of current slope.

Persistence is a binary or threshold-based view. The fan is a continuous, probabilistic one โ€” effectively a richer, distributional generalization.

๐Ÿ–ผ๏ธ Placeholder: Comparison Illustration Visual: slope persistence (single line) vs. slope fan (band of probabilities).


๐Ÿงฉ Integration With Conditional Studiesโ€‹

Slope Distribution Fans can themselves be computed under conditional contexts โ€” e.g., high ATR, specific trading sessions, or RSI zones. Each condition produces a different deformation of the fanโ€™s shape.

ModeDescription
GlobalP(st+hโˆฃst)P(s_{t+h} \mid s_t) across all data
ConditionalP(st+hโˆฃst,C)P(s_{t+h} \mid s_t, C) under condition C
ComparativeDifference or KL-divergence between conditional and global fans

๐Ÿ–ผ๏ธ Placeholder: Conditional Fan Comparison Visual: overlapping contour plots showing fan widening/narrowing by regime.


๐Ÿง  Notesโ€‹

  • The slope fan is not predictive in isolation โ€” itโ€™s descriptive of conditional dynamics.
  • When integrated into a feature pipeline, it can inform forecast uncertainty or expected directional persistence.
  • The fan can also be viewed as a distributional regression surface over slope magnitude ร— horizon.

Summary: The Slope Distribution Fan visualizes how slope values historically evolve after a given slope magnitude. It transforms slope behavior into a multi-horizon likelihood field โ€” a richer way of understanding trend momentum, decay, and variability.

๐Ÿ–ผ๏ธ Placeholder: Summary Visualization Visual: composite graphic showing slope bins, fan expansion, and persistence overlay.