OPEN-SOURCE SCRIPT
Pivot Distance Strategy

# Multi-Timeframe Pivot Distance Strategy
## Core Innovation & Originality
This strategy revolutionizes moving average crossover trading by applying MA logic to **pivot distance relationships** instead of raw price data. Unlike traditional MA crossovers that react to price changes, this system reacts to **structural momentum changes** in how current price relates to recent significant pivot levels, creating earlier signals with fewer false positives.
## Methodology & Mathematical Foundation
### Pivot Distance Oscillator
The strategy calculates:
- **High Pivot Percentage**: (Current Close / Last Pivot High) × 100
- **Low Pivot Percentage**: (Last Pivot Low / Current Close) × 100
- **Pivot Distance**: High Pivot Percentage - Low Pivot Percentage
This creates a standardized oscillator measuring market structure compression/expansion regardless of asset price or volatility.
### Multi-Timeframe Filter
Higher timeframe analysis provides directional bias:
- **HTF Long** → Allow long entries, force short exits
- **HTF Short** → Allow short entries, force long exits
- **HTF Squeeze** → Block all entries, force all exits
## Signal Generation Methods
### Method 1: Dual MA Crossover (Primary/Default)
**Fast MA (14 EMA)** and **Slow MA (50 SMA)** applied to pivot distance values:
- **Long Signal**: Fast MA crosses above Slow MA (accelerating bullish pivot momentum)
- **Short Signal**: Fast MA crosses below Slow MA (accelerating bearish pivot momentum)
**Key Advantage**:
- Traditional: Fast MA(price) crosses Slow MA(price) - reacts to price changes
- This Strategy: Fast MA(pivot distance) crosses Slow MA(pivot distance) - reacts to structural changes
- Result: Earlier signals, better trend identification, fewer ranging market whipsaws
### Method 2: MA Cross Zero
- **Long**: Pivot Distance MA crosses above zero
- **Short**: Pivot Distance MA crosses below zero
### Method 3: Pivot Distance Breakout (Squeeze-Based)
Uses dynamic threshold envelopes to detect compression/expansion cycles:
- **Long**: Distance breaks above dynamic breakout threshold after squeeze
- **Short**: Distance breaks below negative breakout threshold after squeeze
**Note**: Only the Breakout method uses threshold envelopes; MA Cross modes operate without them for cleaner signals.
## Risk Management Integration
- **ATR-Based Stops**: Entry ± (ATR × Multiplier) for stops/targets
- **Trailing Stops**: Dynamic adjustment based on profit thresholds
- **Cooldown System**: Prevents overtrading after stop-loss exits
## How to Use
### Setup (Default: MA Cross MA)
1. **Strategy Logic**: "MA Cross MA" for structural momentum signals
2. **MA Settings**: 14 EMA (fast) / 50 SMA (slow) - both adjustable
3. **Multi-Timeframe**: Enable HTF for trend alignment
4. **Risk Management**: ATR stop loss, ATR take profit
### Signal Interpretation
- **Blue/Purple lines**: Fast/Slow MAs of pivot distance
- **Green/Red histogram**: Positive/negative pivot distance
- **Triangle markers**: MA crossover entry signals
- **HTF display**: Shows higher timeframe bias (top-left)
### Trade Management
- **Entry**: Clean MA crossover with HTF alignment
- **Exit**: Opposite crossover, HTF change, or risk management triggers
## Unique Advantages
1. **Structural vs Price Momentum**: Captures market structure changes rather than just price movement, naturally filtering noise
2. **Multi-Modal Flexibility**: Three signal methods for different market conditions or strategies
3. **Timeframe Alignment**: HTF filtering improves win rates by preventing counter-trend trades
## Core Innovation & Originality
This strategy revolutionizes moving average crossover trading by applying MA logic to **pivot distance relationships** instead of raw price data. Unlike traditional MA crossovers that react to price changes, this system reacts to **structural momentum changes** in how current price relates to recent significant pivot levels, creating earlier signals with fewer false positives.
## Methodology & Mathematical Foundation
### Pivot Distance Oscillator
The strategy calculates:
- **High Pivot Percentage**: (Current Close / Last Pivot High) × 100
- **Low Pivot Percentage**: (Last Pivot Low / Current Close) × 100
- **Pivot Distance**: High Pivot Percentage - Low Pivot Percentage
This creates a standardized oscillator measuring market structure compression/expansion regardless of asset price or volatility.
### Multi-Timeframe Filter
Higher timeframe analysis provides directional bias:
- **HTF Long** → Allow long entries, force short exits
- **HTF Short** → Allow short entries, force long exits
- **HTF Squeeze** → Block all entries, force all exits
## Signal Generation Methods
### Method 1: Dual MA Crossover (Primary/Default)
**Fast MA (14 EMA)** and **Slow MA (50 SMA)** applied to pivot distance values:
- **Long Signal**: Fast MA crosses above Slow MA (accelerating bullish pivot momentum)
- **Short Signal**: Fast MA crosses below Slow MA (accelerating bearish pivot momentum)
**Key Advantage**:
- Traditional: Fast MA(price) crosses Slow MA(price) - reacts to price changes
- This Strategy: Fast MA(pivot distance) crosses Slow MA(pivot distance) - reacts to structural changes
- Result: Earlier signals, better trend identification, fewer ranging market whipsaws
### Method 2: MA Cross Zero
- **Long**: Pivot Distance MA crosses above zero
- **Short**: Pivot Distance MA crosses below zero
### Method 3: Pivot Distance Breakout (Squeeze-Based)
Uses dynamic threshold envelopes to detect compression/expansion cycles:
- **Long**: Distance breaks above dynamic breakout threshold after squeeze
- **Short**: Distance breaks below negative breakout threshold after squeeze
**Note**: Only the Breakout method uses threshold envelopes; MA Cross modes operate without them for cleaner signals.
## Risk Management Integration
- **ATR-Based Stops**: Entry ± (ATR × Multiplier) for stops/targets
- **Trailing Stops**: Dynamic adjustment based on profit thresholds
- **Cooldown System**: Prevents overtrading after stop-loss exits
## How to Use
### Setup (Default: MA Cross MA)
1. **Strategy Logic**: "MA Cross MA" for structural momentum signals
2. **MA Settings**: 14 EMA (fast) / 50 SMA (slow) - both adjustable
3. **Multi-Timeframe**: Enable HTF for trend alignment
4. **Risk Management**: ATR stop loss, ATR take profit
### Signal Interpretation
- **Blue/Purple lines**: Fast/Slow MAs of pivot distance
- **Green/Red histogram**: Positive/negative pivot distance
- **Triangle markers**: MA crossover entry signals
- **HTF display**: Shows higher timeframe bias (top-left)
### Trade Management
- **Entry**: Clean MA crossover with HTF alignment
- **Exit**: Opposite crossover, HTF change, or risk management triggers
## Unique Advantages
1. **Structural vs Price Momentum**: Captures market structure changes rather than just price movement, naturally filtering noise
2. **Multi-Modal Flexibility**: Three signal methods for different market conditions or strategies
3. **Timeframe Alignment**: HTF filtering improves win rates by preventing counter-trend trades
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.