OPEN-SOURCE SCRIPT

Trade The Matric / MACD-RSI Hybrid Candles

785
**"MACD-RSI Hybrid Candles"** is a **custom TradingView Pine Script (v6)** indicator that **replaces your chart’s default candles** with **dynamically colored, intensity-adjusted candles** based on **combined MACD and RSI signals**.

It’s a **visual fusion** of:
- **MACD Histogram** → Momentum & Trend Strength
- **RSI** → Overbought/Oversold & Trend Confirmation
- **Dynamic Transparency** → Visualizes **signal strength**

The result? **At-a-glance confirmation of bullish/bearish phases** — no need to check subcharts.

---

## OVERVIEW: What This Indicator Does

| Feature | Purpose |
|-------|--------|
| **Replaces price candles** | Entire chart becomes a **live MACD-RSI signal map** |
| **Colors based on dual confirmation** | Only strong when **both** MACD and RSI agree |
| **Transparency = momentum intensity** | Brighter = stronger signal |
| **Labels & Alerts** | Highlights **phase changes** (bullish/bearish shifts) |

---

## USER INPUTS (Customizable)

| Input | Default | Description |
|------|--------|-----------|
| `fastLen` | 12 | MACD Fast EMA |
| `slowLen` | 26 | MACD Slow EMA |
| `signalLen` | 9 | MACD Signal Line |
| `rsiLen` | 14 | RSI Period |
| `showLabels` | true | Show "Bullish Phase" / "Bearish Phase" labels |

> Standard settings — tweak for sensitivity.

---

## CORE CALCULATIONS

### 1. **MACD**
```pinescript
macdLine = ta.ema(close, fastLen) - ta.ema(close, slowLen)
signalLine = ta.ema(macdLine, signalLen)
hist = macdLine - signalLine
```
- `hist > 0` → **Bullish momentum**
- `hist < 0` → **Bearish momentum**

### 2. **RSI**
```pinescript
rsi = ta.rsi(close, rsiLen)
```
- `rsi > 50` → **Bullish bias**
- `rsi < 50` → **Bearish bias**

---

## DUAL CONFIRMATION LOGIC

| Condition | Meaning |
|--------|--------|
| `bullCond = macdBull and rsiBull` | **MACD hist > 0** AND **RSI > 50** → **Confirmed Bullish** |
| `bearCond = macdBear and rsiBear` | **MACD hist < 0** AND **RSI < 50** → **Confirmed Bearish** |
| Otherwise | **Neutral / Conflicted** |

> Only **strong, aligned signals** get bright colors.

---

## DYNAMIC INTENSITY & TRANSPARENCY (Key Feature)

```pinescript
maxHist = ta.highest(math.abs(hist), 100)
intensity = math.abs(hist) / maxHist
transp = 90 - (intensity * 80)
```

### How It Works:
1. Finds **strongest MACD histogram value** in last 100 bars
2. Compares **current histogram** to that peak → `intensity` (0 to 1)
3. **Transparency scales from 90 (faint) → 10 (bright)**

| Intensity | Transparency | Visual Effect |
|---------|--------------|-------------|
| 0% (weak) | 90 | Almost transparent |
| 50% | 50 | Medium |
| 100% | 10 | **Vivid, bold candle** |

> **Brighter candle = stronger momentum relative to recent history**

---

## CANDLE COLOR LOGIC

| Condition | Candle & Wick Color | Transparency |
|--------|---------------------|------------|
| **Confirmed Bullish** (`bullCond`) | **Lime Green** | Dynamic (10–90) |
| **Confirmed Bearish** (`bearCond`) | **Red** | Dynamic (10–90) |
| **Neutral / Conflicted** | **Gray** | Fixed 80 (faint) |

> **Wicks and borders match body** → full candle takeover

---

## VISUAL OUTPUT

### 1. **Custom Candles**
```pinescript
plotcandle(open, high, low, close, color=barColor, wickcolor=barColor, bordercolor=barColor)
```
- **Replaces default chart candles**
- **No original candles visible**

### 2. **Labels (Optional)**
- **"Bullish Phase"** → Green label **below low** when:
- MACD histogram **crosses above zero**
- AND RSI **> 50**
- **"Bearish Phase"** → Red label **above high** when:
- MACD histogram **crosses below zero**
- AND RSI **< 50**

> Up to **500 labels** (`max_labels_count=500`)

---

## ALERTS (Built-In)

| Alert | Trigger |
|------|--------|
| **Bullish MACD-RSI Signal** | `ta.crossover(hist, 0) and rsi > 50` |
| **Bearish MACD-RSI Signal** | `ta.crossunder(hist, 0) and rsi < 50` |

> Message: *"MACD crossed above zero with RSI > 50 — Bullish phase."*

---

## HOW TO READ THE CHART

| Visual | Market State | Interpretation |
|-------|-------------|----------------|
| **Bright Lime Candles** | **Strong Bullish Momentum** | High conviction — trend accelerating |
| **Faint Lime Candles** | **Weak Bullish** | Momentum present but not strong |
| **Bright Red Candles** | **Strong Bearish Momentum** | Downtrend with power |
| **Faint Red Candles** | **Weak Bearish** | Selling pressure, but fading |
| **Gray Candles** | **Conflicted / Choppy** | MACD and RSI disagree — avoid |
| **"Bullish Phase" Label** | **New Uptrend Starting** | Entry signal |
| **"Bearish Phase" Label** | **New Downtrend Starting** | Short signal |

---

## TRADING STRATEGY (Example)

### **Long Entry**
1. Wait for **"Bullish Phase" label**
2. Confirm **bright lime candles** (intensity > 50%)
3. Enter on **pullback to support** or **breakout**
4. **Stop Loss**: Below recent swing low
5. **Take Profit**: Trail with EMA or at resistance

### **Short Entry**
1. Wait for **"Bearish Phase" label**
2. Confirm **bright red candles**
3. Enter on **rally to resistance**

> **Best in trending markets** — avoid choppy ranges.

---

## UNIQUE FEATURES

| Feature | Benefit |
|-------|--------|
| **Dual Confirmation** | Avoids false MACD signals in overbought/oversold zones |
| **Dynamic Transparency** | Shows **relative strength** — not just direction |
| **Full Candle Replacement** | Clean, uncluttered chart |
| **Phase Labels** | Marks **exact trend change points** |
| **Built-in Alerts** | No extra setup needed |

---

## LIMITATIONS

| Issue | Note |
|------|------|
| **Lagging by design** | MACD & RSI are reactive |
| **Repainting?** | **No** — all on close |
| **No volume filter** | Add separately for better accuracy |
| **Labels can clutter** | Toggle off in choppy markets |
| **Intensity uses 100-bar lookback** | May lag in very long trends |

---

## BEST USE CASES

| Market | Timeframe | Style |
|-------|----------|------|
| Stocks, Forex, Crypto | 15m, 1H, 4H | Swing / Trend Following |
| **Avoid**: Sideways markets | Yes | High noise = many gray candles |

---

## COMPARISON TO STANDARD MACD/RSI

| Feature | This Indicator | Standard MACD + RSI |
|-------|----------------|---------------------|
| Visual | **Candles = signal** | Subchart lines |
| Confirmation | Built-in dual logic | Manual |
| Strength | Dynamic brightness | Histogram height |
| Alerts | Phase changes | Need custom |
| Chart Clutter | Low | High (two panels) |

> **This is a "one-panel" momentum dashboard**

---

## SUMMARY: What This Indicator Does

> **"MACD-RSI Hybrid Candles"** turns your **entire price chart into a live momentum heatmap** where:
>
> 1. **Candle color** = **MACD + RSI agreement** (Bullish / Bearish / Neutral)
> 2. **Brightness** = **Momentum strength** vs. recent 100 bars
> 3. **Labels & Alerts** = **Trend phase changes** (zero-line crosses with RSI filter)
>
> It **eliminates subcharts** and gives **instant visual confirmation** of:
> - **Trend direction**
> - **Momentum power**
> - **High-probability entries**

---

**Ideal for traders who want:**
- **No indicator panels**
- **Clear, color-coded signals**
- **Strength at a glance**
- **Automated alerts on trend shifts**

---

**Pro Tip**: Use with **volume** or **support/resistance** for **higher win rate**.

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.