OPEN-SOURCE SCRIPT

EMA Ribbon Convergence Pullback Long [Swing]

352
EMA Ribbon Convergence Pullback Long [Swing] v10

Type: Long-only entry signal indicator (Pine Script v5, indicator())
Market: Indian equities (NSE), daily timeframe — works on other markets/timeframes but tuned for daily swings
Core idea: Flag a long entry when a 10-EMA ribbon (10 to 100) has recently tightened into a basing zone, price pulls back into it, and then closes back above the fastest EMA.

Note: This is the indicator version — it plots entry signals and alerts only. It does not size positions, place stops/targets, or run backtests. See the separate strategy() build (v11+) if you need Strategy Tester results with stop-loss/target logic.


1. Concept

The ribbon is 10 EMAs (10, 20, 30 ... 100). Three market states matter:


Basing (convergence): the EMAs bunch close together — the stock is consolidating rather than trending.
Pullback: after an uptrend resumes, price dips back down and touches or dips slightly below the ribbon.
Reversal (trigger): price closes back above the fastest EMA (EMA10), confirming buyers have stepped back in.


The indicator signals on step 3, provided step 1 happened recently and the broader trend (price vs EMA100) is still up.

Important design note: the ribbon does not need to be tightly converged on the trigger bar itself. A real pullback naturally causes the fast EMA to dip below the slower ones — requiring "tight AND perfectly ordered" on the same bar as the breakout is close to a contradiction. This version checks convergence over a recent lookback window, then checks the breakout separately as a distinct condition.


2. Entry Logic (all must be true)

#ConditionDescription1Basing RecentlyRibbon spread was "tight" (below threshold) at some point in the last N bars (convergenceLookback)2Trend UpPrice is above EMA100 (or EMA100 rising, depending on mode selected)3Pulled BackPrice's low touched or dipped below EMA10 within the last N bars (pullbackLookback)4Reversal TriggerClose crosses back above EMA10 (or, optionally, a bullish engulfing/hammer candle)5CooldownAt least cooldownBars bars since the last signal, to reduce signal spam

A yellow dot marks "near miss" bars — everything above is true except the trigger hasn't fired yet. Useful as an early watchlist flag.

Known gap in this version: cooldown is bar-count based only — there is no price-distance check, so two signals can fire close together in price if they land just outside the cooldown window on the same basing structure (this was fixed with a price-gap filter in v11).


3. What This Version Does Not Include


No stop-loss or target levels
No position sizing or backtest stats (Strategy Tester tab will not appear — this is an indicator(), not a strategy())
No price-distance-based duplicate-signal suppression (bar-count cooldown only)
No higher-timeframe (weekly) trend filter



4. Key Inputs Reference

Convergence


useAdaptive (default ON) — auto-scales the "tight ribbon" threshold to the stock's own recent volatility (percentile-based) instead of a fixed %. Recommended ON, especially across stocks at very different price levels.
convergenceThresh (default 3.0%) — fixed threshold used only if useAdaptive is OFF, and as the automatic fallback during the adaptive method's warm-up period (first ~150 bars of a chart's history).
pctLen (default 150) — lookback window for the adaptive percentile calculation.
pctRank (default 30) — lower = stricter/tighter convergence requirement.


Ribbon Order


requireBullishOrder (default OFF) — if ON, also requires EMA10 > EMA50 > EMA100 strictly on the trigger bar. Keep OFF for normal pullback entries; turning it ON produces a much rarer "clean trend only" variant. When OFF, this is tracked as an informational-only value in the Data Window.


Setup / Pullback / Trend


convergenceLookback (default 10) — how far back to check for a basing zone.
pullbackLookback (default 6) — how far back to check for a dip into the ribbon.
trendFilterMode (default "Price Above EMA100, no slope") — choose between slope-based or simple price-vs-EMA100 trend filters.
trendLen (default 10) — slope lookback, only used in the 10-bar EMA100-rising mode.
cooldownBars (default 5) — minimum bars between signals.


Candle Confirmation


requireCandlePattern (default OFF) — if ON, requires an engulfing or hammer candle in addition to the crossover. OFF gives more signals; ON gives fewer, higher-conviction ones.
useEngulfing, useHammer, minBodyATRRatio — pattern-detection sub-settings, only relevant if the above is ON or you're using patterns as an alternative trigger.


Diagnostics


showDebugTable — live stats panel (top-right) showing hover/click instructions.
showSetupMarkers — yellow "near miss" dots.
showWarmupBg — shades the region at the start of the chart where the adaptive threshold hasn't fully matured yet (using the fixed-% fallback instead).
Hidden 🔍-prefixed data-window plots — hover any bar (or click-and-hold on the chart) and open TradingView's Data Window (right-hand toolbar icon, or Alt+D) to see the live true/false state of every condition for that specific bar: Spread %, Threshold Used, Converged, EMA Order, Ribbon Bullish, Basing Recently, Pulled Back, Close Crossed Up, Candle Pattern, Trend Up, and the final BUY Signal flag. This is the fastest way to understand why a bar did or didn't signal.



5. How to Use


Paste the script into Pine Editor and add to chart.
Set an alert on the built-in alertcondition ("EMA Ribbon Long Entry") if you want notifications — set trigger to "Once Per Bar Close" to avoid intrabar flicker.
Use the Data Window (see Diagnostics above) to inspect any historical bar and confirm which conditions passed.
Because there's no stop-loss/target built in here, define your own risk management manually before acting on a signal (e.g., stop below the pullback low, target at a fixed risk-multiple).



6. Known Limitations


Long-only, daily-timeframe design. No short logic; not tested on intraday timeframes.
No higher-timeframe (weekly) trend filter — the indicator can still fire during a daily pullback that's actually part of a larger weekly downtrend. Consider manually checking the weekly chart before taking a signal.
No exit logic. This tells you when to consider entering, not when to exit — position sizing, stop-loss, and target are entirely up to you at this version.
Not backtested with real trade statistics at this stage — visual/historical review only. Use the v11+ strategy() build for Strategy Tester metrics (win rate, profit factor, drawdown).
This is not financial advice. Validate signals manually, paper trade, and manage risk according to your own plan before using with real capital.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.