- The Composite Fractal Behavior index measures trend duration by analyzing fractal efficiency across 96 simultaneous lookback periods (2 to 192 bars...
The Composite Fractal Behavior index measures trend duration by analyzing fractal efficiency across 96 simultaneous lookback periods (2 to 192 bars by default). Rather than asking "how strong is the trend," CFB asks "how long has the market been moving efficiently." The answer: a single integer representing the dominant trending timeframe. Use CFB to dynamically tune other indicators: instead of RSI(14), use RSI(CFB).
## Historical Context
Mark Jurik operates in the shadow zone between academic signal processing and proprietary trading. His algorithms (JMA, RSX, CFB) emerged from treating financial time series as noisy signals requiring adaptive filtering rather than fixed-period analysis. CFB first appeared in his commercial software suite alongside JMA in the early 2000s.
The insight: markets exhibit fractal self-similarity. Trending behavior at one timeframe may not exist at another. A strong 50-bar trend might appear as noise on a 10-bar scale or as a minor blip on a 200-bar scale. CFB scans all scales simultaneously, identifying which timeframes show efficient (low-noise) trending.
Traditional indicators use fixed periods chosen by the trader. This creates a fundamental mismatch: a 14-period RSI works until market character changes, then fails. CFB eliminates this guesswork by continuously measuring which periods currently exhibit trending behavior.
The computational challenge was substantial. Naive implementation requires O(N × M) operations per bar where M is the number of scanned periods. QuanTAlib achieves O(N) per bar through running-sum optimization, maintaining 96 parallel accumulators with incremental updates.
## Architecture & Physics
CFB operates as a massive parallel analyzer: 96 fractal efficiency calculations run simultaneously, their results composited into a single trend-duration estimate.
### 1. Lookback Length Array
Default configuration scans 96 periods:
$$
L \in \{2, 4, 6, 8, \ldots, 190, 192\}
$$
Dense coverage ensures smooth transitions between dominant timeframes. Sparse arrays cause CFB to jump between distant values.
### 2. Fractal Efficiency Ratio
For each length $L$, calculate the efficiency of price movement:
The numerator is net displacement (straight-line distance). The denominator is total path length (sum of absolute bar-to-bar changes). Perfect efficiency ($R = 1$) means price moved in a straight line. Zero efficiency means price went nowhere despite movement.
### 3. Quality Threshold Filter
Not all timeframes contribute. Only periods showing quality trends count:
$$
w_L = \begin{cases}
R_L & \text{if } R_L \geq 0.25 \\
0 & \text{if } R_L < 0.25
\end{cases}
$$
The 0.25 threshold filters out choppy, mean-reverting behavior. This means at least 25% of price movement was directional.
### 4. Weighted Composite Calculation
Qualifying lengths contribute to the composite, weighted by their efficiency:
One addition, one subtraction, regardless of $L$. With 96 lengths, this reduces complexity from O(96 × 192) ≈ 18,432 operations to O(96 × 3) = 288 operations per bar.
### Transfer Function
CFB has no transfer function: it is not a filter but a measurement. The output depends on market state, not a fixed transformation of input.
### Warmup Analysis
Full warmup requires the longest lookback period plus one:
$$
\text{Warmup} = \max(L) + 1 = 193 \text{ bars}
$$
Before warmup completion, shorter timeframes produce valid readings; longer timeframes cannot contribute.
## Performance Profile
### Operation Count (Streaming Mode)
Per-bar update with 96 lengths:
| Operation | Count | Cost (cycles) | Subtotal |
| :-------- | ----: | ------------: | -------: |
| Volatility calculation | 1 | 3 | 3 |
| Running sum updates | 96 | 3 | 288 |
| Net move calculations | 96 | 5 | 480 |
| Division (ratio) | 96 | 15 | 1,440 |
| Comparison (threshold) | 96 | 1 | 96 |
| Weighted sum accumulation | ~48* | 3 | 144 |
| Final division + round | 2 | 20 | 40 |
| **Total** | **~435** | — | **~2,491 cycles** |
*Assuming ~50% of timeframes qualify on average.
Division dominates (58%). The 96 parallel ratio calculations create the bulk of the work.
Validation approach: verify batch mode matches streaming mode bar-by-bar. Cross-reference with Jurik's published methodology.
## Common Pitfalls
1.**Directional Blindness**: CFB measures trend duration, not direction. A CFB of 80 during a crash means the same as CFB of 80 during a rally: the market has been trending efficiently for ~80 bars. Combine with directional indicators for complete picture.
2.**Modulator Misuse**: CFB produces period estimates for other indicators. Using `RSI(CFB)` adapts RSI to current market state. Using CFB as a buy/sell signal directly rarely works: it tells you market state, not action.
3.**Warmup Requirement**: Full warmup requires 193 bars (for default 192-length maximum). Earlier bars produce partial readings using only shorter timeframes. IsHot becomes true only when the longest lookback is filled.
4.**Jump Behavior**: When dominant timeframe shifts, CFB can jump significantly (e.g., from 120 to 40). This is correct behavior: the market's trending scale changed. Smooth CFB output if jumps cause problems.
5.**Decay Interpretation**: Rapid decay toward 1 indicates trend breakdown: no timeframe shows quality trending. This is valuable information, not a signal failure.
6.**Memory Cost**: Each CFB instance consumes ~5 KB. Running hundreds of CFB instances (e.g., scanning multiple symbols) requires attention to memory budget.
7.**Computational Cost**: At ~2,500 cycles per bar, CFB is 35× slower than EMA. Acceptable for most use cases but consider caching or reducing scan density for ultra-low-latency applications.