OPEN-SOURCE SCRIPT

Structure Analysis + Hammer Alert

89
# Structure Resistance + Hammer Alert

## 📊 Indicator Overview
This indicator integrates Structure Breakout Analysis with Candlestick Pattern Recognition, helping traders identify market trend reversal points and strong momentum signals. Through visual markers and background colors, you can quickly grasp the bullish/bearish market structure.

---

## 🎯 Core Features

### 1️⃣ Structure Resistance System
- Auto-plot Previous High/Low: Automatically marks key support/resistance based on pivot points
- Structure Breakout Detection: Shows "BULL" when price breaks above previous high, "BEAR" when breaking below previous low
- Trend Background Color: Green background for bullish structure, red background for bearish structure

### 2️⃣ Bullish Momentum Candles (Hammer Patterns)
Detects candles with long lower shadows, indicating strong buying pressure at lows:
- 💪Strong Bull (Bullish Hammer): Green marker, bullish close with significant lower shadow
- 💪Weak Bull (Bearish Hammer): Teal marker, bearish close but strong lower shadow

### 3️⃣ Bearish Momentum Candles (Inverted Hammer/Shooting Star)
Detects candles with long upper shadows, indicating strong selling pressure at highs:
- 💪Weak Bear (Bullish Inverted Hammer): Orange marker, bullish close but significant upper shadow
- 💪Strong Bear (Shooting Star): Red marker, bearish close with significant upper shadow

### 4️⃣ Smart Marker Sizing
Markers automatically adjust size based on current trend:
- With-Trend Signals: Larger markers (e.g., hammer in bullish trend)
- Counter-Trend Signals: Smaller markers (e.g., shooting star in bullish trend)
- Neutral Trend: Medium-sized markers

---

## ⚙️ Parameter Settings

### Structure Resistance Parameters
- Swing Length: Default 5, higher values = clearer structure but fewer signals
- Show Lines/Labels: Toggle on/off options

### Bullish Momentum (Hammer) Parameters
- Lower Shadow/Body Ratio: Default 2.0, lower shadow must be 2x body size
- Upper Shadow/Body Ratio Limit: Default 0.2, upper shadow cannot be too long
- Body Position Ratio: Default 2.0, ensures body is at the top of candle

### Bearish Momentum (Inverted Hammer) Parameters
- Upper Shadow/Body Ratio: Default 2.0, upper shadow must be 2x body size
- Lower Shadow/Body Ratio Limit: Default 0.2, lower shadow cannot be too long
- Body Position Ratio: Default 2.0, ensures body is at the bottom of candle

### Filter & Display Settings
- Minimum Body Size: Filters out doji-like candles with tiny bodies
- Pattern Type Toggles: Show/hide different pattern types individually
- Background Transparency: Adjust background color intensity (higher = more transparent)
- Label Distance: Adjust marker distance from candles

---

## 📈 Usage Guidelines

### Trading Signal Interpretation

**Long Signals (Strongest to Weakest):**
1. Bullish Structure + Bullish Hammer (💪Strong Bull) → Strongest long signal
2. Bullish Structure + Bearish Hammer (💪Weak Bull) → Secondary long signal
3. Bearish Structure + Hammer → Potential reversal signal

**Short Signals (Strongest to Weakest):**
1. Bearish Structure + Shooting Star (💪Strong Bear) → Strongest short signal
2. Bearish Structure + Bullish Inverted Hammer (💪Weak Bear) → Secondary short signal
3. Bullish Structure + Shooting Star → Potential reversal signal

### Practical Tips
✅ Trend Following: Prioritize large marker signals (aligned with trend)
✅ Structure Confirmation: Wait for structure breakout before entry to avoid false breaks
✅ Multiple Timeframes: Confirm trend direction with higher timeframes
⚠️ Counter-Trend Caution: Small marker signals (counter-trend) require stricter risk management

---

## 🔔 Alert Setup

This indicator provides 9 alert conditions:
- Individual Patterns: Bullish Hammer, Bearish Hammer, Bullish Inverted Hammer, Shooting Star
- Combined Signals: Bullish Momentum, Bearish Momentum, Bull/Bear Momentum
- Structure Breakouts: Bullish Structure Break, Bearish Structure Break

---

## 💡 FAQ

**Q: Why do hammers sometimes appear without markers?**
A: Check "Minimum Body Size" setting - the candle body may be too small and filtered out

**Q: Too many or too few markers?**
A: Adjust "Lower Shadow/Body Ratio" or "Upper Shadow/Body Ratio" parameters - higher ratios = stricter conditions

**Q: How to see only the strongest signals?**
A: Disable "Bearish Hammer" and "Bullish Inverted Hammer", keep only "Bullish Hammer" and "Shooting Star"

**Q: Can it be used on all timeframes?**
A: Yes, but recommended for 15-minute and higher timeframes - shorter timeframes have more noise

---

## 📝 Disclaimer

⚠️ This indicator is a supplementary tool and should be used with other technical analysis methods

⚠️ Past performance does not guarantee future results - always practice proper risk management

⚠️ Recommended to test on demo account before live trading

---

**Version:** Pine Script v6
**Applicable Markets:** Stocks, Futures, Cryptocurrencies, and all markets

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.