OPEN-SOURCE SCRIPT

Adaptive MFI Divergence Indicator

Key Features:
Pivot-Based Divergence Detection:

The script identifies bullish and bearish divergences using MFI EMA and price pivots:
Bullish Divergence: Price forms a lower low, while the MFI EMA forms a higher low.
Bearish Divergence: Price forms a higher high, while the MFI EMA forms a lower high.
Pivots are determined using configurable left and right bars for fine-tuned divergence detection.
Dynamic Entry Conditions:

For bullish divergences, the script:
Records the pivot high formed between the two pivot lows.
Triggers a buy signal only when the price closes above the recorded pivot high.
Ensures that the divergence aligns with a positive trend and occurs under favorable volatility conditions.
For bearish divergences, the script:
Records the pivot low formed between the two pivot highs.
Triggers a sell signal only when the price closes below the recorded pivot low.
Confirms the divergence aligns with a negative trend and sufficient volatility.
Trend and Volatility Filtering:

Confirms trend alignment using EMA crossovers:
Bullish Trend: EMA (25) > EMA (50).
Bearish Trend: EMA (25) < EMA (50).
Filters signals using Historical Volatility (HV):
Signals are valid only if HV exceeds its 50-period SMA benchmark, ensuring active market conditions.
Enhanced Money Flow Index (MFI):

The MFI calculation is enhanced by:
Adjusting for volume weight using a logarithmic scale based on the ratio of current to average volume.
Normalizing weights to stay within a stable range (0.5–1.5).
Offers the option to toggle between standard and adjusted MFI using the “Use adjusted MFI” input.
Clear Visual and Alert System:

Signals are marked directly on the chart:
Green "BUY" labels appear below the bars for bullish signals.
Red "SELL" labels appear above the bars for bearish signals.
Alerts for both bullish and bearish divergences enable real-time notifications.
Entry Conditions:
Bullish Entry:
Divergence Confirmation:

Price forms a lower low.
MFI EMA forms a higher low.
Pivot low is confirmed.
Pivot High Recording:

The script records the pivot high formed between the two pivot lows.
Entry Trigger:

A buy alert is triggered only when the price closes above the recorded pivot high.
Additional checks:
Trend Confirmation: EMA (25) > EMA (50).
Volatility Validation: HV exceeds its benchmark (50-period SMA).
MFI EMA Threshold: MFI EMA > 61.8.
Bearish Entry:
Divergence Confirmation:

Price forms a higher high.
MFI EMA forms a lower high.
Pivot high is confirmed.
Pivot Low Recording:

The script records the pivot low formed between the two pivot highs.
Entry Trigger:

A sell alert is triggered only when the price closes below the recorded pivot low.
Additional checks:
Trend Confirmation: EMA (25) < EMA (50).
Volatility Validation: HV exceeds its benchmark (50-period SMA).
MFI EMA Threshold: MFI EMA < 38.2.
Practical Applications:
Divergence-Based Reversals:

Ideal for detecting potential trend reversals using divergence signals confirmed by pivot breakouts.
Trend-Filtered Signals:

Eliminates false signals by requiring trend alignment via EMA crossovers.
Volatility-Aware Trading:

Ensures signals occur during active market conditions, reducing noise and enhancing signal reliability.
Why Choose This Indicator?
The Custom MFI Divergence Alerts script combines:

Accurate divergence detection using pivots on price and MFI EMA.
Dynamic entry conditions that align with trend and market volatility.
Volume-weighted MFI adjustments for more reliable oscillator signals
bitcoinpredictioncommoditysignalscommoditytradingExponential Moving Average (EMA)goldsignalsHistorical VolatilityMFImfi_divergenceMoney Flow Index (MFI)niftyprediction

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?


更多:

免责声明