OPEN-SOURCE SCRIPT
已更新 Adaptive ALMA 2.0

This script is a indicator that builds upon the Arnaud Legoux Moving Average (ALMA). Unlike a standard ALMA, which uses fixed settings, this version is "Adaptive" and "Evasive."
Here is a breakdown of what the code is doing:
1. The Adaptive Engine (Efficiency Ratio)
The core logic uses an Efficiency Ratio (ER) to measure market noise versus trend strength:
High Volatility/Clear Trend: The ER is high. The script automatically shortens the length and reduces the offset to make the line react faster (minimizing lag).
Low Volatility/Consolidation: The ER is low. The script increases the length and sigma to make the line smoother, preventing "whipsaws" (fake signals).
2. Global Evasion Engine (Noise Filtering)
This is the most unique part of the script. It uses two ATRs (Fast and Slow) to create a "Noise Zone":
Auto-Tune Evasion: It calculates a visual_noise_th (threshold). If the price is wiggling inside this gray/aqua band, the trend state won't change easily.
Volatility-Based Sensitivity: In "noisy" markets, it requires a larger price move (determined by d_atr) to flip the trend from Bullish to Bearish.
PS1: ATR is calculated on the full range of candle prices - open + close
3. Trend Logic & Signals
Bullish (Green): When the ALMA is rising, the price is above it, and the move exceeds the noise threshold.
Bearish (Red): When the ALMA is falling, the price is below it, and the move exceeds the noise threshold.
Neutral (Gray): When the price is stuck within the "Noise Band."
4. Extra Layers
It includes Medium (50) and Long (200) ALMA lines to give you a broader context of the trend (e.g., only taking Buy signals when the Long ALMA is also green).
Source: It uses a custom price source (open + close + close) / 3 to give more weight to the closing price while maintaining some "breath" from the open.
PS2: the sample chart is for BTC with a 5-minute interval
PS3: Works on any interval - you only need to adjust the parameters, default values are for fast-moving and liquid assets (e.g. BTC intervals 1 minute - 1 day and higher) and suggested Japanese candles (including Heikin Ashi)
Here is a breakdown of what the code is doing:
1. The Adaptive Engine (Efficiency Ratio)
The core logic uses an Efficiency Ratio (ER) to measure market noise versus trend strength:
High Volatility/Clear Trend: The ER is high. The script automatically shortens the length and reduces the offset to make the line react faster (minimizing lag).
Low Volatility/Consolidation: The ER is low. The script increases the length and sigma to make the line smoother, preventing "whipsaws" (fake signals).
2. Global Evasion Engine (Noise Filtering)
This is the most unique part of the script. It uses two ATRs (Fast and Slow) to create a "Noise Zone":
Auto-Tune Evasion: It calculates a visual_noise_th (threshold). If the price is wiggling inside this gray/aqua band, the trend state won't change easily.
Volatility-Based Sensitivity: In "noisy" markets, it requires a larger price move (determined by d_atr) to flip the trend from Bullish to Bearish.
PS1: ATR is calculated on the full range of candle prices - open + close
3. Trend Logic & Signals
Bullish (Green): When the ALMA is rising, the price is above it, and the move exceeds the noise threshold.
Bearish (Red): When the ALMA is falling, the price is below it, and the move exceeds the noise threshold.
Neutral (Gray): When the price is stuck within the "Noise Band."
4. Extra Layers
It includes Medium (50) and Long (200) ALMA lines to give you a broader context of the trend (e.g., only taking Buy signals when the Long ALMA is also green).
Source: It uses a custom price source (open + close + close) / 3 to give more weight to the closing price while maintaining some "breath" from the open.
PS2: the sample chart is for BTC with a 5-minute interval
PS3: Works on any interval - you only need to adjust the parameters, default values are for fast-moving and liquid assets (e.g. BTC intervals 1 minute - 1 day and higher) and suggested Japanese candles (including Heikin Ashi)
版本注释
- Added additional options (timeframe = '', timeframe_gaps = false) - Change the time frame and set the marker after the end of the time interval (prevents "repainting")- Added offset options for drawing markers on the main chart
- Minor changes to the arguments panel (coloring moved to the styles panel)
- Slightly changed the coloring selection for averages (Adaptive ALMA first)
- Minor option change - FIXED ALMA medium and ALMA long averages are active by default - this is intended to enable the full range of indicator options.
The script does not repaint historical markers - the only option that "gives the impression of flickering" is the variability of the marker's appearance during the CURRENT candlestick until the end of the interval (candlestick), i.e., during the trading period of a given interval. This can be prevented by using the option from the first patch at the very top.
版本注释
- Fixed several bugs- Added Bollinger Bands with crossover markers
- Changed default settings to more universal ones (working on standard and Heikin Ashi candles)
- Added the "source" line as a guide
- For traditionalists, the code includes a hidden price switch for a standard set of price data (close, hlc, ohlc4, etc.) – just unlock and use.
I think this is the final version – it can be used as a ready-made system.
版本注释
minor code changes版本注释
minor code fixes开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。