OPEN-SOURCE SCRIPT

Consecutive Candles Above/Below EMA

86
Description:
This indicator identifies and highlights periods where the price remains consistently above or below an Exponential Moving Average (EMA) for a user-defined number of consecutive candles. It visually marks these sustained trends with background colors and labels, helping traders spot strong bullish or bearish market conditions. Ideal for trend-following strategies or identifying potential trend exhaustion points, this tool provides clear visual cues for price behavior relative to the EMA.
How It Works:
EMA Calculation: The indicator calculates an EMA based on the user-specified period (default: 100). The EMA is plotted as a blue line on the chart for reference.

Consecutive Candle Tracking: It counts how many consecutive candles close above or below the EMA:
If a candle closes below the EMA, the "below" counter increments; any candle closing above resets it to zero.

If a candle closes above the EMA, the "above" counter increments; any candle closing below resets it to zero.

Highlighting Trends: When the number of consecutive candles above or below the EMA meets or exceeds the user-defined threshold (default: 200 candles):
A translucent red background highlights periods where the price has been below the EMA.

A translucent green background highlights periods where the price has been above the EMA.

Labeling: When the required number of consecutive candles is first reached:
A red downward arrow label with the text "↓ [number] Below" appears for below-EMA streaks.

A green upward arrow label with the text "↑ [number] Above" appears for above-EMA streaks.

Usage:
Trend Confirmation: Use the highlights and labels to confirm strong trends. For example, 200 candles above the EMA may indicate a robust uptrend.

Reversal Signals: Prolonged streaks (e.g., 200+ candles) might suggest overextension, potentially signaling reversals.

Customization: Adjust the EMA period to make it faster or slower, and modify the candle count to make the indicator more or less sensitive to trends.

Settings:
EMA Length: Set the period for the EMA calculation (default: 100).

Candles Count: Define the minimum number of consecutive candles required to trigger highlights and labels (default: 200).

Visuals:
Blue EMA line for tracking the moving average.

Red background for sustained below-EMA periods.

Green background for sustained above-EMA periods.

Labeled arrows to mark when the streak threshold is met.

This indicator is a powerful tool for traders looking to visualize and capitalize on persistent price trends relative to the EMA, with clear, customizable signals for market analysis.

Explain EMA calculation

Other trend indicators

Make description shorter

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.