OPEN-SOURCE SCRIPT
Aggiornato

MFE (Market Fractal Entropy)

959
The Market Fractal Entropy (MFE) is a groundbreaking indicator that fully integrates traditional chart analysis with information theory.

Unlike conventional oscillators that merely rely on price smoothing or momentum to measure "overbought" or "oversold" conditions, this script takes a strictly mathematical approach to the market's geometric structure. By quantifying elements such as trendline slopes, distances from trendlines, retracements, and extensions as "information content," you can think of it as a multi-faceted chart analysis compressed into a single oscillator.

▶How to Trade with MFE

Theoretically, a positive MFE value represents the probability (or information content) of a High being formed (i.e., the probability that the current candle's high becomes a Pivot High, PH). Conversely, a negative value represents the probability of a Low being formed (the probability of the current candle's low becoming a Pivot Low, PL).

Therefore, an explosive surge (spike) from the zero-line towards the extreme bands (+90 / -90) strongly suggests that a High or Low is highly likely forming at that exact moment. During a trend, you will often see spikes stopping exactly at the zero line; this indicates an excellent entry opportunity on a retracement.

▶Integrating Traditional Chart Analysis and Information Theory

Traditional chart analysis utilizes tools like trendlines, retracements, and extensions to understand the geometric structure of the market. However, interpreting these tools often relies heavily on the subjective judgment of the trader.

On the other hand, in Claude Shannon's Information Theory, "Self-Information" (or Surprise) mathematically quantifies the amount of information associated with an event. The lower the probability of an event occurring, the higher its surprise or information content.

This script elegantly integrates these two distinct fields. It models the geometric features of past Pivot Highs (PH) and Pivot Lows (PL)—such as the slope of the trend, the depth of the retracement, and the length of the extension—as a probability distribution. It then evaluates the currently forming wave against this historical distribution to calculate its "surprise" (information content). In essence, it objectively and mathematically scores how "rare" or "common" the current geometric structure is, providing a data-driven approach to classical chart patterns.

▶Theoretical & Philosophical Background: Market Geometric Information Theory (MGIT)

I have always believed that the market possesses an orderly geometric structure (such as trendlines, horizontal levels, and chart patterns) and a temporal rhythm in which these structures periodically complete themselves. I hypothesized that market dynamism could be understood as a geometric order within the two-dimensional spacetime of price and time. Furthermore, I believe this order can be quantified by treating it as entropy (information content) within a complex system.

I call this the Market Geometric Information Theory (MGIT). MGIT views financial markets not as simple time-series data, but as a continuous generation and dissipation of wave structures within a multi-dimensional "geometric feature space."

▶The philosophy of MGIT is built upon two core concepts:

Structural Memory: The market is not an amnesiac system. It retains an invisible "probability distribution" of past wave structures, trend angles, and geometric ratios. The market constantly learns from its own history.

Geometric Attractors: In complex systems theory, dynamic systems eventually settle into stable states called Attractors. In financial markets, crowd psychology naturally gravitates toward specific, harmonious wave proportions (like Fibonacci ratios). We define these universally preferred proportions as "Geometric Attractors."

▶What is Market Entropy?

Based on MGIT, the "Market Entropy" in this script is the quantification of the information content (surprise) generated when a PH (Pivot High) or PL (Pivot Low) is formed at the current candle.

It calculates how much the currently forming provisional pivot deviates from the market's "structural memory" (the historical probability distribution). If the calculated surprise is small, it evaluates that the probability of a PH or PL forming is high. Conversely, if the surprise is large, the probability of a PH or PL forming is evaluated as low.

▶The Breakthrough: The Reversal Mechanism

The ultimate edge of this indicator lies in its ability to pinpoint market tops and bottoms through the lens of structural mechanics, rather than simple momentum decay.

In this indicator, entropy is decomposed into a directional metric consisting of positive entropy and negative entropy. When MFE is close to the positive extreme (+100), the market is evaluated as forming a PH. When MFE is close to the negative extreme (-100), the market is evaluated as forming a PL.

▶Key Features of this Script

Four-Quadrant Regime Modeling & Probability Distributions:
The market state is dynamically categorized into four quadrants (Uptrend, Downtrend, Expansion, Contraction) using a Markov-like state model. The geometric features (slopes, retracements) of past PH/PL formations are accumulated as a "probability distribution" for each state. The script then calculates the self-information (surprise) of the current provisional PH or PL by evaluating how "rare" or "unlikely" it is against this historical probability distribution.

Minimum Information Principle:
Evaluates multiple provisional pivot formations and adopts the one with the lowest absolute entropy (least surprise = most likely outcome).

Kalman Filter Option:
Includes a customizable Kalman Filter (Process Noise $Q$ & Measurement Noise $R$) to intelligently smooth out erratic spikes and isolate the true entropy trend.

Dynamic UI & Scaling:
The entropy line dynamically changes color based on the zero-line cross. Since information content is inherently unstable and can easily diverge into massive numbers, it uses Tukey Fences and Tanh soft-clipping to maintain an elegant $-100$ to $+100$ bounded oscillator, greatly improving readability and interpretability.
Note di rilascio
Updated initial settings.
Note di rilascio
New Feature: Kalman Filter for Feature Distribution Estimation

In this update, we have expanded the Kalman Filter capabilities to the estimation of the feature distributions themselves. Instead of relying solely on the simple median of historical features, users can now enable the Kalman Filter to dynamically estimate the expected value of feature distributions based on their sequential progression.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.