OPEN-SOURCE SCRIPT
Обновлено

MA - ALMA 34/50/144/233 [BySel]

105
OPTIMIZATION OF THE GAUSSIAN FILTER IN FIBONACCI REGRESSION SPACE
I present the methodological construction of an indicator system based on the Arnaud Legoux Moving Average (ALMA) using Fibonacci period parameters (34, 50, 144, 233). This is not merely the selection of random numbers, but rather a synthesis between Digital Signal Processing (DSP) theory and Fractal Market Geometry. We will dissect the mathematical structure of the Gaussian filter and explain why applying it across Fibonacci timeframes creates such an effective market measurement reference framework.

Here, we must conduct a deep analysis of two metaphysical hyperparameters: Offset and Sigma ($\sigma$). In the source code under discussion, alma_offset = 0.85 and alma_sigma = 6. These are revolutionary values. In traditional statistics, the peak of the normal distribution lies at the center (offset = 0.5), which produces lag equivalent to an SMA. By shifting the peak of the weighting function to the right (Offset = 0.85), we are performing an intentional “phase shift,” assigning the greatest weight to the most recent data while not entirely eliminating the influence of past data as in the crude approach of relying solely on closing prices. Mathematically, the value 0.85 approaches the Nyquist limit to ensure responsiveness without causing overshoot—that is, without being disrupted by instantaneous random fluctuations. The Sigma parameter = 6 serves to control the bandwidth width of the filter. A large Sigma makes the weighting curve narrower, concentrating energy at the Offset point, transforming ALMA into an extremely sharp low-pass filter that eliminates most high-frequency noise which conventional moving averages fail to suppress.

Notably, the use of Fibonacci numbers as the filtering window length ($L$) creates the potential for wave resonance. The 144 period is not only four times the 34 period arithmetically, but within Elliott wave structure it represents the dominance of a higher-degree wave over a lower-degree wave. ALMA 144 and ALMA 233 function as fractal “shorelines,” where price returns to rebalance before continuing the trend. Thanks to ALMA’s low-lag characteristic, these dynamic support lines are far more precise than the traditional SMA 200 or EMA 200, as they accurately reflect the current center of mass of capital flow rather than the arithmetic average of distant historical data.

Below is the concise Technical Guideline for traders and quantitative analysts when applying the ALMA Fibonacci system (34/50/144/233) in the stock market.

GUIDELINE FOR USING THE ALMA FIBONACCI SYSTEM (34/50/144/233)

Core Principle: The system employs a Gaussian filter (ALMA) to minimize lag, combined with Fibonacci numerical periods to identify the market’s energy layers.

1. Component Identification (Vector Roles)

ALMA 34 (Blue – Fast Signal): Represents Short-term Momentum. Used to trigger entries and monitor immediate thrust.

ALMA 50 (Red – Baseline): Represents Medium-term Flow. This is the first dynamic support zone during pullbacks.

ALMA 144 (Teal – Trend Line): Represents Trend Structure. It delineates the boundary between Bull and Bear markets.

ALMA 233 (Brownish-red – Boundary Line): Represents Major Support/Resistance. This is the “hard floor” or “hard ceiling” of the long-term trend.

2. Trading Strategy (Setup)

A. Laminar Flow State (Strong Trend):

Identification: The lines are perfectly ordered: Price > 34 > 50 > 144 > 233 (for an uptrend) and expand evenly like a fan.

Action: Only look for LONG (Buy) positions.

Entry: When price pulls back to ALMA 34 or at deepest to ALMA 50, followed by a bullish confirmation candle.

Do not short in this structure.

B. Singular Attraction State (Mean Reversion – Bottom/Top Catching):

Identification: Price moves too far away from the ALMA bundle (the distance between Price and ALMA 34 becomes excessive).

Action: Take partial profits. Wait for price to be drawn back toward a reasonable equilibrium zone between ALMA 50 and ALMA 144.

Reversal attempt: Only consider when price touches ALMA 144 or 233 and that ALMA line still maintains an upward slope.

C. Turbulent Flow State (Sideways Market):

Identification: The four ALMA lines intertwine, flatten out, and the distance between them is very narrow.

Action: STAY OUT (NO TRADE). This is a high-noise zone; the Gaussian filter suppresses false signals but does not create directional edge.

3. Risk Management Rules

Stop Loss:

Place just below ALMA 144 for short-term trades (Swing trade).

Place just below ALMA 233 for position trades.

Note: If a candle closes decisively below ALMA 233, the market structure has broken (Structural Break), and the position must be exited.

Exit:

Early exit: When price closes below ALMA 34 (momentum loss).

Standard exit: When ALMA 34 crosses below ALMA 50 (confirmed capital flow reversal).

4. Important Notes (Scientific Note)

Lag: This ALMA system has significantly lower lag compared to equivalent SMA/EMA. Therefore, crossover signals here are more reliable and less prone to whipsaw.

Fractal Property: It can be applied on all timeframes (H1, H4, D1). However, the highest accuracy is on the D1 (Daily) timeframe for the stock market, as it filters out intraday noise.
Информация о релизе
To allow users to customize these parameters in the Settings panel, we need to replace the fixed (hardcoded) numbers with the input.int() function.

Below is the upgraded Pine Script. I have also added grouping so that the settings interface appears cleaner and more professional.

Explanation of the changes:

input.int(...): This is the most important function. It creates an input field in the settings panel.

For example: input.int(34, ...) means the default value is 34, but you can modify it to 89, 200, etc.

group="...": I grouped the Period settings into one section and the technical settings (Offset/Sigma) into a separate section. This helps keep the Settings panel organized.

minval=1: Sets the minimum limit to 1 to prevent errors if the user accidentally enters a negative number or zero.

Flexible Offset/Sigma: I also converted alma_offset and alma_sigma into input parameters. If the market is highly volatile (Crypto, Forex), you can reduce Sigma to 4 or 5 to make the indicator more responsive without modifying the code.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.