OPEN-SOURCE SCRIPT

MTF Traffic Lights

61
## What this script does

**MTF Traffic Lights (4H / 1H / 15m / 5m / 3m / 1m) - Realtime ** is a compact multi-timeframe dashboard that shows, in one glance, whether each timeframe is:

- Bullish (green),
- Bearish (red),
- Or in disagreement / transition (yellow),

based on a consistent combination of **EMA 9/20 trend** and optional **MACD confirmation**.

The goal is to replace cluttered stacks of indicators with one clear “traffic light” panel that updates live and is easy to interpret.

---

## Core Logic

For each timeframe (4H, 1H, 15m, 5m, 3m, 1m):

1. **Trend via EMA 9/20**
- Fast EMA (default 9) vs Slow EMA (default 20).
- `EMA fast > EMA slow` → bullish structure on that timeframe.
- `EMA fast < EMA slow` → bearish structure.

2. **Momentum via MACD (optional)**
- Standard MACD (12, 26, 9 by default).
- Uses the MACD histogram sign as a confirmation filter.

3. **Traffic-light state**
- If **MACD filter ON**:
- **Green**: EMA bullish **and** MACD histogram ≥ 0.
- **Red**: EMA bearish **and** MACD histogram ≤ 0.
- **Yellow**: EMA and MACD do not agree → caution / transition.
- If **MACD filter OFF**:
- **Green**: EMA bullish.
- **Red**: EMA bearish.
- **Yellow**: EMAs essentially flat/indecisive.

4. **Realtime MTF behavior**
- Uses `request.security()` per timeframe.
- The **Intrabar HTF (LIVE)** option:
- When disabled (default): values are based on **confirmed closes** (no repaint).
- When enabled: higher timeframe values update intrabar using lookahead-on, so you can see evolving conditions; this is intentionally labeled as **repainting** behavior.

5. **Display**
- A fixed table in the top-right corner:
- Left column: timeframe labels (4H, 1H, 15m, 5m, 3m, 1m).
- Right column: a colored dot representing that timeframe’s current state.

No additional plots, shapes, or unrelated indicators are required.

---

## How to Use It

- Read the table **top to bottom** as a quick MTF alignment check:
- Mostly green → aligned bullish conditions across timeframes.
- Mostly red → aligned bearish conditions.
- Mixed / yellow → conflicting signals; consider standing down or zooming in.

- Combine with your own entries:
- Use it as a regime/confirmation layer for trend-following, ORB, or scalping systems.
- Filter trades to those aligned with higher timeframe conditions.

- Adjust inputs as needed:
- Change EMA or MACD parameters if your system uses different values.
- Toggle MACD filter off if you only want pure EMA 9/20 structure.

---

## Originality & Compliance Notes

- This script is a **single, focused tool**:
- A structured MTF state engine using consistent EMA + MACD logic.
- Presented as a compact table instead of multiple stacked indicators.
- It does **not** simply clone an existing open-source script one-to-one.
- The description explains:
- What each color means,
- How the calculations work,
- The effect of the LIVE/repaint option.

For publishing:
- Use a **clean chart** in the published example:
- Candles + this dashboard (and only essential elements) so its output is clear.
- Title uses standard ASCII characters, as required by the House Rules.

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.