PROTECTED SOURCE SCRIPT

Smart Trail + Trend Ribbon

96
Smart Trail + Trend Ribbon

This script combines a smart trailing system with an EMA-based trend ribbon to help you quickly read trend direction, potential reversals and dynamic support/resistance zones.

1. Smart Trail
The Smart Trail module is based on an external library function getSmartTrail() and plots a dynamic trailing line that adapts to market conditions.

• The line switches its state between long and short depending on price action.
• When the direction is long, the trail is colored with the Up Color; when short, it uses the Down Color.
• The area between the main trail and the filler line is shaded to highlight the active bias and strength of the move.

Smart Trail inputs:
Trail Period – base length for calculating the trail.
Param A / Param B – additional sensitivity and smoothing parameters that control how fast the trail reacts to price changes.
Up Color / Down Color – visual colors for long/short regimes.

Use it as a dynamic support/resistance reference or as a trailing level for managing open positions.

2. Trend Ribbon (EMA Ribbon)
The Trend Ribbon block uses two EMAs calculated on hlc3 (average of high, low and close) and creates a colored band between them.

• When EMA Ribbon 1 is above EMA Ribbon 2, the area between them is filled with Uptrend Colors.
• When EMA Ribbon 1 is below EMA Ribbon 2, the area is filled with Downtrend Colors.
• The ribbon is slightly expanded relative to the EMAs using the current price range to make the zone more visible on the chart.

Trend Ribbon inputs:
EMA Ribbon 1 Period – faster EMA.
EMA Ribbon 2 Period – slower EMA.
Uptrend Color / Uptrend Color (2) – main and secondary colors for bullish conditions.
Downtrend Color / Downtrend Color (2) – main and secondary colors for bearish conditions.

This gives you a clear visual filter of the current trend and helps avoid trading directly against the dominant direction.

How to use
• Combine the Smart Trail direction with the Trend Ribbon bias to confirm entries and exits.
• Long setups are stronger when the Smart Trail is in long mode and the Trend Ribbon shows an uptrend.
• Short setups are cleaner when the Smart Trail is in short mode and the Trend Ribbon shows a downtrend.
• Works on any symbol and timeframe; parameters can be tuned to your trading style (scalping, intraday, swing).

Disclaimer: This script is for educational and analytical purposes only and is not financial advice. Always manage your own risk.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.