OPEN-SOURCE SCRIPT
Telah dikemas kini

EMA/SMA Ribbon Pro (AUTO HTF + Labels)

2 286
This indicator is a multi-timeframe (MTF) moving average ribbon that dynamically adjusts to the next highest timeframe. It provides a visual representation of market trends by stacking multiple EMAs and SMAs with customizable color fills and labels.

Features

✅ Multi-Timeframe (MTF) Support: Automatically detects the next highest time frame or allows for manual selection
✅ Customizable Moving Averages: Supports EMA and SMA with different lengths for flexible configuration
✅ Ribbon Visualization: Smooth color transitions between different moving averages for better trend identification
✅ Crossover Labels: Detects bullish and bearish EMA/SMA crossovers and marks them on the chart
✅ Price Labels & Timeframe Display: Displays moving average values to the right of the price axis with customizable label padding and colors

How It Works

Select the HTF mode: Manual or automatic
Choose EMA/SMA lengths to create different ribbons
Enable/disable price labels for each moving average
Customize colors and transparency for ribbons and labels
Crossover labels appear when faster moving averages cross slower ones and vice versa

Use Cases

📌 Trend Identification: Identify bullish and bearish trends using multiple EMAs and SMAs
📌 Support & Resistance Zones: MAs can act as dynamic support and resistance levels
📌 Reversal & Confirmation Signals: Watch for MTF crossovers to confirm trend changes

Customization

🔹 Standard EMA Lengths: 6, 8, 13, 21, 34, 48, 100, 200, 300, 400
🔹 SMA Lengths: 48, 100, 200
🔹 Color Adjustments: Set custom colors for bullish/bearish ribbons
🔹 Crossovers: Enable/disable custom crossover pairs (e.g., 100/200 EMA, 200 EMA/SMA).

This indicator is perfect for traders who rely on multi-timeframe confluence while seeking to enhance their market analysis and decision-making process.

As always, by combining EMA/SMA Ribbon with other tools, traders ensure that they are not relying on a single indicator. This layered approach can reduce the likelihood of false signals and improve overall trading accuracy.

As always, be sure to use any indicator with price action and volume indicators for better trade confirmation!
Nota Keluaran
❗❗I wanted to give an update to clarify how I like to use this indicator❗❗

First, I have created alerts for a few of my favorite crossover pairs. Those include the EMA 13/48, EMA 100/200 and EMA/SMA 200/200. I've also included alerts for a break and retest of the EMA 21. I did have to comment out a few alerts in order to meet the OUTPUT SERIES threshold of 64 plot counts. 🙀 For more information: tradingview.com/pine-script-docs/writing/limitations/

An example of using either of the crossovers in a real-world situation could be the "break and retest" of the crossover. For instance, you could be on the 5 minute chart with the AUTO HTF feature enabled (therefore you're looking at the 10 minute ribbon and respective labels).
At this point, you're looking for a few things: an alert such as the 13/48 to fire (to the upside) on the higher time frame (10 minute ribbon). Generally, a crossover on a higher time frame will hold more weight than a lower one. But since you're on the 5 minute chart, you could wait for a close of the 5 minute candle either one time (or 2 times for more confirmation) after the 13/48 crossover alert/label fires and then you could place your trade. OR you could wait
(now that the crossover has occurred) for price to reverse back to where the crossover occurred and make sure that it bounces off the level, reverses course again and regains/retains its bullish momentum. While of course making sure to set your stop loss dependent upon your specific strategy. But in this example, you could set it using a "1.5x stop loss strategy" - meaning set your stop-loss order at a price level that is 1.5 times the "average true range" (ATR) below your entry price (there are plenty of indicators for this including a built in one called Long Position/Short Position), essentially allowing for some price fluctuation while still limiting
potential losses to a predetermined percentage based on the stock's recent volatility.

I included alerts for both the chart that you're on (AUTO HTF is disabled) and for when AUTO HTF is enabled. To create an alert:
➖you'll first determine if you want the alert to fire based on the Chart or a time frame of your choosing from the dropdown (AUTO HTF is disabled) or if you want the alert to fire based on the next highest time frame from your current chart (AUTO HTF is enabled).
💡TIP: If you choose to manually choose your higher time frame via the dropdown
menu, you'll want to make sure you remember which time frame you use so that you can create a custom alert name based on that specific chosen time frame.
➖Next, you'll click on the 3 dots next to the Indicator name in upper left of chart panel.
➖Then click "Add Alert on..."
➖From there, you should be able to pick the type of alert based on the title.
➖Then set the trigger, the experation and then add a custom name (if applicable) but the Message should already be populated and you can determine if that needs to be changed based on if you choose your custom higher time frame (AUTO HTF disabled) or if you choose the
next highest time frame (AUTO HTF is enabled).

💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥

// Break and Retest Strategy Explanation of EMA 21

This strategy alerts traders when price breaks above or below the EMA 21 and successfully retests it within a user-defined number of bars. The alerts work for both the chart’s timeframe and an optional higher timeframe (HTF) when Auto HTF is enabled.

1️⃣ Detecting the Initial Break
Bullish Breakout:
➖This occurs when the closing price crosses above the 21 EMA.
➖The alert tracks this using ta.crossover(), which confirms when price was below the EMA on the previous bar and has now moved above it.

Bearish Breakdown:
➖This occurs when the closing price crosses below the 21 EMA.
➖The script tracks this using ta.crossunder(), confirming when price was above the EMA on the previous bar and has now moved below it.
These breakouts are detected separately for both the chart’s timeframe and the higher timeframe (if selected by the user).

2️⃣ Checking for a Retest Within a Set Number of Bars
After the breakout, the alert checks if price returns to test the EMA 21 within a user-defined number of bars before confirming a continuation in the breakout direction.

Bullish Retest Condition:
➖After breaking above the 21 EMA, price must dip back to or below the EMA within the set number of bars (retest_bars).
➖If the lowest price in this period is below the EMA, and price closes back above the EMA, a successful bullish retest is confirmed.
Bearish Retest Condition:
➖After breaking below the 21 EMA, price must rise back to or above the EMA within the set number of bars.
➖If the highest price in this period is above the EMA, and price closes back below the EMA, a successful bearish retest is confirmed.
These retests are tracked for both the chart timeframe and higher timeframe.

3️⃣ Creating Alerts for Break and Retest Confirmation
Once the breakout and retest conditions are both met, an alert is triggered to notify the trader:
Bullish Retest Alert:
➖Triggers when price breaks above the 21 EMA and successfully retests it within the set number of bars before bouncing higher.
➖Bearish Retest Alert:
➖Triggers when price breaks below the 21 EMA and successfully retests it within the set number of bars before dropping lower.
➖The alerts explicitly indicate whether the event occurred on the chart’s timeframe or the higher timeframe based on user settings.

🟢How This EMA 21 Retest Helps Traders🟢

This setup allows traders to confirm strong breakout trends by ensuring that price not only breaks the 21 EMA but also retests it before continuing.
🟢Reduces false breakouts: Avoids chasing moves that might quickly reverse.
🟢 Provides confirmation: Ensures that price respects the EMA as a key support/resistance level.
🟢Works for multiple timeframes: Traders can track signals on their chart’s timeframe or a selected higher timeframe for greater trend confirmation.

By combining breakout detection with a proper retest condition and stop-loss (ATR), traders can enter positions more confidently and improve the accuracy of their trend-following strategies.

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.