D-Limit: Built for the Bounce

D-Limit: Built for the Bounce

So this should have been the first post. I got a little excited with Module 4 — the Zone Manager was producing support and resistance lines that I would actually draw myself, and I had to write about it while it was fresh in my head. If you haven't read that one yet, check it out here.

But now let me rewind and give you the full story of D-Limit and where it all started.

Lagging Indicators are the problem!

D-Limit came from frustration. I'd exhausted every lagging indicator I could find — SMA, EMA, ADX, you name it. The real issue? Slow, laggy response times. The market had already turned, but my MACD strategy was still trading the old data.

What I needed was a fast-acting, forward-looking technical indicator.

So that became the brief: figure out how to predict the future — or at least make a well-educated guess.

The Core Idea

The core premise of D-Limit is built on Higher Highs (HH) and Lower Lows (LL) — fundamental market structure. As price rises and pulls back, a new Higher High is marked. When price bottoms out and rebounds, a Lower Low is logged. We also track Higher Lows and Lower Highs in much the same way. These swing points are the foundation of how D-Limit works.

A Modular Design

The design principle was simple: keep things modular. I knew early on that this codebase was going to grow — and when things get big, tracking down issues becomes a real challenge. The D-Limit codebase now sits at 29,600 lines of code!

So that instinct paid off.

Each module in Python is responsible for a specific dataset. I'd complete a module, test it thoroughly, then move it into code freeze before starting the next.

Downstream modules depend on upstream data sources — they never create their own.

This unidirectional flow was a deliberate architectural decision. It prevents circular dependencies, makes each module independently testable, and creates a clean pyramid where everything feeds from validated upstream data.

What Else Does D-Limit Do?

D-Limit feeds raw OHLC data through a structured pipeline of independent modules. The timeframe is configurable — I currently run it on both 15-minute and 60-minute OHLC data, which provides a good balance between responsiveness and noise reduction.

Each module is responsible for one specific layer of market structure:

  • Strength Accumulator — detects directional momentum with minimal lag
  • Swing Detector — labels structural highs and lows in real time
  • Zone Manager — clusters swings into dynamic support and resistance
  • Magnetic Strength Calculator — scores the reliability of each zone
  • Slope Calculator — measures trend angle per candle, not per hour
  • Trend Classifier — combines signals into a clear market state
  • Trend End Predictor — estimates the probability of exhaustion

Each module does one job. Data flows in one direction. There are no circular dependencies, no hidden cross-queries.

The output isn't just a signal — it's structured market context.

A Strategy Change

Originally, the goal was to improve a MACD-based strategy. Sideways markets were killing performance, so Module 7 "the Trend Classifier" was built to identify consolidation quickly and shut down trend entries.

But once D-Limit was running on historical data, something became obvious.

The zones it produced were exceptionally clean.

Support and resistance levels weren’t vague areas, they were structured clusters with strength scores, bounce reliability, directional context, and regime awareness.

At that point, it stopped being about filtering MACD and it became clear that the structural data itself was tradable.

Instead of forcing a lagging indicator to behave better (Sorry MACD), the better idea was to trade what D-Limit was already modelling: high-confidence bounces off statistically validated zones.

So a new strategy was called for.

Zone Bounce

Tube Map - D-Limit

All aboard — So I turned D-Limit V3 into a tube ride.

Each station is a module. Each coloured line is a data path.

OHLC candles hop on at the far left and travel through momentum, swings, slope, zones, magnetics & consolidation logic before pulling into the Orchestrator on the right.

This map isn’t about code structure.

It’s about flow.
How information moves.
And how D-Limit builds its technical analysis.

OHLC Source Raw price data M2: Strength Momentum counter M3: Swing Detector HH · HL · LH · LL M4: Zone Manager Support & resistance M5: Mag Strength Zone score 0–100 M8: Trend End Confidence 0–100 M9: Orchestrator DLimitResult M10: Storage PostgreSQL M6: Slope Trend angle M7: Trend Class Market state M8a: VCR Volume compression M8b: Consolidation Squeeze detection M8c: Breakout Direction bias M8d: Exhaustion Momentum loss M8e: Extended Pullback risk Swing data Zone data D-LIMIT V3 UNIDIRECTIONAL DATA FLOW → Key Swing Line Swing detection → slope analysis Zone Line Zone management → strength scoring Consolidation Line Volume & squeeze analysis Cross-Feed Data sharing between branches Interchange Multiple data paths merge Station Single processing module © D-Limit V3 Pipeline Architecture
Pinch or Ctrl/Cmd + scroll to zoom further

All Stops

M1 — Config
Global settings and parameters for the indicator
M2 — Strength Accumulator
Real-time directional momentum counter
M3 — Smart Swing Detector
Creates HH/HL/LH/LL swing points from price action
M4 — Zone Manager
Creates and tracks S/R zones with magnetic strength
M5 — Magnetic Strength
Scores zone importance from bounce, break & volume history
M6 — Slope Calculator
Measures trend angles between swing points
M7 — Trend Classifier
Identifies market state: trending, consolidating, or neutral
M8 — Trend End Predictor
Detects trend exhaustion before reversals
M9 — Orchestrator
Coordinates the full pipeline — one candle in, full analysis out
M10 — Storage
PostgreSQL persistence for all module outputs

Module 1: Config — The Foundation

Everything starts here. The Config module holds every tunable parameter across D-Limit — swing detection thresholds, zone tolerance percentages, strength calculations, trend classification boundaries. Every downstream module reads from this single source of truth. No magic numbers scattered through the codebase; if you want to tune the system, this is where you go.

Output: A configuration object shared with all modules.

Module 2: Strength Accumulator — Counting Momentum

When a new candle arrives, the Strength Accumulator starts counting. Three up candles in a row? That's a strength of 3 in the up direction. Price reverses? The counter resets immediately and starts counting the other way. No smoothing, no averaging — just a raw, real-time count of consecutive directional candles.

This is the first departure from lagging indicators. There's no lookback window dragging the signal behind price.

Input: Raw OHLC candle data.

Output: Current direction (up/down/flat), running strength count, and a reversal flag.

Module 3: Smart Swing Detector — Finding the Turning Points

This is where the market structure takes shape. Using the strength data from Module 2, the Smart Swing Detector watches for reversals. When price has been climbing and then turns, it marks that peak as a swing point — a Higher High, Lower High, Higher Low, or Lower Low depending on where it sits relative to previous swings.

Every swing gets created here. No filtering, no judgement calls — that comes later. The principle is: capture everything, let downstream modules decide what matters.

Input: Strength Accumulator output + raw candle data.

Output: Swing points (HH, HL, LH, LL) with price, timestamp, strength, and zone interaction metadata.

Module 4: Zone Manager — Building the S/R Map

This is the module that got me excited enough to write about it first. The Zone Manager takes those swing points and clusters them. When 3 or more swings land within 0.5% of each other, a support/resistance zone is created.

But creation is just the beginning. Every time price revisits a zone, the Zone Manager tracks whether it bounced or broke through. Zones that hold up get stronger. Zones that price ignores fade away. The result is a living map of where price actually reacts — not where you think it should.

Zones don't have fixed "support" or "resistance" labels either. A zone at $95,000 is resistance when you're below it and support when you're above it. The market tells you the role; the system just calculates it.

Input: Swing points from Module 3 + Magnetic Strength calculations.

Output: Active S/R zones with price levels, strength scores, bounce/break history, and tolerance bands. [Read the full Module 4 deep dive →]

Module 5: Magnetic Strength — Scoring Zone Importance

How do you know which zones matter? That's the magnetic strength calculation. The formula combines three factors:

  • Base strength — how many times price has tested the zone
  • Reliability — the ratio of bounces to breaks (a zone that holds 9 out of 10 times scores higher than one that breaks regularly)
  • Volume — higher volume at zone interactions means more market participants respect that level

There's no cap on strength. Zones can keep building indefinitely as long as the market keeps respecting them. This gives you a clear ranking: the strongest zones are the ones the market cares about most.

Input: Zone test/bounce/break history from Module 4.

Output: Magnetic strength score for each zone.

Module 6: Slope Calculator — Measuring Trend Angles

The Slope Calculator looks at the last two swing points of the same type and measures the angle between them. A steep angle means price is moving fast. A shallow angle means the trend is losing steam.

This is calculated per-candle for fast reaction times. The output is a simple but powerful metric: is the current move steep (>45 degrees), moderate (>20 degrees), shallow, or flat?

Input: Swing points from Module 3.

Output: Trend angle, direction, and steepness classification.

Module 7: Trend Classifier — Reading the Market State

This is where D-Limit answers the question every trader asks: "What's the market doing right now?"

Module 7 takes the slope data, zone interaction history, and swing strength to classify the market into one of three states:

  • Trending — strong directional movement with high breakout rates
  • Consolidating — price trapped between zones, high capture rate, weak swings
  • Neutral — mixed signals, no clear state

Identifying consolidation was the original goal here. The MACD strategy was getting destroyed in sideways markets, entering trades that went nowhere. Module 7 gives you a clear signal: "The market is ranging — stay out."

Input: Slope data from Module 6 + zone interaction rates from Module 4 + swing strength.

Output: Market state classification with confidence score, capture/breakout rates.

Module 8: Trend End Predictor — Spotting Exhaustion

This is where D-Limit tries to see around corners. The Trend End Predictor scores the probability that the current trend is about to end, using four weighted factors:

  • Distance to nearest opposing zone (40%) — if price is approaching a strong resistance zone during an uptrend, exhaustion is more likely
  • Weakening swing strength (30%) — are recent swings getting weaker compared to earlier ones?
  • Trend duration (20%) — older trends are more likely to end
  • Volume decline (10%) — decreasing volume suggests fading interest

A score above 80 out of 100 flags high probability of trend exhaustion. This is Deliverable 2 from the original D-Limit specification — and it's the kind of forward-looking signal that lagging indicators simply can't provide.

Input: Swing results + zone proximity + volume data.

Output: 0-100 exhaustion score with confidence level and component breakdown.

Module 9: Orchestrator — Running the Pipeline

The Orchestrator is the conductor. It takes a raw candle and runs it through every module in sequence — swing detection, zone management, slope calculation, trend classification, and exhaustion prediction. One candle in, one complete market analysis out.

This is the main entry point for using D-Limit. Feed it candles, get back a comprehensive result object containing everything the system knows about the current market state.

Input: Raw OHLCV candle.

Output: Complete DLimitResult — swings, zones, slopes, market state, exhaustion predictions, and consolidation signals.

Module 10: Storage — Persisting Everything

Every result gets written to PostgreSQL. Per-candle indicator data, zone definitions, zone touch history — it all goes into the database. This makes the data queryable for backtesting, available for ML feature engineering, and visible in Grafana dashboards for visual validation.

Input: DLimitResult from the Orchestrator.

Output: Persistent storage across three database tables — ready for analysis, backtesting, and downstream strategies.

spirit-assistant