OPEN-SOURCE SCRIPT
Aggiornato MA Distance Alert

# MA Distance Alert - 均线偏离警报指标
## 中文说明
### 指标简介
MA Distance Alert 是一款基于均线原理的价格偏离监控指标,支持SMA/EMA双均线类型,可自定义均线周期与价格偏离阈值,实时监控价格与均线的偏离程度,当价格超出设定的偏离区间时自动触发视觉提醒与警报通知,辅助交易者快速捕捉价格极端偏离、趋势反转或加速行情信号。
### 核心功能
1. **灵活均线配置**:支持SMA(简单移动平均)、EMA(指数移动平均)两种常用均线类型,可自由调整均线计算周期
2. **精准偏离监控**:自动计算收盘价与均线的偏离百分比,基于自定义阈值生成上下偏离轨道
3. **多重视觉提醒**:高亮标注超出偏离区间的K线背景,上偏离显示红色背景,下偏离显示绿色背景
4. **智能警报通知**:支持价格向上突破、向下跌破、双向偏离三种警报条件,覆盖全场景监控需求
5. **界面友好**:指标叠加在主图显示,不遮挡价格走势,线条配色清晰易辨
### 使用方法
1. 将指标代码添加至TradingView Pine编辑器,加载至图表
2. 参数自定义:选择均线类型、设置均线周期(默认120)、调整偏离阈值(默认12%)
3. 实时观察:价格在上下轨道内运行为正常区间,超出轨道时触发背景高亮
4. 警报设置:开启指标警报,接收价格极端偏离的实时通知
### 适用场景
适用于股票、加密货币、外汇、期货等全品类交易品种,可用于趋势行情中的回调预警、震荡行情中的高低点捕捉、极端行情中的超买超卖判断,适配日线、小时线等所有时间周期。
---
# MA Distance Alert - Moving Average Distance Alert Indicator
## English Description
### Indicator Introduction
MA Distance Alert is a price deviation monitoring indicator based on the moving average principle. It supports both SMA and EMA types, allowing custom moving average periods and price deviation thresholds. It monitors the deviation between price and moving average in real time, automatically triggers visual reminders and alert notifications when the price exceeds the set deviation range, helping traders quickly capture signals of extreme price deviation, trend reversal or accelerated market trends.
### Core Features
1. **Flexible MA Configuration**: Support two commonly used moving average types: SMA (Simple Moving Average) and EMA (Exponential Moving Average), freely adjust the MA calculation period
2. **Accurate Deviation Monitoring**: Automatically calculate the deviation percentage between the closing price and the moving average, generate upper and lower deviation bands based on custom thresholds
3. **Multiple Visual Alerts**: Highlight the K-line background when exceeding the deviation range, red background for upward deviation and green background for downward deviation
4. **Smart Alert Notifications**: Support three alert conditions: price breakout upward, breakdown downward, and two-way deviation, covering full-scenario monitoring needs
5. **User-friendly Interface**: Overlaid on the main chart without blocking price movements, with clear and distinguishable line colors
### How to Use
1. Add the indicator code to TradingView Pine Editor and load it on the chart
2. Customize Parameters: Select MA type, set MA period (default 120), adjust deviation threshold (default 12%)
3. Real-time Observation: Price moving within upper and lower bands is the normal range, background highlight is triggered when exceeding the bands
4. Alert Setup: Enable indicator alerts to receive real-time notifications of extreme price deviations
### Applicable Scenarios
Suitable for all trading varieties including stocks, cryptocurrencies, forex, futures, etc. It can be used for callback early warning in trending markets, high-low point capture in ranging markets, overbought and oversold judgment in extreme markets, compatible with all time frames such as daily and hourly charts.
## 中文说明
### 指标简介
MA Distance Alert 是一款基于均线原理的价格偏离监控指标,支持SMA/EMA双均线类型,可自定义均线周期与价格偏离阈值,实时监控价格与均线的偏离程度,当价格超出设定的偏离区间时自动触发视觉提醒与警报通知,辅助交易者快速捕捉价格极端偏离、趋势反转或加速行情信号。
### 核心功能
1. **灵活均线配置**:支持SMA(简单移动平均)、EMA(指数移动平均)两种常用均线类型,可自由调整均线计算周期
2. **精准偏离监控**:自动计算收盘价与均线的偏离百分比,基于自定义阈值生成上下偏离轨道
3. **多重视觉提醒**:高亮标注超出偏离区间的K线背景,上偏离显示红色背景,下偏离显示绿色背景
4. **智能警报通知**:支持价格向上突破、向下跌破、双向偏离三种警报条件,覆盖全场景监控需求
5. **界面友好**:指标叠加在主图显示,不遮挡价格走势,线条配色清晰易辨
### 使用方法
1. 将指标代码添加至TradingView Pine编辑器,加载至图表
2. 参数自定义:选择均线类型、设置均线周期(默认120)、调整偏离阈值(默认12%)
3. 实时观察:价格在上下轨道内运行为正常区间,超出轨道时触发背景高亮
4. 警报设置:开启指标警报,接收价格极端偏离的实时通知
### 适用场景
适用于股票、加密货币、外汇、期货等全品类交易品种,可用于趋势行情中的回调预警、震荡行情中的高低点捕捉、极端行情中的超买超卖判断,适配日线、小时线等所有时间周期。
---
# MA Distance Alert - Moving Average Distance Alert Indicator
## English Description
### Indicator Introduction
MA Distance Alert is a price deviation monitoring indicator based on the moving average principle. It supports both SMA and EMA types, allowing custom moving average periods and price deviation thresholds. It monitors the deviation between price and moving average in real time, automatically triggers visual reminders and alert notifications when the price exceeds the set deviation range, helping traders quickly capture signals of extreme price deviation, trend reversal or accelerated market trends.
### Core Features
1. **Flexible MA Configuration**: Support two commonly used moving average types: SMA (Simple Moving Average) and EMA (Exponential Moving Average), freely adjust the MA calculation period
2. **Accurate Deviation Monitoring**: Automatically calculate the deviation percentage between the closing price and the moving average, generate upper and lower deviation bands based on custom thresholds
3. **Multiple Visual Alerts**: Highlight the K-line background when exceeding the deviation range, red background for upward deviation and green background for downward deviation
4. **Smart Alert Notifications**: Support three alert conditions: price breakout upward, breakdown downward, and two-way deviation, covering full-scenario monitoring needs
5. **User-friendly Interface**: Overlaid on the main chart without blocking price movements, with clear and distinguishable line colors
### How to Use
1. Add the indicator code to TradingView Pine Editor and load it on the chart
2. Customize Parameters: Select MA type, set MA period (default 120), adjust deviation threshold (default 12%)
3. Real-time Observation: Price moving within upper and lower bands is the normal range, background highlight is triggered when exceeding the bands
4. Alert Setup: Enable indicator alerts to receive real-time notifications of extreme price deviations
### Applicable Scenarios
Suitable for all trading varieties including stocks, cryptocurrencies, forex, futures, etc. It can be used for callback early warning in trending markets, high-low point capture in ranging markets, overbought and oversold judgment in extreme markets, compatible with all time frames such as daily and hourly charts.
Note di rilascio
# MA Distance Alert - 均线偏离警报指标## 中文说明
### 指标简介
MA Distance Alert 是一款基于均线原理的价格偏离监控指标,支持SMA/EMA双均线类型,可自定义均线周期与价格偏离阈值,实时监控价格与均线的偏离程度,当价格超出设定的偏离区间时自动触发视觉提醒与警报通知,辅助交易者快速捕捉价格极端偏离、趋势反转或加速行情信号。
### 核心功能
1. **灵活均线配置**:支持SMA(简单移动平均)、EMA(指数移动平均)两种常用均线类型,可自由调整均线计算周期
2. **精准偏离监控**:自动计算收盘价与均线的偏离百分比,基于自定义阈值生成上下偏离轨道
3. **多重视觉提醒**:高亮标注超出偏离区间的K线背景,上偏离显示红色背景,下偏离显示绿色背景
4. **智能警报通知**:支持价格向上突破、向下跌破、双向偏离三种警报条件,覆盖全场景监控需求
5. **界面友好**:指标叠加在主图显示,不遮挡价格走势,线条配色清晰易辨
### 使用方法
1. 将指标代码添加至TradingView Pine编辑器,加载至图表
2. 参数自定义:选择均线类型、设置均线周期(默认120)、调整偏离阈值(默认12%)
3. 实时观察:价格在上下轨道内运行为正常区间,超出轨道时触发背景高亮
4. 警报设置:开启指标警报,接收价格极端偏离的实时通知
### 适用场景
适用于股票、加密货币、外汇、期货等全品类交易品种,可用于趋势行情中的回调预警、震荡行情中的高低点捕捉、极端行情中的超买超卖判断,适配日线、小时线等所有时间周期。
---
# MA Distance Alert - Moving Average Distance Alert Indicator
## English Description
### Indicator Introduction
MA Distance Alert is a price deviation monitoring indicator based on the moving average principle. It supports both SMA and EMA types, allowing custom moving average periods and price deviation thresholds. It monitors the deviation between price and moving average in real time, automatically triggers visual reminders and alert notifications when the price exceeds the set deviation range, helping traders quickly capture signals of extreme price deviation, trend reversal or accelerated market trends.
### Core Features
1. **Flexible MA Configuration**: Support two commonly used moving average types: SMA (Simple Moving Average) and EMA (Exponential Moving Average), freely adjust the MA calculation period
2. **Accurate Deviation Monitoring**: Automatically calculate the deviation percentage between the closing price and the moving average, generate upper and lower deviation bands based on custom thresholds
3. **Multiple Visual Alerts**: Highlight the K-line background when exceeding the deviation range, red background for upward deviation and green background for downward deviation
4. **Smart Alert Notifications**: Support three alert conditions: price breakout upward, breakdown downward, and two-way deviation, covering full-scenario monitoring needs
5. **User-friendly Interface**: Overlaid on the main chart without blocking price movements, with clear and distinguishable line colors
### How to Use
1. Add the indicator code to TradingView Pine Editor and load it on the chart
2. Customize Parameters: Select MA type, set MA period (default 120), adjust deviation threshold (default 12%)
3. Real-time Observation: Price moving within upper and lower bands is the normal range, background highlight is triggered when exceeding the bands
4. Alert Setup: Enable indicator alerts to receive real-time notifications of extreme price deviations
### Applicable Scenarios
Suitable for all trading varieties including stocks, cryptocurrencies, forex, futures, etc. It can be used for callback early warning in trending markets, high-low point capture in ranging markets, overbought and oversold judgment in extreme markets, compatible with all time frames such as daily and hourly charts.
Note di rilascio
Add asymmetric threshold and flexible price source configuration- Split single threshold into separate upper and lower deviation thresholds for asymmetric alerts
- Add price type selector for moving average calculation (close, open, high, low)
- Add independent price source selection for upper and lower deviation comparisons
- Implement logic to use configured price types for historical bars and latest price for unclosed bars
- Improve parameter organization and add descriptive titles for better usability
- Enable more granular control over alert sensitivity and price comparison methods
-------------
变更日志:新增计算价格、上/下偏离阈值、上/下偏离比较价格等可选配置项
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
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.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
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.