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.

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.
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 buildingpiercing_line + tweezer_bottom + TD buy 9/9 perfected (score=10, max signal)— three separate confirming signals simultaneous, maximum contributionbearish_engulfing + evening_star + TD buy 9/9 perfected (score=6)— opposing candle signals with a completed buy setup; friction applied to any bullish thesisTD buy 9/9 perfectedalone: 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_analysisfactor: 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.
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:
| Asset | Win Rate | Trades |
|---|---|---|
| BTC | 100.0% | 15 |
| ETH | 94.4% | 18 |
| XRP | 90.2% | 42 |
| SOL | 84.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 Band | Win Rate | Trades | Avg Score |
|---|---|---|---|
| 90+ (STRONG) | 91.1% | 83 | 97.0 |
| 80-89 (MODERATE) | 92.3% | 14 | 91.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 Range | Win Rate | Trades |
|---|---|---|
| Below 18 | 50.0% | 2 |
| 18-23 | 96.2% | 52 |
| 24-30 | 86.8% | 43 |
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.
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:
-
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.
-
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.
-
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
Follow the Signal
If this was useful, follow along. Daily intelligence across AI, crypto, and strategy — before the mainstream catches on.

Foresight v5.0: How I Rebuilt a Prediction Market Bot Around Candle Boundaries
The bot was right. The timing was wrong. v4.x had a fundamental reactive architecture problem — by the time signals scored, the CLOB asks were too expensive. v5.0 solved it with event-driven candle boundaries and predictive early-window scoring.

Hermes: A Political Oracle That Bets on Polymarket Using AI News Intelligence
Political prediction markets don't move on charts — they move on information. Hermes is a Python bot that scores political markets using Grok sentiment, Perplexity probability estimation, and calibration consensus from Metaculus and Manifold. Here's how it works.

Leverage: Porting the Foresight Signal Stack to Crypto Perpetuals
The signal stack I built for prediction markets turns out to work on perpetual futures — with modifications. Here's how a 9-factor scoring engine, conviction-scaled leverage, and six independent risk gates become a perps trading system.