PROTECTED SOURCE SCRIPT

Madstrat Strategy - Dual TF

71
# Madstrat Strategy - Dual TF: Complete User Guide

## Overview

The Madstrat Strategy indicator is a comprehensive forex trading system that identifies high-probability trade setups based on a day-counting methodology combined with multi-timeframe EMA alignment analysis. It generates two primary signal types:

1. **Day 3 Signals** - Based on the GSD/RSD (Green Setup Day/Red Setup Day) counting system
2. **Pure Price Action (PA) Signals** - Based on EMA alignment across multiple timeframes with EQ rejection

The indicator operates on **two timeframe combinations simultaneously**:
- **15-minute / 1-hour** combo
- **30-minute / 2-hour** combo

---

## Section 1: Timeframe Signals

### Settings

| Input | Default | Description |
|-------|---------|-------------|
| Show 15m/1hr Signals | ✓ Enabled | Displays signals from the 15-minute LTF with 1-hour HTF confirmation |
| Show 30m/2hr Signals | ✓ Enabled | Displays signals from the 30-minute LTF with 2-hour HTF confirmation |
| Trade Levels Source | Most Recent | Determines which combo draws SL/TP levels |

### How It Works

Each timeframe combination operates independently with its own:
- Signal spacing rules (4 bars for 15m, 2 bars for 30m = both equal ~1 hour)
- Daily signal limits (3 Day 3 signals + 3 Pure PA signals per combo per day)
- EMA alignment checks on both LTF and HTF

**Trade Levels Source Options:**
- **15m/1hr** - Only 15m/1hr signals draw trade levels
- **30m/2hr** - Only 30m/2hr signals draw trade levels
- **Most Recent** - Whichever signal fires most recently draws levels (15m/1hr takes priority if both fire simultaneously)

---

## Section 2: Signal Colors

Customize the appearance of each signal type for each timeframe combination:

### 15m/1hr Combo
| Signal Type | Default Color |
|-------------|---------------|
| Day 3 Buy | Blue |
| Day 3 Sell | Red |
| Pure PA Buy | Aqua |
| Pure PA Sell | Fuchsia |

### 30m/2hr Combo
| Signal Type | Default Color |
|-------------|---------------|
| Day 3 Buy | Teal |
| Day 3 Sell | Orange |
| Pure PA Buy | Lime |
| Pure PA Sell | Maroon |

---

## Section 3: Enhanced FBR Rules

### What is FBR?

**FBR (Failed Breakout Retest)** occurs when price breaks below the previous week's low (or above the previous week's high) but fails to close outside the range, closing back inside instead. This signals a potential reversal and resets the day count to "Day 1" of a new setup sequence.

### Settings

| Input | Default | Description |
|-------|---------|-------------|
| Enable Enhanced FBR Rule | ✓ Enabled | Prevents FBR detection after a clean breakout |
| Show Clean Breakout Labels | ✓ Enabled | Displays labels when clean breakouts occur |
| Bull Breakout Label Color | Blue (25% transparent) | Background color for bullish breakout labels |
| Bear Breakout Label Color | Red (25% transparent) | Background color for bearish breakout labels |

### How Enhanced FBR Works

1. **Clean Breakout Detection**: A clean breakout occurs when price breaks AND closes outside the previous week's range
2. **FBR Blocking**: Once a clean breakout occurs in a week, FBR detection is disabled for the remainder of that week
3. **Weekly Reset**: Both clean breakout and FBR flags reset at the start of each new trading week (Sunday rollover)

### Label Types
- **"CLEAN BULL BO"** - Price broke above previous week high and closed above it
- **"CLEAN BEAR BO"** - Price broke below previous week low and closed below it
- **"FBR Day 1"** - Failed breakout retest detected, count reset to Day 1

---

## Section 4: Real-Time Day Labels

### Purpose

The real-time label shows a **live projection** of what today's day classification will be, updating throughout the trading session as price action develops.

### Settings

| Input | Default | Description |
|-------|---------|-------------|
| Enable Real-Time Day Labels | ✓ Enabled | Shows dynamic label that updates during trading |
| Real-Time Label Position | Right | Position of label relative to current candle |
| Real-Time Label Background | Yellow (20% transparent) | Background color |
| Real-Time Label Text | White | Text color |

### Label Text Meanings

| Label | Meaning |
|-------|---------|
| LIVE: GSD Day X | Projected Green Setup Day (after 2+ red days) |
| LIVE: GD Day X | Projected Green Day (continuing green trend) |
| LIVE: RSD Day X | Projected Red Setup Day (after 2+ green days) |
| LIVE: RD Day X | Projected Red Day (continuing red trend) |
| LIVE: INSIDE DAY | Price range is entirely within previous day's range |
| LIVE: FBR - GSD Day 1 | Bullish failed breakout retest detected |
| LIVE: FBR - RSD Day 1 | Bearish failed breakout retest detected |
| LIVE: ... CLEAN BULL BO | Clean bullish breakout detected |
| LIVE: ... CLEAN BEAR BO | Clean bearish breakout detected |

---

## Section 5: Daily Session Definition

### Instrument Presets

| Preset | Sunday Open | Friday Close | Rollover | Use Case |
|--------|-------------|--------------|----------|----------|
| Forex (FX Pairs) | 17:05 ET | 16:59 ET | 17:00 ET | EUR/USD, GBP/USD, etc. |
| Metals (XAU/XAG) | 18:05 ET | 16:59 ET | 17:00 ET | Gold, Silver |
| Custom | User-defined | User-defined | User-defined | Other instruments |

### Why This Matters

The indicator uses **OANDA-style daily rollover** (5 PM Eastern) rather than UTC midnight. This ensures:
- Accurate day counting for forex markets
- Correct GSD/RSD classification
- Proper weekly level calculations

### Session Break Line

| Input | Default | Description |
|-------|---------|-------------|
| Show Session Break Line | ✓ Enabled | Draws vertical line at daily rollover |
| Session Break Line Color | Black | Line color |
| Width | 2 | Line thickness (1-5) |
| Style | Solid | Solid, dashed, or dotted |

---

## Section 6: Day Labels (GSD/RSD System)

### The Core Day Counting Methodology

This is the foundation of the Madstrat Strategy:

1. **Green Day (GD)**: Daily candle closes higher than it opened
2. **Red Day (RD)**: Daily candle closes lower than it opened
3. **Green Setup Day (GSD)**: A green day that follows 2 or more consecutive red days
4. **Red Setup Day (RSD)**: A red day that follows 2 or more consecutive green days

### The Day 3 Signal

**Day 3** is when the setup is "mature" and ready for a trade:
- **GSD Day 3**: Third consecutive green day after a red sequence of 2+ days
- **RSD Day 3**: Third consecutive red day after a green sequence of 2+ days

### Settings

| Input | Default | Description |
|-------|---------|-------------|
| Max Historical Labels | 60 | Number of day labels to retain on chart |
| Show Day of Week Labels | ✓ Enabled | Shows M O N, T U E, etc. |
| Label Position | Top | Top or bottom of chart |
| Label Hour | 6 | Hour (0-23) when day labels appear |
| GSD/GD Label Background | Blue (25% transparent) | Green day label color |
| RSD/RD Label Background | Red (25% transparent) | Red day label color |
| Inside Day Label Background | Gray (25% transparent) | Inside day label color |

### Important Notes

- **Inside Days** do not increment the count - they are neutral
- **FBR events** reset the count to Day 1 and establish a new trend direction
- **Clean Breakouts** also reset to Day 1 but block further FBR detection that week

---

## Section 7: Daily Levels

Displays the previous day's key price levels:

### Available Levels

| Level | Default | Description |
|-------|---------|-------------|
| Previous Day's High (PDH) | ✓ Enabled, Blue | Highest price of previous session |
| Previous Day's Low (PDL) | ✓ Enabled, Green | Lowest price of previous session |
| Previous Day's EQ | ✓ Enabled, Black | Equilibrium (midpoint of PDH/PDL) |
| 75% Level | ✗ Disabled | 75% of previous day's range |
| 25% Level | ✗ Disabled | 25% of previous day's range |

### EQ Rejection (Critical for Signals)

The **EQ (Equilibrium)** level is crucial for signal generation:
- **Bullish EQ Rejection**: Price wicks down to touch EQ, then closes above it
- **Bearish EQ Rejection**: Price wicks up to touch EQ, then closes below it

The indicator tracks these rejections throughout the day and uses them as a key filter for both Day 3 and Pure PA signals.

---

## Section 8: Weekly Levels

### Previous Week Levels

| Level | Description |
|-------|-------------|
| PWH (Previous Week High) | Highest price of the completed previous week |
| PWL (Previous Week Low) | Lowest price of the completed previous week |
| PWEQ (Previous Week EQ) | Midpoint of PWH and PWL |

### Current Week Levels

| Level | Description |
|-------|-------------|
| WH (Week High) | Running high of the current week |
| WL (Week Low) | Running low of the current week |
| WEQ (Week EQ) | Running midpoint of current week |

### Settings

| Input | Default | Description |
|-------|---------|-------------|
| Show Weekly Levels | ✓ Enabled | Master toggle for all weekly levels |
| Show Previous Week High/Low/EQ | ✓ Enabled | PWH, PWL, PWEQ lines |
| Previous Week Line Color | Black | Color for PW levels |
| Previous Week Line Width | 2 | Thickness of PW lines |
| Show Current Week High/Low | ✓ Enabled | WH, WL lines (dashed) |
| Current Week Line Color | Blue | Color for current week levels |
| Show Weekly Level Labels | ✓ Enabled | Text labels at line ends |
| Weekly Label Size | Normal | Tiny to Huge |
| Lines & Labels End Day | Friday | Extend lines to which day |

---

## Section 9: Session Overlays

Visual boxes showing major forex trading sessions:

### Available Sessions

| Session | Default Times (ET) | Default State |
|---------|-------------------|---------------|
| Sydney | 18:00 - 02:00 | ✗ Disabled |
| Asian | 19:00 - 04:15 | ✓ Enabled |
| London | 01:00 - 11:15 | ✓ Enabled |
| New York | 07:30 - 17:15 | ✓ Enabled |

### Customization Options

For each session:
- Start/End Hour and Minute
- Timezone
- Background color (with transparency)
- Border color
- Border style (solid, dashed, dotted)
- Border width

### General Session Settings

| Input | Default | Description |
|-------|---------|-------------|
| Show Session Overlays | ✓ Enabled | Master toggle |
| Show Session Names on Boxes | ✓ Enabled | Display "Sydney", "Asia", etc. |
| Session Box Border Width | 1 | Border thickness |
| Session Name Text Color | Black | Label text color |
| Session Name Size | Normal | Tiny to Huge |

---

## Section 10: Chart Visuals (Moving Averages)

### Available Moving Averages

| MA | Default | Default Color | Purpose |
|----|---------|---------------|---------|
| 9 EMA | ✓ Shown | Green | Fast trend |
| 18 EMA | ✓ Shown | Orange | Medium trend |
| 50 EMA | ✓ Shown | Blue | Slow trend |
| 50 SMA | ✓ Shown | Purple | Alternative slow trend |
| 200 EMA | ✗ Hidden | Red | Long-term trend |

### EMA Alignment Requirement

For signals to fire, the EMAs must be properly "stacked":

**Bullish Alignment:**
```
Price > 9 EMA > 18 EMA > 50 EMA
```

**Bearish Alignment:**
```
Price < 9 EMA < 18 EMA < 50 EMA
```

This alignment must be present on **both** the LTF (15m or 30m) **and** the HTF (1hr or 2hr) for a signal to generate.

---

## Section 11: Signal Filters

### EQ Rejection Recency

| Input | Default | Description |
|-------|---------|-------------|
| EQ Rejection Recency (bars) | 4 | EQ rejection must occur within this many bars |

On a 15-minute chart, 4 bars = 1 hour. This ensures the EQ rejection is "fresh" and relevant.

### Session Filter

| Input | Default | Description |
|-------|---------|-------------|
| Enable Session Filter | ✗ Disabled | Only allow signals during selected sessions |
| Allow Sydney Session Signals | ✓ Enabled | (Only applies if filter enabled) |
| Allow Asian Session Signals | ✓ Enabled | |
| Allow London Session Signals | ✓ Enabled | |
| Allow New York Session Signals | ✓ Enabled | |

### ADX Filter

| Input | Default | Description |
|-------|---------|-------------|
| Enable ADX Filter | ✓ Enabled | Require minimum trend strength |
| ADX Threshold | 20.0 | Minimum ADX value (5.0 - 50.0) |

The ADX (Average Directional Index) measures trend strength. Values above 20-25 indicate a trending market suitable for directional trades.

---

## Section 12: Signal Types Explained

### Day 3 Signals (Primary)

Day 3 signals come in two forms:

#### Day 3 Detected (Live)
Fires when the **current day is projected** to become Day 3 based on real-time price action. This is an early signal that may change if the daily candle reverses before close.

#### Day 3 Confirmed
Fires when Day 3 has been **officially confirmed** by the previous day's close. This is a more reliable signal as the day count is locked in.

**Requirements for Day 3 Buy:**
1. GSD Count = 3 (confirmed) OR Projected GSD Count = 3 (live)
2. Not an inside day (current or previous)
3. Recent bullish EQ rejection (within recency bars)
4. Bullish EMA alignment on LTF
5. Bullish EMA alignment on HTF
6. Adequate candle body (not all wick)
7. ADX above threshold (if enabled)
8. Within allowed session (if filter enabled)
9. Signal spacing requirement met
10. Less than 3 Day 3 signals already today for this combo

**Day 3 Sell** - Same requirements but bearish (RSD Count = 3, bearish alignment, bearish EQ rejection)

### Pure PA Signals (Secondary)

Pure PA signals also come in two forms:

#### Pure PA Detected (LTF Only)
Fires when the **lower timeframe conditions** are met but HTF confirmation is still pending. This is an early warning that a full signal may be imminent.

#### Pure PA Confirmed (LTF + HTF)
Fires when **both LTF and HTF** conditions are aligned. This is the full confirmation signal.

**Requirements for Pure PA Buy:**
1. Recent bullish EQ rejection
2. Bullish EMA alignment on LTF (Price > 9 > 18 > 50)
3. Bullish EMA alignment on HTF (Price > 9 > 18 > 50)
4. Adequate candle body ratio (≥30%)
5. ADX above threshold on LTF
6. Not currently an inside day
7. Signal spacing requirement met
8. Less than 3 Pure PA signals already today for this combo
9. Within allowed session (if filter enabled)

**Pure PA Sell** - Same requirements but bearish

---

## Section 13: Trade Levels

When a signal fires, the indicator can draw:

| Level | Style | Description |
|-------|-------|-------------|
| Stop Loss (SL) | Red dashed | Entry price ± (ATR × 1.5) |
| Take Profit 1 | Green dashed | 1:1 Risk/Reward |
| Take Profit 2 | Green dotted | 2:1 Risk/Reward |
| Take Profit 3 | Green dotted | 3:1 Risk/Reward |

These levels use a 14-period ATR for the stop loss calculation.

---

## Section 14: Debug Table

Enable **Show Debug Table** to display real-time diagnostic information:

### Information Displayed

| Category | Variables |
|----------|-----------|
| Day Counting | GSD Count, RSD Count, Projected GSD, Projected RSD |
| Day State | Is Projected D3?, Currently Inside?, Week Has FBR?, Clean Breakout (Week)? |
| 15m/1hr Combo | LTF Bull/Bear Positioning, HTF Bull/Bear Positioning, D3/PA Signals Today, Signal Spacing OK |
| 30m/2hr Combo | LTF Bull/Bear Positioning, HTF Bull/Bear Positioning, D3/PA Signals Today, Signal Spacing OK |
| Shared | EQ Rejection Recent (Bull/Bear), Session Filter OK, 15m ADX, 30m ADX, Trade Levels Source |

Green cells = condition met (true)
Red cells = condition not met (false)
Gray cells = informational values

---

## Section 15: Alert Settings

The indicator features a comprehensive **enhanced alert system** with granular control over when and how alerts fire.

### Alert Settings Inputs

| Input | Default | Description |
|-------|---------|-------------|
| Enable Dynamic Alerts | ✓ Enabled | Master toggle for all dynamic alerts with detailed messages |
| Day 3 Detected (Live) | ✓ Enabled | Alert when Day 3 is projected based on current price action |
| Day 3 Confirmed | ✓ Enabled | Alert when Day 3 is officially confirmed |
| Pure PA Detected (LTF) | ✓ Enabled | Alert when LTF conditions are met (early warning) |
| Pure PA Confirmed (LTF+HTF) | ✓ Enabled | Alert when both LTF and HTF conditions align |

### Alert Message Format

All dynamic alerts follow a standardized format for easy parsing:

```
TYPE | SYMBOL @ PRICE | DAY_CLASS | SESSION | DIRECTION | COMBO
```

**Example alerts:**
```
D3 DETECTED | EURUSD @ 1.08542 | GSD Day 3 | London | BUY | 15m/1hr
D3 CONFIRMED | GBPJPY @ 192.456 | RSD Day 3 | New York | SELL | 30m/2hr
PA DETECTED | XAUUSD @ 2345.67 | GSD Day 2 | Asian | BUY | 15m/1hr (LTF only)
PA CONFIRMED | EURJPY @ 164.123 | RSD Day 1 | London | SELL | 30m/2hr
```

### Alert Types Explained

| Alert Type | Meaning | Use Case |
|------------|---------|----------|
| **D3 DETECTED** | Day 3 projected based on current candle | Early entry opportunity; may invalidate if candle reverses |
| **D3 CONFIRMED** | Day 3 locked in from previous close | Higher confidence entry; day count is confirmed |
| **PA DETECTED** | LTF alignment met, waiting for HTF | Heads-up alert; prepare for potential entry |
| **PA CONFIRMED** | Both LTF and HTF aligned | Full confirmation; ready to execute |

### TradingView Alert Dialog Options

When creating an alert in TradingView, you'll see these condition options in the dropdown:

#### Day 3 Detected (Live Projection)
- D3 Detected: Buy 15m/1hr
- D3 Detected: Sell 15m/1hr
- D3 Detected: Buy 30m/2hr
- D3 Detected: Sell 30m/2hr

#### Day 3 Confirmed
- D3 Confirmed: Buy 15m/1hr
- D3 Confirmed: Sell 15m/1hr
- D3 Confirmed: Buy 30m/2hr
- D3 Confirmed: Sell 30m/2hr

#### Pure PA Detected (LTF Only)
- PA Detected: Buy 15m/1hr
- PA Detected: Sell 15m/1hr
- PA Detected: Buy 30m/2hr
- PA Detected: Sell 30m/2hr

#### Pure PA Confirmed (LTF + HTF)
- PA Confirmed: Buy 15m/1hr
- PA Confirmed: Sell 15m/1hr
- PA Confirmed: Buy 30m/2hr
- PA Confirmed: Sell 30m/2hr

#### Combined Alerts (Any Combo)
- D3 Detected: Any Buy
- D3 Detected: Any Sell
- D3 Confirmed: Any Buy
- D3 Confirmed: Any Sell
- PA Confirmed: Any Buy
- PA Confirmed: Any Sell

#### Master Alerts
- ALL Day 3: Any Buy
- ALL Day 3: Any Sell
- ALL PA: Any Buy
- ALL PA: Any Sell

### Setting Up Alerts

1. **Click the Alert icon** in TradingView (or press Alt+A)
2. **Select the indicator** "Madstrat Strategy - Dual TF"
3. **Choose the condition** from the dropdown (e.g., "D3 Confirmed: Any Buy")
4. **Configure notification options** (popup, email, webhook, etc.)
5. **Set alert name** and click "Create"

### Recommended Alert Configurations

**Conservative Approach:**
- Enable only "Day 3 Confirmed" and "PA Confirmed" alerts
- These fire after full confirmation on both timeframes

**Aggressive Approach:**
- Enable all alert types including "Detected" alerts
- Get early warnings but verify manually before entry

**Session-Specific:**
- Create separate alerts for each session you trade
- Use the session filter to limit when signals can fire

---

## Section 16: Signal Identification on Chart

| Shape | Text | Meaning |
|-------|------|---------|
| ▲ Triangle Up | D3-15 | Day 3 Buy from 15m/1hr combo |
| ▲ Triangle Up | D3-30 | Day 3 Buy from 30m/2hr combo |
| ▼ Triangle Down | D3-15 | Day 3 Sell from 15m/1hr combo |
| ▼ Triangle Down | D3-30 | Day 3 Sell from 30m/2hr combo |
| ◆ Diamond | PA-15 | Pure PA signal from 15m/1hr combo |
| ◆ Diamond | PA-30 | Pure PA signal from 30m/2hr combo |

---

## Quick Start Guide

### Recommended Setup for Forex

1. **Timeframe**: Apply indicator to a 15-minute chart
2. **Instrument Preset**: Select "Forex (FX Pairs)"
3. **Enable both** 15m/1hr and 30m/2hr signals initially
4. **Trade Levels Source**: "Most Recent"
5. **ADX Filter**: Enabled with threshold 20
6. **Alerts**: Enable "D3 Confirmed" and "PA Confirmed" for reliable signals

### Reading Signals

1. Look for **Day 3 signals** (triangles) as primary entries
2. Use **Pure PA signals** (diamonds) as supplementary entries
3. Check the debug table to understand why signals did/didn't fire
4. Reference the real-time day label to anticipate upcoming Day 3 opportunities

### Alert Strategy

**For active monitoring:**
- Enable "Detected" alerts as early warnings
- Manually verify conditions before entry

**For set-and-forget:**
- Enable only "Confirmed" alerts
- Trust the full confirmation system

---

## Troubleshooting

### No Signals Appearing?

Check the debug table for:
1. **EQ Rejection Recent** - Is there a recent EQ rejection?
2. **LTF/HTF Positioning** - Are EMAs properly aligned?
3. **GSD/RSD Count** - Is it actually Day 3?
4. **Currently Inside?** - Inside days block signals
5. **Signal Spacing OK** - Has enough time passed since last signal?
6. **ADX value** - Is it above the threshold?

### Day Labels Not Matching Expected Count?

- Verify **Instrument Preset** matches your trading instrument
- Check if an **FBR** or **Clean Breakout** reset the count
- **Inside days** don't increment the count
- Week resets occur at **Sunday 5 PM ET** for forex

### Alerts Not Firing?

1. Ensure **Enable Dynamic Alerts** is checked
2. Verify the specific alert type is enabled (D3 Detected, D3 Confirmed, etc.)
3. Check that the alert condition is properly set up in TradingView
4. Confirm signal filters (session, ADX) aren't blocking the signal

### Understanding Detected vs Confirmed

| Scenario | Detected Alert | Confirmed Alert |
|----------|----------------|-----------------|
| Current day projected to be Day 3, candle still open | ✓ Fires | ✗ Won't fire |
| Previous day closed as Day 3, conditions met today | ✓ May fire | ✓ Fires |
| LTF aligned, HTF not yet aligned | ✓ PA Detected fires | ✗ PA Confirmed won't fire |
| Both LTF and HTF aligned | ✓ May fire | ✓ PA Confirmed fires |

---

## Glossary

| Term | Definition |
|------|------------|
| **GSD** | Green Setup Day - Green day following 2+ red days |
| **RSD** | Red Setup Day - Red day following 2+ green days |
| **GD** | Green Day - Regular green day (not a setup) |
| **RD** | Red Day - Regular red day (not a setup) |
| **FBR** | Failed Breakout Retest - Price breaks weekly level but closes back inside |
| **EQ** | Equilibrium - Midpoint of previous day's range |
| **LTF** | Lower Timeframe (15m or 30m) |
| **HTF** | Higher Timeframe (1hr or 2hr) |
| **PWH/PWL** | Previous Week High/Low |
| **PDH/PDL** | Previous Day High/Low |
| **Clean Breakout** | Price breaks AND closes outside previous week's range |

---

This documentation covers the complete functionality of the Madstrat Strategy - Dual TF indicator including the enhanced alert system. For further assistance with specific scenarios or edge cases, enable the debug table and analyse the real-time variable states.

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.