PROTECTED SOURCE SCRIPT
HM2 - Swing Low High 1-2

# HM2 Swing Low High 1-2 Indicator Logic Description
## Overview
This indicator identifies and tracks key swing points in price action, specifically maintaining four critical levels: **SL1, SL2, SH1, and SH2**. These levels represent a hierarchy of support and resistance based on recent price swings.
## Core Logic
### Swing Point Detection
The indicator uses a **symmetrical swing detection method**:
- **Swing Length Parameter**: Defines how many candles on each side of a potential swing point must be higher (for lows) or lower (for highs)
- **Confirmation**: Only processes confirmed/closed candles to avoid repainting
- **Lookback Buffer**: Waits for adequate price history before making determinations
### The Four Key Levels
#### **SL1 (Swing Low 1) - Most Recent Low**
- The most recently formed swing low
- Always the latest confirmed low point in the price structure
- Updates whenever a new swing low is detected
#### **SL2 (Swing Low 2) - Lower Reference Low**
- The most recent swing low that is **below** SL1
- Must be lower in price than SL1 (deeper support level)
- Provides context for the support structure below current levels
#### **SH1 (Swing High 1) - Most Recent High**
- The most recently formed swing high
- Always the latest confirmed high point in the price structure
- Updates whenever a new swing high is detected
#### **SH2 (Swing High 2) - Higher Reference High**
- The highest swing high that is **above** SH1
- Must be higher in price than SH1 (stronger resistance level)
- Represents the most significant resistance overhead
## Key Features
### Smart Level Management
- **Array-Based Storage**: Maintains up to 50 recent swing points for performance optimization
- **Duplicate Prevention**: Prevents the same bar from being recorded multiple times
- **Hierarchy Enforcement**: SL2 must be below SL1, and SH2 must be above SH1
### Visual Elements
- **Horizontal Lines**: Draw from the swing point to current price with customizable extension
- **Background Plots**: Subtle reference lines for all four levels
- **Labels**: Clear "SL1", "SL2", "SH1", "SH2" labels positioned to the right of current price
- **Detection Markers**: Small triangular markers show when new swing points are detected
### Customization Options
- **Swing Length**: Adjustable sensitivity (1-10 candles)
- **Visual Controls**: Toggle labels and lines on/off
- **Line Extension**: Choose how lines extend (none, right, or both directions)
- **Color Customization**: Separate colors for lows (default red) and highs (default green)
## Practical Application
This indicator is particularly useful for:
- **Support/Resistance Trading**: The four levels provide clear zones for potential reversals
- **Trend Analysis**: Understanding the relationship between recent highs and lows
- **Entry/Exit Planning**: Using the hierarchy of levels for stop-loss and target placement
- **Market Structure**: Visualizing the current swing structure in any timeframe
The indicator automatically updates as new swing points form, ensuring traders always have the most current and relevant support/resistance levels based on actual price structure rather than arbitrary technical levels.
## Overview
This indicator identifies and tracks key swing points in price action, specifically maintaining four critical levels: **SL1, SL2, SH1, and SH2**. These levels represent a hierarchy of support and resistance based on recent price swings.
## Core Logic
### Swing Point Detection
The indicator uses a **symmetrical swing detection method**:
- **Swing Length Parameter**: Defines how many candles on each side of a potential swing point must be higher (for lows) or lower (for highs)
- **Confirmation**: Only processes confirmed/closed candles to avoid repainting
- **Lookback Buffer**: Waits for adequate price history before making determinations
### The Four Key Levels
#### **SL1 (Swing Low 1) - Most Recent Low**
- The most recently formed swing low
- Always the latest confirmed low point in the price structure
- Updates whenever a new swing low is detected
#### **SL2 (Swing Low 2) - Lower Reference Low**
- The most recent swing low that is **below** SL1
- Must be lower in price than SL1 (deeper support level)
- Provides context for the support structure below current levels
#### **SH1 (Swing High 1) - Most Recent High**
- The most recently formed swing high
- Always the latest confirmed high point in the price structure
- Updates whenever a new swing high is detected
#### **SH2 (Swing High 2) - Higher Reference High**
- The highest swing high that is **above** SH1
- Must be higher in price than SH1 (stronger resistance level)
- Represents the most significant resistance overhead
## Key Features
### Smart Level Management
- **Array-Based Storage**: Maintains up to 50 recent swing points for performance optimization
- **Duplicate Prevention**: Prevents the same bar from being recorded multiple times
- **Hierarchy Enforcement**: SL2 must be below SL1, and SH2 must be above SH1
### Visual Elements
- **Horizontal Lines**: Draw from the swing point to current price with customizable extension
- **Background Plots**: Subtle reference lines for all four levels
- **Labels**: Clear "SL1", "SL2", "SH1", "SH2" labels positioned to the right of current price
- **Detection Markers**: Small triangular markers show when new swing points are detected
### Customization Options
- **Swing Length**: Adjustable sensitivity (1-10 candles)
- **Visual Controls**: Toggle labels and lines on/off
- **Line Extension**: Choose how lines extend (none, right, or both directions)
- **Color Customization**: Separate colors for lows (default red) and highs (default green)
## Practical Application
This indicator is particularly useful for:
- **Support/Resistance Trading**: The four levels provide clear zones for potential reversals
- **Trend Analysis**: Understanding the relationship between recent highs and lows
- **Entry/Exit Planning**: Using the hierarchy of levels for stop-loss and target placement
- **Market Structure**: Visualizing the current swing structure in any timeframe
The indicator automatically updates as new swing points form, ensuring traders always have the most current and relevant support/resistance levels based on actual price structure rather than arbitrary technical levels.
Skrip dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya dengan percuma dan tanpa had – ketahui lebih lanjut di sini.
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 dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya dengan percuma dan tanpa had – ketahui lebih lanjut di sini.
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.