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

  1. 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.
  2. The volume filter is mis-specified. sma6Volume[2] > fractalVolumeChange compares 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.
  3. The fractal S/R lines are dead code. The two plot(fractalUp/fractalDown…) lines are commented out — so the teeth/security() machinery doesn't affect what you see. The "MACD" EMAs are also misnamed: ema(close,5) and ema(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:

LineDefinition (verified)Role
Jaw (blue)SMMA(median, 13) shift 8slow trend
Teeth (red)SMMA(median, 8) shift 5fractal validity filter
Lips (green)SMMA(median, 5) shift 3fast 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:

SenseWhoWhat it is
Chart patternBill Williams / ChanlunA 5-bar (or 3-K) swing pivot. This is what your script uses. A trading signal.
Market geometryBenoit 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 HypothesisEdgar 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:

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)

⚠ 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)

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.

  1. Implement FractalSignalEmitter (in signals/) reproducing fractalUpTrend — and adding the missing exits (the script has none).
  2. Fix/parametrize the broken volume filter; expose EMA fast/slow, fractal window, body-expansion factor, the Teeth filter, and exit rule as sweepable params.
  3. Data: needs OHLCV + volume → your yfinance_provider/csv_provider (MES futures in data/csv, or the QU100 equity universe).
  4. Sweep + walk-forward (mandated by CLAUDE.md), report win-rate / profit-factor / Sharpe / max-DD / expectancy, with realistic slippage + commission.
  5. 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.
ParamIn scriptSweep grid
Fast / slow EMA5 / 11(5,11)(8,21)(9,26)(12,26)
Fractal window5-bar5 vs 7-bar
Body-expansion ×>1.01.0–2.0
Teeth filter~approx via EMAoff / 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

Empirical evidence

LLM / post-ChatGPT frontier

Generated for discussion. Verified claims passed 2-of-3 adversarial refutation; gaps (Mandelbrot/Peters, Williams-specific backtests, Chinese-language Chanlun ML) are flagged inline and remain open for a deeper pass. Tell me which decisions in §9 to lock and I'll write the design doc + build the FractalSignalEmitter.