A sophisticated trend duration index that measures the "fractal efficiency" of price movements across multiple time scales. It answers the question: "How long has the market been trending efficiently?"
Composite Fractal Behavior (CFB) analyzes the market's geometry to determine the quality and persistence of a trend. Unlike standard indicators that rely on a single fixed period (e.g., RSI-14), CFB scans a wide spectrum of lookback lengths (e.g., from 2 to 192 bars) simultaneously.
It calculates the "fractal efficiency"—how straight the price path is—for each length. It then combines the lengths that show efficient trending behavior into a single composite index. The result is a value representing the approximate duration (in bars) of the current trend.
Developed by Mark Jurik of Jurik Research, CFB addresses the "lag vs. noise" dilemma by avoiding it entirely. Instead of smoothing price data (which adds lag), it measures the structural integrity of the price action itself. It was designed to be an adaptive input for other indicators, allowing them to adjust their speed based on whether the market is trending or chopping.
CFB is primarily a "state" indicator rather than a directional one.
### 1. Trend Duration
The output value roughly corresponds to the number of bars the current trend has been valid.
- **High Values**: Strong, persistent trend.
- **Low Values**: Choppy, sideways market.
### 2. Trend Strength
- **Rising CFB**: The trend is becoming more efficient or extending in duration.
- **Falling CFB**: The trend is breaking down; volatility is increasing relative to net movement.
### 3. Adaptive Input
CFB is ideal for driving the parameters of other indicators. For example, you can use CFB to dynamically adjust the period of a Moving Average:
- **High CFB** $\rightarrow$ Use a longer period (capture the trend).
- **Low CFB** $\rightarrow$ Use a shorter period (react to chop).
## Architecture Notes
- **Running Sums**: The class maintains an array of running sums for volatility. When a new bar arrives, it adds the new volatility and subtracts the volatility from $L$ bars ago. This keeps the efficiency calculation fast.
- **State Management**: The `Update` method handles `isNew` logic carefully to ensure running sums are rolled back correctly during intra-bar updates.
- **Default Lengths**: If no lengths are provided, the constructor generates a dense array `[2, 4, 6, ..., 192]`.