Fractal Signal — Research & Discussion
Discussion draft · 2026-06-06 · grounded in two adversarially-verified deep-research runs (foundational + post-ChatGPT/LLM frontier), English + Chinese sources. Verdicts marked ✓ verified / ✗ refuted / △ gap.
TL;DR
Your Pine script is a Bill Williams "bottom-fractal breakout" long entry — what Williams literally calls the "Third Wise Man." It's the same family as the Chinese 缠论 底分型 (Chanlun bottom fractal) reversal, but a weaker cousin: a real Chanlun buy (一类买点) also requires 背驰 / MACD-area divergence, which your signal omits. The evidence base is thin and cautionary — rigorous studies show chart-pattern reversal edges that vanish out-of-sample and get beaten by plain moving-average rules. The signal is entry-only (no exit) — and exits will drive results more than any entry tweak. It's very backtestable in rainier; the LLM-research angle is real but booby-trapped by data leakage. Net: worth testing, with eyes open.
1 · What the signal really does
It's a TradingView Pine v4 study — an indicator that paints signals, not a strategy that trades. It has no entries/exits/backtest of its own. Most input(...) toggles just show/hide things (Ichimoku, SMA/EMA lines, bar colors). The one actionable output is the fractalUpTrend marker (the white candle + ▽ triangle).
1.1 — The entry, decoded into plain English
A fractal is a 5-bar swing pivot. A down-fractal (swing low / "bottom") is a bar whose low is the lowest of 5, with two higher lows on each side:
high[3] ← UP-fractal (a swing HIGH / "top")
/ \
high[4] high[2]
/ \
high[5] high[1] ← mirror image = DOWN-fractal (swing LOW / "bottom")
time → [5] [4] [3] [2] [1] [0] (the pivot is confirmed 3 bars late — inherent to fractals)
The long fires when:
fractalUpTrend = fractalsDown # a BOTTOM fractal just confirmed (swing low formed) AND close > open[1] # price pushing up now AND close[1] > open[1] AND close[2] > open[2] # a run of bullish bodies AND |close[1]-open[1]| > |close[3]-open[3]| # bodies EXPANDING → momentum AND high > high[3] # breaks above the fractal bar's high (BREAKOUT) AND ema5[3] < ema11[3] # 3 bars ago still a DOWNtrend → catching the turn
In one line: buy the bottom reversal — a confirmed swing low + 2–3 expanding green bars + a breakout over the pivot high, emerging out of a prior downtrend. This is textbook Williams "Third Wise Man." ✓ verified against Williams' Trading Chaos + platform docs.
1.2 — Three things in the code worth knowing before you trust it
- It's entry-only. No stop, target, or exit anywhere. You cannot backtest it as-is — exits must be defined, and they'll dominate the P&L.
- The volume filter is mis-specified.
sma6Volume[2] > fractalVolumeChangecompares a raw volume count (e.g. 1,000,000) against a percentage (e.g. +80). It's almost always true → it does essentially nothing. The author intended a volume gate; the form is dimensionally broken. - The fractal S/R lines are dead code. The two
plot(fractalUp/fractalDown…)lines are commented out — so theteeth/security()machinery doesn't affect what you see. The "MACD" EMAs are also misnamed:ema(close,5)andema(close,11)— a 5/11 pair, not 12/26.
2 · The Williams lineage ✓ verified
Bill Williams introduced Fractals + the Alligator in Trading Chaos (1995) / New Trading Dimensions (1998) — the "混沌交易法" (Chaos trading) school. The Alligator is three SMMAs of the median price (H+L)/2, each shifted forward:
| Line | Definition (verified) | Role |
|---|---|---|
| Jaw (blue) | SMMA(median, 13) shift 8 | slow trend |
| Teeth (red) | SMMA(median, 8) shift 5 | fractal validity filter |
| Lips (green) | SMMA(median, 5) shift 3 | fast trend |
Williams' rule: a down-fractal is only a valid buy trigger when it sits below the Teeth (an up-fractal only above). Your script carries exactly one Alligator line — an 8-period SMMA = the Teeth — and approximates the "below Teeth" condition with its ema5[3] < ema11[3] downtrend check. So it's a faithful, if simplified, Williams setup.
✗ Minor corrections the verifier killed: claims that Lips uses shift-4 or shift-2 were refuted — it's shift-3.
3 · The Chinese connection — 缠论 (Chanlun) ✓ verified △ one nuance refuted
缠论 / 缠中说禅 (Chanlun) is the hugely popular Chinese TA system whose foundational building block is the fractal (分型). Its structural hierarchy is strictly bottom-up:
分型 (fractal) → 笔 (stroke) → 线段 (segment) → 中枢 (centre/hub) → 背驰 (divergence) 底分型 = bottom fractal 顶分型 = top fractal
A 底分型 is read as "a downtrend is about to reverse" — which is exactly your signal's premise. The original corpus is the 「缠中说禅:教你炒股票108课」 (108 lessons, original Sina blog 2006–2008), by the pen-named 缠中说禅 (real name 李彪 / Li Biao, d. 2008, respectfully "缠师").
The key, honest finding
Your signal matches the 底分型 pattern + reversal premise, but it is NOT a canonical Chanlun buy. A real first-class buy point (一类买点 / 一买) is divergence-confirmed: the departing down-move makes a new price low but with weaker force (smaller summed MACD bar-area = 背驰) than the prior move. Your script does a bare breakout with no divergence check — so it's a simpler, weaker cousin of true Chanlun reversal logic. (Chanlun even warns: a 底分型 alone is the weakest reversal signal — a necessary precondition, not a trade.) This is the single most actionable upgrade idea in this whole doc → add an MACD-area divergence filter as a tested variant.
✗ refuted: "the pasted signal is essentially a 底分型 reversal" (only half-true — see above); and "Chanlun fractals live on fixed timeframe levels (year/quarter/month…)" — Chanlun 级别 (levels) are recursive/self-similar, not a calendar ladder.
Open-source Chanlun engines you could borrow from: Vespa314/chan.py and waditu/czsc (both compute 分型/笔/中枢/背驰 + backtests).
4 · "Fractal" means three different things △ research gap — from domain knowledge
People conflate these constantly. Keep them straight:
| Sense | Who | What it is |
|---|---|---|
| Chart pattern | Bill Williams / Chanlun | A 5-bar (or 3-K) swing pivot. This is what your script uses. A trading signal. |
| Market geometry | Benoit Mandelbrot — The (Mis)Behavior of Markets (2004) | Prices are statistically self-similar across scales, fat-tailed, with long memory. A theory of risk, not a signal. |
| Fractal Market Hypothesis | Edgar Peters — Fractal Market Analysis (1994) | Markets are stable because investors act on many horizons; measured via the Hurst exponent (H>0.5 = trending/persistent). A market-structure model. |
The two deep-research runs did not surface verified Mandelbrot/Peters claims (a coverage gap), so this section is from established domain knowledge, flagged as such. The relevant connection for you: Hurst-style persistence could be a regime filter on the Williams signal (only take reversals when H suggests mean-reversion vs trend).
5 · Does it actually work? The honest evidence ✓ verified
There is no peer-reviewed backtest of Williams Fractals / Alligator specifically (win-rate / profit-factor / Sharpe) that survived verification. The nearest rigorous evidence is on technical analysis broadly and on chart-pattern reversals — and it's cautionary:
- Park & Irwin (2007, J. Economic Surveys) — of ~92–95 modern studies, ~58 positive / ~24 negative / ~10–19 mixed, but riddled with data-snooping, ex-post rule selection, and weak cost/risk accounting → nothing conclusive.
- Sullivan, Timmermann & White (1999, J. Finance) — tested 7,846 rules over ~100y of DJIA with White's Reality Check. In-sample the best (a short ~5-day MA) made ~17.2%/yr (p=0.000); out-of-sample (1987–96) the edge vanished (p=0.341 DJIA / 0.908 S&P futures). The canonical warning that in-sample-tuned rules die OOS.
- Chang & Osler (1999, Economic Journal) — head-and-shoulders (a discrete reversal entry, the nearest proxy to fractals) was profitable for only 2 of 6 currencies and was "easily dominated by simple moving-average and momentum rules."
What this means for us
A fractal+EMA reversal with several tunable filters is exactly the kind of rule that backtests well in-sample and fails out-of-sample. Any result we get must be validated walk-forward, out-of-sample, net of realistic costs, and benchmarked against a dumb baseline (plain MA cross / buy-and-hold). If it can't beat the baseline OOS, it's noise.
6 · The LLM / post-ChatGPT frontier (2023–2026) ✓ verified
You asked specifically for recent + LLM-driven work. The field is real and fast-moving — and mostly over-claimed.
The architectures (mature)
- Multi-agent "trading firm" is the dominant pattern — TradingAgents (arXiv 2412.20138, Dec 2024): 7 roles (analysts/researcher/trader/risk) + a bull/bear debate stage.
- FinMem (2311.13743, Nov 2023): memory + character cognition. QuantAgent-HFT (2509.09995, Sep 2025): Indicator/Pattern/Trend/Risk agents — its PatternAgent detects double-bottoms over structured price (relevant). P1GPT (2510.23032, Oct 2025): rule-based MACD/RSI/MA only — explicitly no fractals or Chanlun.
- Vision-LLMs reading charts: MM-DREX (2509.05080, Sep 2025) is a VLM router over candlestick images with a dedicated "reversal" expert — the closest thing to your use case. But raw chart literacy is weak: GPT-4V scored ~16th percentile of humans on a visualization-literacy test; the best candlestick-vision result (a Stanford course ViT) is inflated by ~80/10/10 class imbalance and isn't peer-reviewed.
⚠ The load-bearing warning: the "Profit Mirage"
"Profit Mirage" (arXiv 2510.07920, Oct 2025): LLM backtest returns collapse the moment the test window crosses the model's knowledge cutoff — because the model memorized past prices + post-hoc explanations rather than learning causal drivers. Reported decay: Sharpe −51–62%, returns −50–72% OOS. The headline "GPT-4 predicts returns ~90%" (Lopez-Lira & Tang, 2304.07619) is real but on the non-tradable immediate reaction; the tradable drift is modest. TradingAgents' AAPL Sharpe 8.21 / +26.6% over 5 months has zero transaction costs — a red flag, not an edge. Rule: any LLM-discovered fractal signal must be validated strictly post-cutoff, with costs, walk-forward — or it's a mirage.
Auto-research loops (the template you want)
- AlphaAgent (arXiv 2502.16789, KDD'25, peer-reviewed, code
RndmVariableQ/AlphaAgent): Idea Agent → Factor Agent → Eval/backtest Agent → feedback, iterating each round. The cleanest transferable pattern. - QuantAgent (2402.03755, Feb 2024): two-loop self-improver (inner: refine vs knowledge base; outer: validate in market).
- ElliottAgents (2506.16813, ICAART 2025): LLM + RAG + DRL over Elliott Wave — the closest published LLM system to swing/wave pattern analysis.
The genuine gap = your opportunity
No 2023+ peer-reviewed LLM work models Williams fractals or Chanlun (缠论/底分型) specifically. The nearest analogues are ElliottAgents (waves) and MM-DREX's reversal expert. So an LLM-driven fractal/Chanlun research loop is genuinely under-explored territory — interesting, but treat it as a leakage-resistant validation harness first, an "alpha engine" a distant second.
7 · Backtesting it in rainier proposal
This fits rainier's existing engine cleanly: a SignalEmitter feeds Signal(entry/SL/TP/confidence) → event-driven engine → BacktestMetrics, with a built-in --sweep.
- Implement
FractalSignalEmitter(insignals/) reproducingfractalUpTrend— and adding the missing exits (the script has none). - Fix/parametrize the broken volume filter; expose EMA fast/slow, fractal window, body-expansion factor, the Teeth filter, and exit rule as sweepable params.
- Data: needs OHLCV + volume → your
yfinance_provider/csv_provider(MES futures indata/csv, or the QU100 equity universe). - Sweep + walk-forward (mandated by CLAUDE.md), report win-rate / profit-factor / Sharpe / max-DD / expectancy, with realistic slippage + commission.
- Baselines + variants: compare vs buy-and-hold and a plain EMA cross; test a Chanlun-style 背驰 (MACD-area divergence) variant — the research says the bare breakout is the weak version.
| Param | In script | Sweep grid |
|---|---|---|
| Fast / slow EMA | 5 / 11 | (5,11)(8,21)(9,26)(12,26) |
| Fractal window | 5-bar | 5 vs 7-bar |
| Body-expansion × | >1.0 | 1.0–2.0 |
| Teeth filter | ~approx via EMA | off / true 8-SMMA "below Teeth" |
| Exit (MISSING) | — | ATR-mult SL/TP · fixed R:R 1:1.5/1:2/1:3 · time-stop N bars · exit-on-top-fractal · exit-on-EMA-cross |
| + Chanlun 背驰 | — | require MACD-area divergence (variant) |
Reminder from §5: exits will move the numbers more than any entry tweak. Start with ATR-stop + fixed R:R as the default.
8 · An LLM auto-research loop for this signal if you want to go there
Mirroring AlphaAgent/QuantAgent, but built leakage-first (this ties into your existing docs/PLAN-auto-research.md direction):
┌─ Idea agent ── propose a fractal-variant (filters, exits, divergence) ─┐ │ ▼ │ Code agent → FractalSignalEmitter variant │ │ │ ▼ │ Critic agent ◀── metrics ◀── Backtest (rainier engine, walk-forward, COSTS) │ │ "is this a mirage? OOS? costs? baseline-beating? overfit?" └────────┘ feeds the next idea
Non-negotiable guardrails (straight from the 2025 leakage literature)
- Validate strictly out-of-sample / post-model-cutoff — or returns are presumptively memorized.
- Always charge realistic costs + slippage — frictionless backtests overstate everything.
- Walk-forward, never a single in-sample window. Guard against data-snooping (the more variants the loop tries, the more a White's-Reality-Check-style correction matters).
- The LLM is best as a hypothesis generator + critic, not a chart-reader (vision-LLMs are at the 16th percentile) and not a return-predictor.
9 · Decisions for us
Q1 · Instrument & timeframe to test first
MES futures (your data/csv) or the QU100 equity universe? Which timeframe (1H / daily)?
Q2 · Default exit
I'd start with ATR-stop + fixed R:R. Agree, or do you have a preferred exit philosophy (Williams uses opposite-fractal / Alligator-mouth-close)?
Q3 · Test the Chanlun 背驰 variant?
The research's strongest upgrade idea: add MACD-area divergence confirmation as a variant alongside the bare breakout. Worth including in v1, or keep v1 minimal?
Q4 · Scope
Just the static backtest + sweep (clean, fast), or also stand up the LLM auto-research loop (§8) on top? The loop is the more ambitious, leakage-sensitive path.
References ✓ verified primary
From two adversarially-verified deep-research runs (2-of-3 refute to kill a claim). primary = arXiv/journal/platform docs; blogs corroborated against primaries.
Williams / Alligator / Chanlun
- Bill Williams, Trading Chaos (Wiley, 2nd ed. 2004) / New Trading Dimensions — fractals, Alligator, "Three Wise Men."
- Alligator + fractal spec corroborated vs MetaTrader 5 / TradingView / StockChartsChartSchool. tradeciety · roboforex · litefinance
- 缠中说禅, 《教你炒股票108课》 (original Sina blog 2006–2008). Engines: Vespa314/chan.py · waditu/czsc · chanlun-pro (买卖点/背驰 doc)
Empirical evidence
- Park & Irwin (2007), J. Economic Surveys — TA evidence survey. AgMAS PDF
- Sullivan, Timmermann & White (1999), J. Finance 54(5):1647–1691 — Reality Check, OOS collapse. DOI
- Chang & Osler (1999), Economic Journal — head-and-shoulders dominated by MA/momentum (summarized in Park & Irwin).
LLM / post-ChatGPT frontier
- Profit Mirage — LLM backtest leakage. arXiv 2510.07920 (Oct 2025)
- Lopez-Lira & Tang — LLM return forecasting (qualified). arXiv 2304.07619
- TradingAgents 2412.20138 · FinMem 2311.13743 · QuantAgent-HFT 2509.09995 · P1GPT 2510.23032
- MM-DREX (VLM reversal expert) 2509.05080 · GPT-4V viz literacy VIS'24
- AlphaAgent (KDD'25) 2502.16789, code RndmVariableQ/AlphaAgent · QuantAgent 2402.03755 · ElliottAgents 2506.16813 · survey 2408.06361
FractalSignalEmitter.