OPEN-SOURCE SCRIPT

[Top] LHAMA Consolidation Detector

417
Introducing the Low-High Adaptive Moving Average (LHAMA 🦙), a powerful tool designed to help traders visually distinguish between trending and consolidating market phases. Unlike traditional moving averages that can produce false signals in choppy markets, the LHAMA is engineered to flatten out during periods of consolidation and become more responsive when a clear trend emerges.

This indicator's primary function is to act as a "Consolidation Detector." When the LHAMA line goes flat and adopts its "Flat Color," it serves as a clear visual cue that the market is range-bound. Conversely, when the line begins to slope and changes to its Bullish or Bearish color, it signals a potential breakout or the start of a new trend.

How It Works
The LHAMA is a type of adaptive moving average. Its adaptiveness is derived from a unique calculation that measures market "trendiness." It does this by tracking whether new highs or new lows are being made within a specified lookback period.

In a Trending Market: When the price consistently makes new highs or lows, the indicator's responsiveness increases, causing the LHAMA to track the price much more closely and responsively.

In a Consolidating Market: When the price is range-bound and fails to make new highs or lows, the responsiveness decreases significantly. This causes the LHAMA to flatten out and become less sensitive to minor price fluctuations, effectively filtering out market noise.

Key Features
Adaptive Calculation: The core engine of the indicator, which automatically adjusts its smoothing based on trend strength.

Slope-Based Coloring: The line's color dynamically changes based on its slope, providing an at-a-glance view of market conditions: bullish, bearish, or flat.

Multi-Line & Multi-Timeframe (MTF): You can enable up to six fully customizable LHAMA lines. Each line can be configured with its own length, colors, and can even be set to a different timeframe, allowing for comprehensive multi-timeframe analysis on a single chart.

Volatility Clouds: Each LHAMA can display an optional cloud around it. The cloud's width is based on your choice of either the Average True Range (ATR) or Standard Deviation (StdDev), offering a visual representation of volatility.

Volume Weighting: An option to incorporate volume into the adaptive calculation, making the LHAMA even more responsive during high-volume price movements.

How to Use
Identify Consolidation: The primary use case. A flat and consistently colored LHAMA line is a strong indication of a sideways or consolidating market. This can help traders avoid taking trend-following trades in choppy conditions.

Confirm Trends: When the LHAMA begins to slope upwards or downwards and changes to its trend color, it can be used to confirm the direction and strength of a new trend. The steeper the slope, the stronger the momentum, and more solid the directional color.

Dynamic Support & Resistance: Like other moving averages, the LHAMA can act as a dynamic level of support in an uptrend or resistance in a downtrend. The optional cloud can further define these zones.

Multi-MA Ribbon Strategy: By enabling multiple LHAMAs with different lengths (e.g., Fibonacci sequence like 14, 21, 34, 55), you can create a ribbon. The expansion of the ribbon indicates a strong trend, while its contraction signals a weakening trend or consolidation.

Settings Explained
Enable 🦙 Line: A simple checkbox to turn each of the six LHAMA lines on or off.

Length: The lookback period for the LHAMA calculation. Shorter lengths are more responsive, while longer lengths are smoother.

Timeframe: Set a specific timeframe for each LHAMA. Leave blank to use the chart's current timeframe.

Volume Weight: If checked, adds volume weighting to make the LHAMA more responsive to high-volume moves.

Colors (Bullish, Bearish, Flat): Customize the colors for each market state. To only see the line during consolidation, set the Bullish and Bearish colors to 100% transparency. To hide the line during consolidation, set the Flat color to 100% transparency.

Color Sensitivity: This is a crucial setting. Because price scales (tick sizes) vary widely between symbols, this setting allows you to adjust the sensitivity of the slope detection. A lower value requires a steeper slope to trigger a trend color, while a higher value is more sensitive.

Recommended settings are provided in the input tooltip as a starting point:
  • $5 Tick: 0.25 Sensitivity
  • $1 Tick: 0.75 Sensitivity
  • $0.25 Tick: 3 Sensitivity
  • $0.01 Tick: 50 Sensitivity
  • $0.005 Tick: 100 Sensitivity


Cloud Settings:
  • Show Cloud: Toggles the visibility of the volatility cloud around the LHAMA.
  • Width Based On: Choose between "ATR" or "StdDev" to calculate the cloud's width.
  • Cloud Length & Width: Set the lookback period and multiplier for the ATR/StdDev calculation to control the size of the cloud.

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。