Engineering

Why Our Bot Now Reads the Market's Body Language — and the Numbers Behind It

We built a 666-line candle engine with full TD Sequential integration into PolyEdge v3.0. Four days live, 97 closed trades, 91.3% win rate, and +$694.25 on $1,092 wagered. Here's what predictive signal layers do that reactive TA cannot.

February 27, 2026
9 min read
#trading-bots#technical-analysis#td-sequential
Why Our Bot Now Reads the Market's Body Language — and the Numbers Behind It
Share

Every technical indicator you've ever used tells you what already happened.

RSI at 72 means the asset has been overbought for some period of time. MACD crossover confirmed means the faster average already crossed the slower one. Bollinger Band compression already happened before the price broke out. These are all measurements of history, packaged to look like predictions.

The best traders don't fight this. They use reactive indicators correctly — as confirmation, as context, as regime filters. But the real edge is in the layer that comes before confirmation. The layer that reads the market's intent in real time, before the price move has printed.

That's what we built.


The Problem With Purely Reactive TA

PolyEdge — our Polymarket trading bot — has always run a TA engine. MACD, RSI, Bollinger Bands, volume analysis, momentum scoring. That engine is good. The InDecision Framework feeds multi-timeframe conviction data on top of it. Together they've been the analytical core for every trade the bot has placed.

But there was a gap in the architecture. The TA engine reads the aftermath of price action. It doesn't read the structure forming as it happens. Candlestick patterns and TD Sequential are different. They're reading the market's body language — the visible signature of what buyers and sellers are doing to each other right now, at the current bar.

A hammer forming at support doesn't tell you what's already happened. It tells you that sellers pushed price lower during the candle, buyers showed up and rejected those lows, and the close printed near the high. That's a live negotiation. The outcome isn't confirmed yet. But the weight of evidence is shifting, and a predictive system captures that shift before the next candle opens.

We built the candle engine to close this gap.


What We Built: candle_engine.py

The engine is 666 lines of pure Python. No external libraries for the pattern detection logic — just price data, array math, and ATR-normalized threshold calculations. It runs in parallel with the TA engine and pattern engine on every market evaluation cycle.

20 candlestick patterns across four tiers:

  • Single candle: hammer, inverted hammer, hanging man, shooting star, dragonfly doji, gravestone doji, doji
  • Two-candle: bullish engulfing, bearish engulfing, piercing line, dark cloud cover, tweezer top, tweezer bottom
  • Three-candle: morning star, evening star, three white soldiers, three black crows, three inside up, three inside down
  • Special: abandoned baby (with gap relaxation for 24/7 crypto markets that don't have daily open gaps)

The ATR-normalized thresholds are critical. BTC trades at $95,000. XRP trades at $2.50. A fixed ratio for body size, shadow length, or gap magnitude would make the engine blind to half its signals on one asset while firing false positives on the other. ATR normalization means the engine adapts to each asset's volatility regime automatically — the same mathematical rigor applies whether we're reading BTC or XRP.

Direction-relative scoring is how the engine contributes to the overall PolyEdge score. When a bullish pattern aligns with the current trade direction, it adds points. When a pattern opposes the trade direction, it subtracts. The contribution is clamped to a 0-15 range and then scaled into the scoring architecture. The engine cannot manufacture edge — it can only amplify what's already there or apply friction when the candle structure disagrees with the thesis.


TD Sequential: The Real Unlock

Candlestick patterns are sharp and fast. TD Sequential is different. It's an exhaustion measurement, not a momentum measurement.

Tom DeMark's buy setup works like this: count 9 consecutive bars where the close is strictly less than the close 4 bars ago. Not less-than-or-equal — strictly less than. Any bar that doesn't satisfy the condition resets the count to zero. When you get to 9, the setup is complete.

The logic it encodes is elegant. If for 9 consecutive bars, the market is consistently closing lower relative to where it was 4 bars back — sellers have been in control across every single one of those bars. At bar 9, exhaustion is the thesis. Sellers have been selling. Supply-side pressure is long in the tooth. The conditions for a reversal are not guaranteed, but they are structurally present.

INSIGHT

The perfected setup raises the bar further. A TD buy 9 is perfected when bar 8 or bar 9 prints a low at or below the lows of bars 6 and 7. That final push to a new low — after 8 bars of relentless selling — is historically DeMark's highest-probability reversal signal. The sellers took one last shot at lower prices and printed it. That's the exhaustion signature.

We also implemented buy countdown (a 13-bar non-consecutive count tracking close vs. the low 2 bars prior) and all sell-side equivalents. The engine detects setups, countdowns, and perfected signals independently, and the scoring contribution reflects signal quality: a TD buy 9/9 perfected with a confirming candlestick pattern like morning star or piercing line is a max-signal combination.

In production today, the engine logged 6,527 pattern detections in a single day. Some examples from the live detection log:

  • morning_star + TD buy 3/9 (score=5) — early setup in progress, doji confirmation building
  • piercing_line + tweezer_bottom + TD buy 9/9 perfected (score=10, max signal) — three separate confirming signals simultaneous, maximum contribution
  • bearish_engulfing + evening_star + TD buy 9/9 perfected (score=6) — opposing candle signals with a completed buy setup; friction applied to any bullish thesis
  • TD buy 9/9 perfected alone: 1,260 completions detected across all markets and timeframes

That last number matters. 1,260 perfected TD buy setups detected in a single trading day. The engine isn't sparse. It's reading every candle across every active market and building the count in real time.


How It Integrates Into PolyEdge v3.0

Before v3.0, the technical_analysis factor in the PolyEdge scoring system maxed out at 20 points, sourced entirely from the TA engine. The denominator calculation also had a bug that we fixed in this release.

After v3.0:

  • TA engine contributes 0-25 raw points, scaled to 0-20
  • Candle engine contributes 0-15 raw points, scaled to 0-10
  • Combined technical_analysis factor: 0-30 points

The candle engine adds 10 points of pure predictive signal capacity to a system that was already running hot. The distinction matters architecturally: the TA engine is reactive (it measures what happened), the candle engine is predictive (it reads structure forming in real time). These are complementary, not redundant. Stacking them correctly amplifies edge when both layers agree and applies natural friction when they conflict.


Four Days Live: The Data

These are real trades. Real USDC. On-chain settlement on Polygon.

Overall Win Rate
91.3%
84 wins · 8 losses · 97 closed trades · 4 days live
Total P&L
+$694.25
$1,092.12 wagered · +63.6% ROI
Candle Pattern Detections
6,527
Single day — all markets, all timeframes

By timeframe:

The 5m and 15m windows are where the bot lives. 92.0% win rate on 50 trades (5m) and 92.5% on 40 trades (15m). The 1h bucket has only 2 trades — not enough data to conclude anything. The hourly markets have fundamentally different liquidity dynamics and we're still calibrating.

By asset:

AssetWin RateTrades
BTC100.0%15
ETH94.4%18
XRP90.2%42
SOL84.2%22

XRP carries the most volume — 42 trades. The win rate holds. SOL is the softest at 84.2%, which deserves continued monitoring as the sample grows.

By conviction band:

Score BandWin RateTradesAvg Score
90+ (STRONG)91.1%8397.0
80-89 (MODERATE)92.3%1491.6

The MODERATE band is actually outperforming STRONG by 1.2 percentage points — small sample, but it tells you the scoring architecture is calibrated correctly. The system isn't over-filtering moderate conviction signals, and it isn't manufacturing false precision at the top.

The TA tier breakdown is the most operationally interesting number in the dataset:

TA Score RangeWin RateTrades
Below 1850.0%2
18-2396.2%52
24-3086.8%43
The 18-23 band is the sweet spot: 96.2% win rate on 52 trades.

This deserves some explanation. The highest TA scores (24-30) are underperforming the mid-range. The hypothesis: when the candle engine is contributing maximum points, it's often detecting a pattern at what may be a structural extreme — the very top of an exhaustion count. The signal is high-quality, but the market is more likely to be congested or contested near those levels. The mid-range represents cleaner directionality with solid confirmation, without the noise that comes at maximum signal saturation.

We'll watch this pattern. If it holds over the next 200 trades, it informs threshold tuning.


An Honest Read on the Before/After

I want to be careful here because the temptation is to point at the candle engine launch and draw a straight line to performance. That would be intellectually dishonest.

The engine went live at 09:32 AM today based on the first candle detection log. The 71 trades placed before that timestamp had a 92.4% win rate. The 26 trades placed after — with the candle engine contributing in real time — show 88.5%.

Before you read a regression into that, understand the sample: 26 trades. At the volatility of these markets, 26 trades is noise. Four losses in a row on 26 trades is a bad afternoon session, not a trend. The overall 4-day win rate of 91.3% on 97 trades is the number to track.

WARNING

The candle engine is additive, not replacing anything. The TA engine still runs. InDecision still runs. The candle engine adds a predictive layer on top of two already-working analytical systems. Attributing short-term session variance to a new component with 26 data points isn't analysis — it's confirmation bias hunting.

The real validation test is at 500 trades. That's when the signal separation between TA tiers, score bands, and asset classes will be statistically defensible. We're at 97. We're watching, not concluding.


What's Next

The candle engine is running. TD Sequential is counting in real time. The detection volume (6,527 patterns in a single day) confirms the engine is active and healthy across the full market set.

Near-term work:

  1. Expand the pattern confidence weighting — not all patterns are equal quality. A textbook morning star at a key support level is structurally stronger than the same pattern in the middle of a range. Incorporating relative position into the score contribution is the next architectural layer.

  2. TD Countdown tracking — the 13-bar countdown is implemented and detecting, but the score contribution for intermediate countdown bars (not just the completed 13) is still being tuned. A bar 9 countdown is meaningful signal on its own.

  3. Cross-timeframe TD confirmation — if the 5m chart completes a TD buy 9 and the 15m chart is on bar 6 of its own buy setup, that's structural alignment. The engine currently reads each timeframe independently. Cross-timeframe confirmation is a premium signal category.

The through-line of the entire system — InDecision Framework for conviction gap detection, PolyEdge for multi-factor scoring, now the candle engine for predictive structure — is the same architecture principle we've applied everywhere: don't just measure what already happened. Read what's forming.

The market prints its intent on every candle. 91.3% of the time, we've been right about what it means.

Explore the Invictus Labs Ecosystem

// Join the Network

Follow the Signal

If this was useful, follow along. Daily intelligence across AI, crypto, and strategy — before the mainstream catches on.

No spam. Unsubscribe anytime.

Share
// More SignalsAll Posts →