OPEN-SOURCE SCRIPT
Levels & Flow

📌 Overview
Levels & Flow is a visual trading tool that combines daily pivot levels with a dynamic EMA ribbon to help traders identify structure, momentum, and key decision zones in the market.
This script is designed for discretionary traders who rely on clean visual cues for intraday and swing trading strategies.
⚙️ Key Features
Daily Pivot, Support, and Resistance Lines
Automatically plots the daily pivot level based on the previous day’s OHLC data, along with calculated support and resistance levels.
Fibonacci Retracement Levels
Two dashed lines above and below the pivot represent the retracement of the pivot-resistance and pivot-support range, forming the boundaries of the “no-trade zone.”
No-Trade Zone (Shaded Box)
A gray shaded box between the two Fibonacci levels to visually mark a high-chop/low-conviction zone.
Trend-Based Candle Coloring (Current Day Only)
Candles are colored green if the close is above the pivot, red if below (only on the current trading day).
Bullish/Bearish Trend Label
A small table in the bottom-right corner displays “Bullish” or “Bearish” depending on whether price is above or below the pivot.
20-EMA Gradient Ribbon
A stack of 20 EMAs, each smoothed and color-coded from blue to green to reflect short- to long-term trend alignment.
Cumulative EMA with Adaptive Weighting
An intelligent moving average line that adjusts weight distribution among the 20 EMAs based on recent predictive accuracy using a learning rate and lookback period.
🧠 How It Works
📍 Levels
The script calculates daily pivot, resistance, and support levels using standard formulas:
Pivot = (High + Low + Close) / 3
Resistance = (2 × Pivot) – Low
Support = (2 × Pivot) – High
These levels update each day and extend 143 bars to the right.
📏 Fib Lines
Fib Up = Pivot + (Resistance – Pivot) × 0.382
Fib Down = Pivot – (Pivot – Support) × 0.382
These lines form the “no-trade zone” box.
📈 EMA Ribbon
20 EMAs starting from the user-defined Base Length, each incremented by 1
Each EMA is smoothed using the Smoothing Period
Color-coded from blue to green for intuitive visual flow
Filled between EMAs to visualize trend strength and alignment
🧠 Cumulative EMA Learning
Each EMA’s historical error is calculated over a Lookback Period
Lower-error EMAs receive higher weight; weights are normalized to sum to 1
The result is a cumulative EMA that adapts based on historical predictive power
🔧 User Inputs
Input
Base EMA Length: Sets the period for the shortest EMA (default: 20)
Smoothing Period: Smooths all EMAs and the cumulative EMA
Lookback for Learning: Number of bars to evaluate EMA prediction accuracy
Learning Rate: Adjusts how quickly weights shift in favor of more accurate EMAs
✅ How to Use It
Use the pivot level to define directional bias.
Watch for price breakouts above resistance or breakdowns below support to consider entry.
Avoid trading inside the shaded zone, where direction is less reliable.
Use the EMA ribbon gradient to confirm short/long alignment.
The cumulative EMA helps define trend with noise reduction.
🧪 Best For
Intraday traders who want to blend structure with flow
Swing traders needing clean daily levels with dynamic confirmation
Anyone looking to avoid choppy zones and improve visual clarity
⚠️ Disclaimer
This script is for educational and informational purposes only. It does not constitute financial advice or a trading recommendation. Always test scripts in simulation or on demo accounts before live use. Use at your own risk.
Levels & Flow is a visual trading tool that combines daily pivot levels with a dynamic EMA ribbon to help traders identify structure, momentum, and key decision zones in the market.
This script is designed for discretionary traders who rely on clean visual cues for intraday and swing trading strategies.
⚙️ Key Features
Daily Pivot, Support, and Resistance Lines
Automatically plots the daily pivot level based on the previous day’s OHLC data, along with calculated support and resistance levels.
Fibonacci Retracement Levels
Two dashed lines above and below the pivot represent the retracement of the pivot-resistance and pivot-support range, forming the boundaries of the “no-trade zone.”
No-Trade Zone (Shaded Box)
A gray shaded box between the two Fibonacci levels to visually mark a high-chop/low-conviction zone.
Trend-Based Candle Coloring (Current Day Only)
Candles are colored green if the close is above the pivot, red if below (only on the current trading day).
Bullish/Bearish Trend Label
A small table in the bottom-right corner displays “Bullish” or “Bearish” depending on whether price is above or below the pivot.
20-EMA Gradient Ribbon
A stack of 20 EMAs, each smoothed and color-coded from blue to green to reflect short- to long-term trend alignment.
Cumulative EMA with Adaptive Weighting
An intelligent moving average line that adjusts weight distribution among the 20 EMAs based on recent predictive accuracy using a learning rate and lookback period.
🧠 How It Works
📍 Levels
The script calculates daily pivot, resistance, and support levels using standard formulas:
Pivot = (High + Low + Close) / 3
Resistance = (2 × Pivot) – Low
Support = (2 × Pivot) – High
These levels update each day and extend 143 bars to the right.
📏 Fib Lines
Fib Up = Pivot + (Resistance – Pivot) × 0.382
Fib Down = Pivot – (Pivot – Support) × 0.382
These lines form the “no-trade zone” box.
📈 EMA Ribbon
20 EMAs starting from the user-defined Base Length, each incremented by 1
Each EMA is smoothed using the Smoothing Period
Color-coded from blue to green for intuitive visual flow
Filled between EMAs to visualize trend strength and alignment
🧠 Cumulative EMA Learning
Each EMA’s historical error is calculated over a Lookback Period
Lower-error EMAs receive higher weight; weights are normalized to sum to 1
The result is a cumulative EMA that adapts based on historical predictive power
🔧 User Inputs
Input
Base EMA Length: Sets the period for the shortest EMA (default: 20)
Smoothing Period: Smooths all EMAs and the cumulative EMA
Lookback for Learning: Number of bars to evaluate EMA prediction accuracy
Learning Rate: Adjusts how quickly weights shift in favor of more accurate EMAs
✅ How to Use It
Use the pivot level to define directional bias.
Watch for price breakouts above resistance or breakdowns below support to consider entry.
Avoid trading inside the shaded zone, where direction is less reliable.
Use the EMA ribbon gradient to confirm short/long alignment.
The cumulative EMA helps define trend with noise reduction.
🧪 Best For
Intraday traders who want to blend structure with flow
Swing traders needing clean daily levels with dynamic confirmation
Anyone looking to avoid choppy zones and improve visual clarity
⚠️ Disclaimer
This script is for educational and informational purposes only. It does not constitute financial advice or a trading recommendation. Always test scripts in simulation or on demo accounts before live use. Use at your own risk.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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.