PROTECTED SOURCE SCRIPT
DisplacementAndPinBar [TFO]

# DisplacementAndPinBar v1.5 - Advanced Market Structure Indicator
## Overview
DisplacementAndPinBar v1.5 is a sophisticated technical indicator that combines displacement detection with advanced pin bar analysis to identify high-probability trading opportunities. Unlike traditional pin bar indicators that create chart clutter with insignificant signals, this indicator uses mathematical filtering to show only meaningful market structure patterns.
## Key Features
### 🎯 **True Pin Bar Detection**
- **Level Rejection Logic**: Pin bars must break recent highs/lows (adjustable lookback period)
- **Statistical Significance**: Uses standard deviation to filter candle size
- **Smart Classification**: Distinguishes between true pin bars and momentum impulse candles
- **Visual Clarity**: Green/red circles with "PIN" text for easy identification
### 📈 **Displacement Detection**
- **Momentum Identification**: Detects large body candles showing strong directional movement
- **Open-to-Close Analysis**: Measures true momentum (not just volatility)
- **Objective Filtering**: Uses standard deviation over customizable lookback period
- **Market Structure**: Identifies significant shifts in buying/selling pressure
### ⚡ **Advanced Signal Types**
#### 1. Pin Bar Signals
- **Bullish Pin Bars**: Long lower wicks rejecting at key support levels
- **Bearish Pin Bars**: Long upper wicks rejecting at key resistance levels
- **Requirements**: Must break recent 20-candle highs/lows + meet wick-to-body ratios
#### 2. Confirmation Signals
- **Follow-Through Detection**: Validates pin bar signals with directional movement
- **Smart Filtering**: Requires proper body size and minimal opposing wicks
- **Visual**: Large yellow/pink triangles (semi-transparent)
#### 3. Displacement Momentum Signals
- **Continuation Pattern**: Two displacement candles in same direction within timeframe
- **No Opposing Signal**: Ensures clean momentum without conflicting moves
- **Trade Signal**: Huge yellow/pink triangles indicating strong momentum building
#### 4. Impulse & Indecision Detection
- **Impulse Candles**: Large wicks without level rejection (gray triangles)
- **Indecision Patterns**: Range-bound rejection patterns (gray diamonds)
- **Context Awareness**: Helps understand market state and volatility
## Technical Specifications
### Mathematical Foundation
- **Standard Deviation Filtering**: Eliminates noise by requiring statistical significance
- **Historical Comparison**: Manual loop calculations for reliable level detection
- **Independent Criteria**: Pin bars use High-to-Low, Displacement uses Open-to-Close
- **Multi-Timeframe Logic**: Optimized for 5-minute charts but works on all timeframes
### Default Settings (Optimized for 5-minute)
- **Displacement Length**: 40 periods
- **Displacement Strength**: 4.0x standard deviation
- **Pin Bar Lookback**: 20 periods
- **Pin Bar Body-to-Wick Ratio**: 4.0
- **Displacement Signal Lookback**: 6 periods
- **FVG Requirement**: OFF (recommended for optimal signals)
## Visual Hierarchy
### Signal Priority (Most to Least Important)
1. **🔴🟢 PIN Circles**: True pin bars at key levels (highest probability reversals)
2. **🔺 Huge Triangles**: Displacement momentum signals (strong continuation)
3. **🔺 Large Triangles**: Pin bar confirmations (validation signals)
4. **🔺 Small Triangles**: Impulse patterns (momentum without level interaction)
5. **💎 Diamonds**: Indecision at range extremes
6. **🟡🟣 Colored Candles**: Base displacement detection
### Visual Enhancements
- **Semi-Transparent Triangles**: Prevents hiding pin bar signals when zoomed out
- **Black Text on Circles**: Enhanced readability
- **Size Differentiation**: Clear hierarchy through symbol sizing
- **Color Coding**: Intuitive green/red for direction, blue for momentum
## Trading Applications
### Reversal Trading
- **Pin Bar Entries**: High-probability reversals at key support/resistance
- **Confirmation Required**: Wait for follow-through triangle for validation
- **Stop Placement**: Just beyond pin bar wick for optimal risk/reward
### Momentum Trading
- **Displacement Signals**: Trade continuation when two displacement candles align
- **Trend Following**: Excellent for catching momentum shifts and breakouts
- **Multiple Timeframes**: Combine with higher timeframe bias for best results
### Market Context
- **Impulse Analysis**: Understand when market is in momentum vs. consolidation
- **Indecision Patterns**: Identify range-bound conditions and potential breakouts
- **Volume Confirmation**: Displacement often coincides with volume spikes
## Alert System
Comprehensive alert functionality for all major signals:
- Bullish/Bearish Pin Bar detection
- Pin Bar confirmation signals
- Displacement momentum signals
- Customizable alert messages with context
## Settings Organization
### 🎯 Trading Signals (Priority Settings)
- Displacement trade signal toggle and lookback period
- Pin bar and confirmation detection toggles
### 📊 Core Settings Groups
- **Displacement Settings**: Length, strength, FVG requirements
- **Pin Bar Settings**: Lookback periods, ratios, thresholds
- **Visual Settings**: Colors and display preferences
### 💡 Helpful Tooltips
- Detailed explanations for each setting
- Optimization recommendations
- Best practices for different timeframes
## Why This Indicator is Different
### ❌ **What Most Pin Bar Indicators Do Wrong**
- Show every candle with long wicks (creates noise)
- No context about market structure or significance
- Fixed parameters that don't adapt to volatility
- No distinction between rejection and momentum patterns
### ✅ **What DisplacementAndPinBar v1.5 Does Right**
- **Quality Over Quantity**: Only shows statistically significant patterns
- **Market Structure Awareness**: Considers recent highs/lows and volatility
- **Multiple Signal Types**: Comprehensive pattern recognition
- **Visual Clarity**: Clean, organized display with logical hierarchy
- **Professional Features**: Proper alerts, settings organization, documentation
## Best Practices
### Timeframe Recommendations
- **Primary**: 5-minute charts (optimized settings)
- **Secondary**: 15-minute and 1-hour for confirmation
- **Scalping**: 1-minute with adjusted sensitivity
### Market Application
- **Forex**: Excellent during London/NY sessions
- **Crypto**: Particularly effective on Bitcoin and major altcoins
- **Stocks**: Works well on liquid stocks and indices
- **Futures**: Optimal on high-volume contracts
### Risk Management
- **Stop Losses**: Use pin bar wicks and displacement candle extremes
- **Position Sizing**: Reduce size in low-probability setups
- **Confirmation**: Wait for follow-through signals when possible
- **Context**: Consider higher timeframe trends and major support/resistance
## Version History
- **v1.1**: Initial pin bar and displacement integration
- **v1.3**: Added confirmation logic and refined indecision detection
- **v1.5**: Added displacement momentum signals, organized settings, comprehensive alerts
## Credits
Based on original displacement work by tradeforopp, enhanced with advanced pin bar detection and signal classification by AleksandarPesic & Claude (Anthropic).
---
*DisplacementAndPinBar v1.5 represents a new standard in technical analysis, combining mathematical rigor with practical trading applications. Perfect for traders who want quality signals without the noise.*
## Overview
DisplacementAndPinBar v1.5 is a sophisticated technical indicator that combines displacement detection with advanced pin bar analysis to identify high-probability trading opportunities. Unlike traditional pin bar indicators that create chart clutter with insignificant signals, this indicator uses mathematical filtering to show only meaningful market structure patterns.
## Key Features
### 🎯 **True Pin Bar Detection**
- **Level Rejection Logic**: Pin bars must break recent highs/lows (adjustable lookback period)
- **Statistical Significance**: Uses standard deviation to filter candle size
- **Smart Classification**: Distinguishes between true pin bars and momentum impulse candles
- **Visual Clarity**: Green/red circles with "PIN" text for easy identification
### 📈 **Displacement Detection**
- **Momentum Identification**: Detects large body candles showing strong directional movement
- **Open-to-Close Analysis**: Measures true momentum (not just volatility)
- **Objective Filtering**: Uses standard deviation over customizable lookback period
- **Market Structure**: Identifies significant shifts in buying/selling pressure
### ⚡ **Advanced Signal Types**
#### 1. Pin Bar Signals
- **Bullish Pin Bars**: Long lower wicks rejecting at key support levels
- **Bearish Pin Bars**: Long upper wicks rejecting at key resistance levels
- **Requirements**: Must break recent 20-candle highs/lows + meet wick-to-body ratios
#### 2. Confirmation Signals
- **Follow-Through Detection**: Validates pin bar signals with directional movement
- **Smart Filtering**: Requires proper body size and minimal opposing wicks
- **Visual**: Large yellow/pink triangles (semi-transparent)
#### 3. Displacement Momentum Signals
- **Continuation Pattern**: Two displacement candles in same direction within timeframe
- **No Opposing Signal**: Ensures clean momentum without conflicting moves
- **Trade Signal**: Huge yellow/pink triangles indicating strong momentum building
#### 4. Impulse & Indecision Detection
- **Impulse Candles**: Large wicks without level rejection (gray triangles)
- **Indecision Patterns**: Range-bound rejection patterns (gray diamonds)
- **Context Awareness**: Helps understand market state and volatility
## Technical Specifications
### Mathematical Foundation
- **Standard Deviation Filtering**: Eliminates noise by requiring statistical significance
- **Historical Comparison**: Manual loop calculations for reliable level detection
- **Independent Criteria**: Pin bars use High-to-Low, Displacement uses Open-to-Close
- **Multi-Timeframe Logic**: Optimized for 5-minute charts but works on all timeframes
### Default Settings (Optimized for 5-minute)
- **Displacement Length**: 40 periods
- **Displacement Strength**: 4.0x standard deviation
- **Pin Bar Lookback**: 20 periods
- **Pin Bar Body-to-Wick Ratio**: 4.0
- **Displacement Signal Lookback**: 6 periods
- **FVG Requirement**: OFF (recommended for optimal signals)
## Visual Hierarchy
### Signal Priority (Most to Least Important)
1. **🔴🟢 PIN Circles**: True pin bars at key levels (highest probability reversals)
2. **🔺 Huge Triangles**: Displacement momentum signals (strong continuation)
3. **🔺 Large Triangles**: Pin bar confirmations (validation signals)
4. **🔺 Small Triangles**: Impulse patterns (momentum without level interaction)
5. **💎 Diamonds**: Indecision at range extremes
6. **🟡🟣 Colored Candles**: Base displacement detection
### Visual Enhancements
- **Semi-Transparent Triangles**: Prevents hiding pin bar signals when zoomed out
- **Black Text on Circles**: Enhanced readability
- **Size Differentiation**: Clear hierarchy through symbol sizing
- **Color Coding**: Intuitive green/red for direction, blue for momentum
## Trading Applications
### Reversal Trading
- **Pin Bar Entries**: High-probability reversals at key support/resistance
- **Confirmation Required**: Wait for follow-through triangle for validation
- **Stop Placement**: Just beyond pin bar wick for optimal risk/reward
### Momentum Trading
- **Displacement Signals**: Trade continuation when two displacement candles align
- **Trend Following**: Excellent for catching momentum shifts and breakouts
- **Multiple Timeframes**: Combine with higher timeframe bias for best results
### Market Context
- **Impulse Analysis**: Understand when market is in momentum vs. consolidation
- **Indecision Patterns**: Identify range-bound conditions and potential breakouts
- **Volume Confirmation**: Displacement often coincides with volume spikes
## Alert System
Comprehensive alert functionality for all major signals:
- Bullish/Bearish Pin Bar detection
- Pin Bar confirmation signals
- Displacement momentum signals
- Customizable alert messages with context
## Settings Organization
### 🎯 Trading Signals (Priority Settings)
- Displacement trade signal toggle and lookback period
- Pin bar and confirmation detection toggles
### 📊 Core Settings Groups
- **Displacement Settings**: Length, strength, FVG requirements
- **Pin Bar Settings**: Lookback periods, ratios, thresholds
- **Visual Settings**: Colors and display preferences
### 💡 Helpful Tooltips
- Detailed explanations for each setting
- Optimization recommendations
- Best practices for different timeframes
## Why This Indicator is Different
### ❌ **What Most Pin Bar Indicators Do Wrong**
- Show every candle with long wicks (creates noise)
- No context about market structure or significance
- Fixed parameters that don't adapt to volatility
- No distinction between rejection and momentum patterns
### ✅ **What DisplacementAndPinBar v1.5 Does Right**
- **Quality Over Quantity**: Only shows statistically significant patterns
- **Market Structure Awareness**: Considers recent highs/lows and volatility
- **Multiple Signal Types**: Comprehensive pattern recognition
- **Visual Clarity**: Clean, organized display with logical hierarchy
- **Professional Features**: Proper alerts, settings organization, documentation
## Best Practices
### Timeframe Recommendations
- **Primary**: 5-minute charts (optimized settings)
- **Secondary**: 15-minute and 1-hour for confirmation
- **Scalping**: 1-minute with adjusted sensitivity
### Market Application
- **Forex**: Excellent during London/NY sessions
- **Crypto**: Particularly effective on Bitcoin and major altcoins
- **Stocks**: Works well on liquid stocks and indices
- **Futures**: Optimal on high-volume contracts
### Risk Management
- **Stop Losses**: Use pin bar wicks and displacement candle extremes
- **Position Sizing**: Reduce size in low-probability setups
- **Confirmation**: Wait for follow-through signals when possible
- **Context**: Consider higher timeframe trends and major support/resistance
## Version History
- **v1.1**: Initial pin bar and displacement integration
- **v1.3**: Added confirmation logic and refined indecision detection
- **v1.5**: Added displacement momentum signals, organized settings, comprehensive alerts
## Credits
Based on original displacement work by tradeforopp, enhanced with advanced pin bar detection and signal classification by AleksandarPesic & Claude (Anthropic).
---
*DisplacementAndPinBar v1.5 represents a new standard in technical analysis, combining mathematical rigor with practical trading applications. Perfect for traders who want quality signals without the noise.*
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
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.
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
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.