OPEN-SOURCE SCRIPT
Cập nhật

Adaptive HMA Signals

66
Adaptive HMA Signals

This indicator pairs nicely with the Contrarian 100 MA and can be located here:
Contrarian 100 MA


Overview
The "Adaptive HMA Signals" indicator is a sophisticated technical analysis tool designed for traders aiming to capture trend changes with precision. By leveraging Hull Moving Averages (HMAs) that adapt dynamically to market conditions (volatility or volume), this indicator generates actionable buy and sell signals based on price interactions with adaptive HMAs and slope analysis. Optimized for daily charts, it is highly customizable and suitable for trading forex, stocks, cryptocurrencies, or other assets. The indicator is ideal for swing traders and trend followers seeking to time entries and exits effectively.

How It Works
The indicator uses two adaptive HMAs—a primary HMA and a minor HMA—whose periods adjust dynamically based on user-selected market conditions (volatility via ATR or volume via RSI). It calculates the slope of the primary HMA to identify trend strength and generates exit signals when the price crosses the minor HMA under specific slope conditions. Signals are plotted as circles above or below the price, with inverted colors (white for buy, blue for sell) to enhance visibility on any chart background.

Key Components
Adaptive HMAs: Two HMAs (primary and minor) with dynamic periods that adjust based on volatility (ATR-based) or volume (RSI-based) conditions. Periods range between user-defined minimum and maximum values, adapting by a fixed percentage (3.141%).
Slope Analysis: Calculates the slope of the primary HMA over a 34-bar period to gauge trend direction and strength, normalized using market range data.
Signal Logic: Generates buy signals (white circles) when the price falls below the minor HMA with a flat or declining slope (indicating a potential trend reversal) and sell signals (blue circles) when the price rises above the minor HMA with a flat or rising slope.
Signal Visualization: Plots signals at an offset based on ATR for clarity, using semi-transparent colors to avoid chart clutter.

Mathematical Concepts

Dynamic Period Adjustment:
Primary HMA period adjusts between minLength (default: 144) and maxLength (default: 200).
Minor HMA period adjusts between minorMin (default: 55) and minorMax (default: 89).
Periods decrease by 3.141% under high volatility/volume and increase otherwise.

HMA Calculation:
Uses the Hull Moving Average formula: WMA(2 * WMA(src, length/2) - WMA(src, length), sqrt(length)).
Provides a smoother, faster-responding moving average compared to traditional MAs.

Slope Calculation:
Computes the slope of the primary HMA using a 34-bar period, normalized by the market range (highest high - lowest low over 34 bars).
Slope angle is converted to degrees using arccosine for intuitive trend strength interpretation.

Signal Conditions:
Buy: Slope ≥ 17° (flat or rising), price < minor HMA, low volatility/volume.
Sell: Slope ≤ -17° (flat or declining), price > minor HMA, low volatility/volume.
Signals are triggered only on confirmed bars to avoid repainting.

Entry and Exit Rules
Buy Signal (White Circle): Triggered when the price crosses below the minor HMA, the slope of the primary HMA is flat or rising (≥17°), and volatility/volume is low. The signal appears as a white circle above the price bar, offset by 0.72 * ATR(5).

Sell Signal (Blue Circle): Triggered when the price crosses above the minor HMA, the slope of the primary HMA is flat or declining (≤-17°), and volatility/volume is low. The signal appears as a blue circle below the price bar, offset by 0.72 * ATR(5).

Exit Rules: Exit a buy position on a sell signal and vice versa. Combine with other tools (e.g., support/resistance, RSI) for additional confirmation. Always apply proper risk management.

Recommended Usage
The "Adaptive HMA Signals" indicator is optimized for daily charts but can be adapted to other timeframes (e.g., 1H, 4H) with adjustments to period lengths. It performs best in trending or range-bound markets with clear reversal points. Traders should:

Backtest the indicator on their chosen asset and timeframe to validate signal reliability.
Combine with other technical tools (e.g., trendlines, Fibonacci retracements) for stronger trade setups.
Adjust minLength, maxLength, minorMin, and minorMax based on market volatility and timeframe.
Use the Charger input to toggle between volatility (ATR) and volume (RSI) adaptation for optimal performance in specific market conditions.

Customization Options
Source: Choose the price source (default: close).
Show Signals: Toggle visibility of buy/sell signals (default: true).
Charger: Select adaptation trigger—Volatility (ATR-based) or Volume (RSI-based) (default: Volatility).
Main HMA Periods: Set minimum (default: 144) and maximum (default: 200) periods for the primary HMA.
Minor HMA Periods: Set minimum (default: 55) and maximum (default: 89) periods for the minor HMA.
Slope Period: Fixed at 34 bars for slope calculation, adjustable via code if needed.

Why Use This Indicator?
The "Adaptive HMA Signals" indicator combines the responsiveness of HMAs with dynamic adaptation to market conditions, offering a robust tool for identifying trend reversals. Its clear visual signals, customizable periods, and adaptive logic make it versatile for various markets and trading styles. Whether you’re a beginner or an experienced trader, this indicator enhances your ability to time entries and exits with precision.
Tips for Users

Test the indicator thoroughly on your chosen market and timeframe to optimize settings (e.g., adjust period lengths for non-daily charts).
Use in conjunction with price action or other indicators (e.g., RSI, MACD) for stronger trade confirmation.
Monitor volatility/volume conditions to ensure the Charger setting aligns with market dynamics.
Ensure your chart timeframe aligns with the selected period lengths for accurate signal generation.
Apply strict risk management to protect against false signals in choppy markets.

Happy trading with the Adaptive HMA Signals indicator! Share your feedback and strategies in the TradingView community!
Phát hành các Ghi chú
Made a tweak to match the strategy version created. Minor tweaks to improve dot print.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.