PROTECTED SOURCE SCRIPT
Momentum Pull Back Stratergy

"Master Pull Back Strategy" is a highly detailed momentum and volume-based trading system designed for Trading View. It visually annotates the chart, detects buy/sell signals, tracks market phases, and evaluates retracements and confirmations. Below is a full breakdown of its logic and components:
🔷 1. Volume Profile Highlights (Arrow Emojis)
Purpose: Show volume strength vs. average using color-coded arrows.
Calculates average volume over a user-defined period (length = 10).
Divides current volume by average volume to get volRatio.
Based on volRatio, plots small arrows (acting like diamonds) in various colors:
Low volume (black, navy, blue...) to high volume (yellow, red, purple).
Visual Purpose: Give a quick sense of how "loud" or "quiet" a candle's volume is.
📈 2. Highs of Day Tracking
Purpose: Track the high price reached during different trading sessions.
Defines pre-market, regular, and post-market sessions.
Tracks the highest price (high) in each session.
Plots colored lines:
Orange: Pre-market high
Red: Regular market high
Blue: Post-market high
🟩 3. Green Candle Pattern Detection
Purpose: Detect bullish patterns formed by consecutive green candles.
Key Conditions:
Count green candles (greenCount) until a red candle appears or 10 candles max.
Require at least 1 silver-or-above volume candle (volRatio >= 1.0).
Must have ≥3% price gain during the green sequence.
Must accumulate >20,000 volume during the green run.
If Valid:
Locks the pattern.
Records important values:
patternStartPrice, patternEndPrice, totalPatternVolume, patternHigh, patternBars[]
Marks the bar after which red starts (redStartBar)
⬇️ 4. Retracement Monitoring
Purpose: Track retracement from the pattern high after it locks.
Defines retracement percentage:
(greenPatternHigh - low) / (greenPatternHigh - greenPatternLow)
If retracement exceeds 80%, it invalidates the pattern.
Buy signal is disabled if pattern retraces too far.
✅ 5. Buy Signal Logic
Purpose: Fire a buy signal after pattern lock if price breaks above local high.
Conditions:
Pattern is locked (patternLocked).
Price breaks above a short-term high (triggerBreak).
It's not the first red candle.
Price is within 8.5% above EMA9.
Buy signal fires and:
Sets buyActive = true
Tracks highest price after buy
Stores buyPrice = close
❌ 6. Sell Signal Logic
Purpose: Exit signal after retracement from post-buy high.
While buy is active:
If price retraces ≥3% from the post-buy high → sellSignal = true
Resets buyActive, trackedHigh, and buyPrice
Plots a red "SELL" label above the bar.
🎨 7. Buy Signal Visual Color Coding
Purpose: Color buy signal based on how deep the retracement is.
Uses retracement percentage:
≥65% → Red (high risk)
45–65% + MACD bullish → Yellow (moderate)
<45% + MACD bullish → Green (ideal)
Plots BUY label below bar in the respective color.
🔻 8. Retracement Triangle Visuals
Purpose: Shows retracement progression while pattern is locked.
If pattern is locked and not ready for buy:
Plots triangle below bar in the buyColor for visual tracking.
⭐ 9. Star Markers Above Lock Candle
Purpose: Confirmations when pattern locks.
First Star:
Plotted above the first red candle after green pattern lock.
Second Star (⭐⭐):
Additional confirmations:
Volume OK (less than previous)
MACD bullish
Price > VWAP
VolAtLock > 100K
Price up >6% from first green candle
Price below 75% of daily EMA200 or above EMA200
Third Star (⭐⭐⭐):
Even stricter confirmations:
Volume < 60% of previous
High <= previous high
VolAtLock > 500K
Price > $3
Gain >9% from first green
Price < 50% of daily EMA200 or above EMA200
📊 10. Bar Coloring
Purpose: Visually highlight bars based on pattern phase and MACD.
Gray: MACD Bearish
Light Green: Part of active green pattern
Blue: In locked phase but no buy triggered
🔄 11. Reset Logic
Purpose: Clears all tracking variables once a buy signal fires or pattern is invalidated.
Also resets if:
Retracement is too deep
10 candles pass post-lock without a trigger
⛰️ 12. Double Top Detection
Purpose: Basic visual marker when current high == previous high.
Plots a gray triangle if current and previous bar highs match.
📌 Summary: What This Strategy Shows
Buy Opportunities: Based on high-volume green runs and confirmed breakouts.
Sell Triggers: Once a retracement from peak exceeds 3%.
Visuals for Confirmation:
Diamonds for volume
Stars for lock confidence
Colors for retracement strength
Risk Management:
Retracement filtering
Time limits on locked phases
Volume filters
Market Context: Tracks pre/regular/post market highs and daily EMA 200.
🔷 1. Volume Profile Highlights (Arrow Emojis)
Purpose: Show volume strength vs. average using color-coded arrows.
Calculates average volume over a user-defined period (length = 10).
Divides current volume by average volume to get volRatio.
Based on volRatio, plots small arrows (acting like diamonds) in various colors:
Low volume (black, navy, blue...) to high volume (yellow, red, purple).
Visual Purpose: Give a quick sense of how "loud" or "quiet" a candle's volume is.
📈 2. Highs of Day Tracking
Purpose: Track the high price reached during different trading sessions.
Defines pre-market, regular, and post-market sessions.
Tracks the highest price (high) in each session.
Plots colored lines:
Orange: Pre-market high
Red: Regular market high
Blue: Post-market high
🟩 3. Green Candle Pattern Detection
Purpose: Detect bullish patterns formed by consecutive green candles.
Key Conditions:
Count green candles (greenCount) until a red candle appears or 10 candles max.
Require at least 1 silver-or-above volume candle (volRatio >= 1.0).
Must have ≥3% price gain during the green sequence.
Must accumulate >20,000 volume during the green run.
If Valid:
Locks the pattern.
Records important values:
patternStartPrice, patternEndPrice, totalPatternVolume, patternHigh, patternBars[]
Marks the bar after which red starts (redStartBar)
⬇️ 4. Retracement Monitoring
Purpose: Track retracement from the pattern high after it locks.
Defines retracement percentage:
(greenPatternHigh - low) / (greenPatternHigh - greenPatternLow)
If retracement exceeds 80%, it invalidates the pattern.
Buy signal is disabled if pattern retraces too far.
✅ 5. Buy Signal Logic
Purpose: Fire a buy signal after pattern lock if price breaks above local high.
Conditions:
Pattern is locked (patternLocked).
Price breaks above a short-term high (triggerBreak).
It's not the first red candle.
Price is within 8.5% above EMA9.
Buy signal fires and:
Sets buyActive = true
Tracks highest price after buy
Stores buyPrice = close
❌ 6. Sell Signal Logic
Purpose: Exit signal after retracement from post-buy high.
While buy is active:
If price retraces ≥3% from the post-buy high → sellSignal = true
Resets buyActive, trackedHigh, and buyPrice
Plots a red "SELL" label above the bar.
🎨 7. Buy Signal Visual Color Coding
Purpose: Color buy signal based on how deep the retracement is.
Uses retracement percentage:
≥65% → Red (high risk)
45–65% + MACD bullish → Yellow (moderate)
<45% + MACD bullish → Green (ideal)
Plots BUY label below bar in the respective color.
🔻 8. Retracement Triangle Visuals
Purpose: Shows retracement progression while pattern is locked.
If pattern is locked and not ready for buy:
Plots triangle below bar in the buyColor for visual tracking.
⭐ 9. Star Markers Above Lock Candle
Purpose: Confirmations when pattern locks.
First Star:
Plotted above the first red candle after green pattern lock.
Second Star (⭐⭐):
Additional confirmations:
Volume OK (less than previous)
MACD bullish
Price > VWAP
VolAtLock > 100K
Price up >6% from first green candle
Price below 75% of daily EMA200 or above EMA200
Third Star (⭐⭐⭐):
Even stricter confirmations:
Volume < 60% of previous
High <= previous high
VolAtLock > 500K
Price > $3
Gain >9% from first green
Price < 50% of daily EMA200 or above EMA200
📊 10. Bar Coloring
Purpose: Visually highlight bars based on pattern phase and MACD.
Gray: MACD Bearish
Light Green: Part of active green pattern
Blue: In locked phase but no buy triggered
🔄 11. Reset Logic
Purpose: Clears all tracking variables once a buy signal fires or pattern is invalidated.
Also resets if:
Retracement is too deep
10 candles pass post-lock without a trigger
⛰️ 12. Double Top Detection
Purpose: Basic visual marker when current high == previous high.
Plots a gray triangle if current and previous bar highs match.
📌 Summary: What This Strategy Shows
Buy Opportunities: Based on high-volume green runs and confirmed breakouts.
Sell Triggers: Once a retracement from peak exceeds 3%.
Visuals for Confirmation:
Diamonds for volume
Stars for lock confidence
Colors for retracement strength
Risk Management:
Retracement filtering
Time limits on locked phases
Volume filters
Market Context: Tracks pre/regular/post market highs and daily EMA 200.
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.