INVITE-ONLY SCRIPT

Diamond Peaks [EdgeTerminal]

59
The Diamond Peaks indicator is a comprehensive technical analysis tool that uses a few mathematical models to identify high-probability trading opportunities. This indicator goes beyond traditional support and resistance identification by incorporating volume analysis, momentum divergences, advanced price action patterns, and market sentiment indicators to generate premium-quality buy and sell signals.

Dynamic Support/Resistance Calculation
The indicator employs an adaptive algorithm that calculates support and resistance levels using a volatility-adjusted lookback period. The base calculation uses ta.highest(length) and ta.lowest(length) functions, where the length parameter is dynamically adjusted using the formula: adjusted_length = base_length * (1 + (volatility_ratio - 1) * volatility_factor). The volatility ratio is computed as current_ATR / average_ATR over a 50-period window, ensuring the lookback period expands during volatile conditions and contracts during calm periods. This mathematical approach prevents the indicator from using fixed periods that may become irrelevant during different market regimes.

Momentum Divergence Detection Algorithm
The divergence detection system uses a mathematical comparison between price series and oscillator values over a specified lookback period. For bullish divergences, the algorithm identifies when recent_low < previous_low while simultaneously indicator_at_recent_low > indicator_at_previous_low. The inverse logic applies to bearish divergences. The system tracks both RSI (calculated using Pine Script's standard ta.rsi() function with Wilder's smoothing) and MACD (using ta.macd() with exponential moving averages). The mathematical rigor ensures that divergences are only flagged when there's a clear mathematical relationship between price momentum and the underlying oscillator momentum, eliminating false signals from minor price fluctuations.

Volume Analysis Mathematical Framework
The volume analysis component uses multiple mathematical transformations to assess market participation. The Cumulative Volume Delta (CVD) is calculated as ∑(buying_volume - selling_volume) where buying_volume occurs when close > open and selling_volume when close < open. The relative volume calculation uses current_volume / ta.sma(volume, period) to normalize current activity against historical averages. Volume Rate of Change employs ta.roc(volume, period) = (current_volume - volume[period]) / volume[period] * 100 to measure volume acceleration. Large trade detection uses a threshold multiplier against the volume moving average, mathematically identifying institutional activity when relative_volume > threshold_multiplier.

Advanced Price Action Mathematics
The Wyckoff analysis component uses mathematical volume climax detection by comparing current volume against ta.highest(volume, 50) * 0.8, while price compression is measured using (high - low) < ta.atr(20) * 0.5. Liquidity sweep detection employs percentage-based calculations: bullish sweeps occur when low < recent_low * (1 - threshold_percentage/100) followed by close > recent_low. Supply and demand zones are mathematically validated by tracking subsequent price action over a defined period, with zone strength calculated as the count of bars where price respects the zone boundaries. Fair value gaps are identified using ATR-based thresholds: gap_size > ta.atr(14) * 0.5.

Sentiment and Market Regime Mathematics
The sentiment analysis employs a multi-factor mathematical model. The fear/greed index uses volatility normalization: 100 - min(100, stdev(price_changes, period) * scaling_factor). Market regime classification uses EMA crossover mathematics with additional ADX-based trend strength validation. The trend strength calculation implements a modified ADX algorithm: DX = |+DI - -DI| / (+DI + -DI) * 100, then ADX = RMA(DX, period). Bull regime requires short_EMA > long_EMA AND ADX > 25 AND +DI > -DI. The mathematical framework ensures objective regime classification without subjective interpretation.

Confluence Scoring Mathematical Model
The confluence scoring system uses a weighted linear combination: Score = (divergence_component * 0.25) + (volume_component * 0.25) + (price_action_component * 0.25) + (sentiment_component * 0.25) + contextual_bonuses. Each component is normalized to a 0-100 scale using percentile rankings and threshold comparisons. The mathematical model ensures that no single component can dominate the score, while contextual bonuses (regime alignment, volume confirmation, etc.) provide additional mathematical weight when multiple factors align. The final score is bounded using math.min(100, math.max(0, calculated_score)) to maintain mathematical consistency.

Vitality Field Mathematical Implementation
The vitality field uses a multi-factor scoring algorithm that combines trend direction (EMA crossover: trend_score = fast_EMA > slow_EMA ? 1 : -1), momentum (RSI-based: momentum_score = RSI > 50 ? 1 : -1), MACD position (macd_score = MACD_line > 0 ? 1 : -1), and volume confirmation. The final vitality score uses weighted mathematics: vitality_score = (trend * 0.4) + (momentum * 0.3) + (macd * 0.2) + (volume * 0.1). The field boundaries are calculated using ATR-based dynamic ranges: upper_boundary = price_center + (ATR * user_defined_multiplier), with EMA smoothing applied to prevent erratic boundary movements. The gradient effect uses mathematical transparency interpolation across multiple zones.

Signal Generation Mathematical Logic
The signal generation employs boolean algebra with multiple mathematical conditions that must simultaneously evaluate to true. Buy signals require: (confluence_score ≥ threshold) AND (divergence_detected = true) AND (relative_volume > 1.5) AND (volume_ROC > 25%) AND (RSI < 35) AND (trend_strength > minimum_ADX) AND (regime = bullish) AND (cooldown_expired = true) AND (last_signal ≠ buy). The mathematical precision ensures that signals only generate when all quantitative conditions are met, eliminating subjective interpretation. The cooldown mechanism uses bar counting mathematics: bars_since_last_signal = current_bar_index - last_signal_bar_index ≥ cooldown_period. This mathematical framework provides objective, repeatable signal generation that can be backtested and validated statistically.

This mathematical foundation ensures the indicator operates on objective, quantifiable principles rather than subjective interpretation, making it suitable for algorithmic trading and systematic analysis while maintaining transparency in its computational methodology.

* for now, we're planning to keep the source code private as we try to improve the models used here and allow a small group to test them. My goal is to eventually use the multiple models in this indicator as their own free and open source indicators. If you'd like to use this indicator, please send me a message to get access.

Advanced Confluence Scoring System
Each support and resistance level receives a comprehensive confluence score (0-100) based on four weighted components:
Momentum Divergences (25% weight)
  • RSI and MACD divergence detection
  • Identifies momentum shifts before price reversals
  • Bullish/bearish divergence confirmation


Volume Analysis (25% weight)
  • Cumulative Volume Delta (CVD) analysis
  • Volume Rate of Change monitoring
  • Large trade detection (institutional activity)
  • Volume profile strength assessment


Advanced Price Action (25% weight)
  • Supply and demand zone identification
  • Liquidity sweep detection (stop hunts)
  • Wyckoff accumulation/distribution patterns
  • Fair value gap analysis


Market Sentiment (25% weight)
  • Fear/Greed index calculation
  • Market regime classification (Bull/Bear/Sideways)
  • Trend strength measurement (ADX-like)
  • Momentum regime alignment


Dynamic Support and Resistance Detection
The indicator uses an adaptive algorithm to identify significant support and resistance levels based on recent market highs and lows. Unlike static levels, these zones adjust dynamically to market volatility using the Average True Range (ATR), ensuring the levels remain relevant across different market conditions.

Vitality Field Background
The indicator features a unique vitality field that provides instant visual feedback about market sentiment:
  • Green zones: Bullish market conditions with strong momentum
  • Red zones: Bearish market conditions with weak momentum
  • Gray zones: Neutral/sideways market conditions

The vitality field uses a sophisticated gradient system that fades from the center outward, creating a clean, professional appearance that doesn't overwhelm the chart while providing valuable context.

Buy Signals (🚀 BUY)
Buy signals are generated when ALL of the following conditions are met:
  • Valid support level with confluence score ≥ 80
  • Bullish momentum divergence detected (RSI or MACD)
  • Volume confirmation (1.5x average volume + 25% volume ROC)
  • Bull market regime environment
  • RSI below 35 (oversold conditions)
  • Price action confirmation (Wyckoff accumulation, liquidity sweep, or large buying volume)
  • Minimum trend strength (ADX > 25)
  • Signal alternation check (prevents consecutive buy signals)
  • Cooldown period expired (default 10 bars)


Sell Signals (🔻 SELL)
Sell signals are generated when ALL of the following conditions are met:
  • Valid resistance level with confluence score ≥ 80
  • Bearish momentum divergence detected (RSI or MACD)
  • Volume confirmation (1.5x average volume + 25% volume ROC)
  • Bear market regime environment
  • RSI above 65 (overbought conditions)
  • Price action confirmation (Wyckoff distribution, liquidity sweep, or large selling volume)
  • Minimum trend strength (ADX > 25)
  • Signal alternation check (prevents consecutive sell signals)
  • Cooldown period expired (default 10 bars)


How to Use the Indicator
1. Signal Quality Assessment
Monitor the confluence scores in the information table:
  • Score 90-100: Exceptional quality levels (A+ grade)
  • Score 80-89: High quality levels (A grade)
  • Score 70-79: Good quality levels (B grade)
  • Score below 70: Weak levels (filtered out by default)


2. Market Context Analysis
Use the vitality field and market regime information to understand the broader market context:
  • Trade buy signals in green vitality zones during bull regimes
  • Trade sell signals in red vitality zones during bear regimes
  • Exercise caution in gray zones (sideways markets)


3. Entry and Exit Strategy
For Buy Signals:
  • Enter long positions when premium buy signals appear
  • Place stop loss below the support confluence zone
  • Target the next resistance level or use a risk/reward ratio of 2:1 or higher


For Sell Signals:
  • Enter short positions when premium sell signals appear
  • Place stop loss above the resistance confluence zone
  • Target the next support level or use a risk/reward ratio of 2:1 or higher


4. Risk Management
  • Only trade signals with confluence scores above 80
  • Respect the signal alternation system (no overtrading)
  • Use appropriate position sizing based on signal quality
  • Consider the overall market regime before taking trades


Customizable Settings
Signal Generation Controls
  • Signal Filtering: Enable/disable advanced filtering
  • Confluence Threshold: Adjust minimum score requirement (70-95)
  • Cooldown Period: Set bars between signals (5-50)
  • Volume/Momentum Requirements: Toggle confirmation requirements
  • Trend Strength: Minimum ADX requirement (15-40)


Vitality Field Options
  • Enable/Disable: Control background field display
  • Transparency Settings: Adjust opacity for center and edges
  • Field Size: Control the field boundaries (3.0-20.0)
  • Color Customization: Set custom colors for bullish/bearish/neutral states


Weight Adjustments
  • Divergence Weight: Adjust momentum component influence (10-40%)
  • Volume Weight: Adjust volume component influence (10-40%)
  • Price Action Weight: Adjust price action component influence (10-40%)
  • Sentiment Weight: Adjust sentiment component influence (10-40%)


Best Practices
  • Always wait for complete signal confirmation before entering trades
  • Use higher timeframes for signal validation and context
  • Combine with proper risk management and position sizing
  • Monitor the information table for real-time market analysis
  • Pay attention to volume confirmation for higher probability trades
  • Respect market regime alignment for optimal results


Basic Settings
Base Length (Default: 25)
  • Controls the lookback period for identifying support and resistance levels
  • Range: 5-100 bars
  • Lower values = More responsive, shorter-term levels
  • Higher values = More stable, longer-term levels
  • Recommendation: 25 for intraday, 50 for swing trading


Enable Adaptive Length (Default: True)
  • Automatically adjusts the base length based on market volatility
  • When enabled, length increases in volatile markets and decreases in calm markets
  • Helps maintain relevant levels across different market conditions


Volatility Factor (Default: 1.5)
  • Controls how much the adaptive length responds to volatility changes
  • Range: 0.5-3.0
  • Higher values = More aggressive length adjustments
  • Lower values = More conservative length adjustments


Volume Profile Settings
VWAP Length (Default: 200)
  • Sets the calculation period for the Volume Weighted Average Price
  • Range: 50-500 bars
  • Shorter periods = More responsive to recent price action
  • Longer periods = More stable reference line
  • Used for volume profile analysis and confluence scoring


Volume MA Length (Default: 50)
  • Period for calculating the volume moving average baseline
  • Range: 10-200 bars
  • Used to determine relative volume (current volume vs. average)
  • Shorter periods = More sensitive to volume changes
  • Longer periods = More stable volume baseline


High Volume Node Threshold (Default: 1.5)
  • Multiplier for identifying significant volume spikes
  • Range: 1.0-3.0
  • Values above this threshold mark high-volume nodes with diamond shapes
  • Lower values = More frequent high-volume signals
  • Higher values = Only extreme volume events marked


Momentum Divergence Settings
Enable Divergence Detection (Default: True)
  • Master switch for momentum divergence analysis
  • When disabled, removes divergence from confluence scoring
  • Significantly impacts signal generation quality


RSI Length (Default: 14)
  • Period for RSI calculation used in divergence detection
  • Range: 5-50
  • Standard RSI settings apply (14 is most common)
  • Shorter periods = More sensitive, more signals
  • Longer periods = Smoother, fewer but more reliable signals


MACD Settings
  • Fast (Default: 12): Fast EMA period for MACD calculation (5-50)
  • Slow (Default: 26): Slow EMA period for MACD calculation (10-100)
  • Signal (Default: 9): Signal line EMA period (3-20)
  • Standard MACD settings for divergence detection


Divergence Lookback (Default: 5)
  • Number of bars to look back when detecting divergences
  • Range: 3-20
  • Shorter periods = More frequent divergence signals
  • Longer periods = More significant divergence signals


Volume Analysis Enhancement Settings
Enable Advanced Volume Analysis (Default: True)
  • Master control for sophisticated volume calculations
  • Includes CVD, volume ROC, and large trade detection
  • Critical for signal accuracy


Cumulative Volume Delta Length (Default: 20)
  • Period for CVD smoothing calculation
  • Range: 10-100
  • Tracks buying vs. selling pressure over time
  • Shorter periods = More reactive to recent flows
  • Longer periods = Broader trend perspective


Volume ROC Length (Default: 10)
  • Period for Volume Rate of Change calculation
  • Range: 5-50
  • Measures volume acceleration/deceleration
  • Key component in volume confirmation requirements


Large Trade Volume Threshold (Default: 2.0)
  • Multiplier for identifying institutional-size trades
  • Range: 1.5-5.0
  • Trades above this threshold marked as large trades
  • Lower values = More frequent large trade signals
  • Higher values = Only extreme institutional activity


Advanced Price Action Settings
Enable Wyckoff Analysis (Default: True)
  • Activates simplified Wyckoff accumulation/distribution detection
  • Identifies potential smart money positioning
  • Important for high-quality signal generation


Enable Supply/Demand Zones (Default: True)
  • Identifies fresh supply and demand zones
  • Tracks zone strength based on subsequent price action
  • Enhances confluence scoring accuracy


Enable Liquidity Analysis (Default: True)
  • Detects liquidity sweeps and stop hunts
  • Identifies fake breakouts vs. genuine moves
  • Critical for avoiding false signals


Zone Strength Period (Default: 20)
  • Bars used to assess supply/demand zone strength
  • Range: 10-50
  • Longer periods = More thorough zone validation
  • Shorter periods = Faster zone assessment


Liquidity Sweep Threshold (Default: 0.5%)
  • Percentage move required to confirm liquidity sweep
  • Range: 0.1-2.0%
  • Lower values = More sensitive sweep detection
  • Higher values = Only significant sweeps detected


Sentiment and Flow Settings
Enable Sentiment Analysis (Default: True)
  • Master control for market sentiment calculations
  • Includes fear/greed index and regime classification
  • Important for market context assessment


Fear/Greed Period (Default: 20)
  • Calculation period for market sentiment indicator
  • Range: 10-50
  • Based on price volatility and momentum
  • Shorter periods = More reactive sentiment readings


Momentum Regime Length (Default: 50)
  • Period for determining overall market regime
  • Range: 20-100
  • Classifies market as Bull/Bear/Sideways
  • Longer periods = More stable regime classification


Trend Strength Length (Default: 30)
  • Period for ADX-like trend strength calculation
  • Range: 10-100
  • Measures directional momentum intensity
  • Used in signal filtering requirements


Advanced Signal Generation Settings
Enable Signal Filtering (Default: True)
  • Master control for premium signal generation system
  • When disabled, uses basic signal conditions
  • Highly recommended to keep enabled


Minimum Signal Confluence Score (Default: 80)
  • Required confluence score for signal generation
  • Range: 70-95
  • Higher values = Fewer but higher quality signals
  • Lower values = More frequent but potentially lower quality signals


Signal Cooldown (Default: 10 bars)
  • Minimum bars between signals of same type
  • Range: 5-50
  • Prevents signal spam and overtrading
  • Higher values = More conservative signal spacing


Require Volume Confirmation (Default: True)
  • Mandates volume requirements for signal generation
  • Requires 1.5x average volume + 25% volume ROC
  • Critical for signal quality


Require Momentum Confirmation (Default: True)
  • Mandates divergence detection for signals
  • Ensures momentum backing for directional moves
  • Essential for high-probability setups


Minimum Trend Strength (Default: 25)
  • Required ADX level for signal generation
  • Range: 15-40
  • Ensures signals occur in trending markets
  • Higher values = Only strong trending conditions


Confluence Scoring Settings
  • Minimum Confluence Score (Default: 70)
  • Threshold for displaying support/resistance levels
  • Range: 50-90
  • Levels below this score are filtered out
  • Higher values = Only strongest levels shown


Component Weights (Default: 25% each)
  • Divergence Weight: Momentum component influence (10-40%)
  • Volume Weight: Volume analysis influence (10-40%)
  • Price Action Weight: Price patterns influence (10-40%)
  • Sentiment Weight: Market sentiment influence (10-40%)
  • Must total 100% for balanced scoring


Vitality Field Settings
Enable Vitality Field (Default: True)
  • Controls the background gradient field display
  • Provides instant visual market sentiment feedback
  • Enhances chart readability and context


Vitality Center Transparency (Default: 85%)
  • Opacity at the center of the vitality field
  • Range: 70-95%
  • Lower values = More opaque center
  • Higher values = More transparent center


Vitality Edge Transparency (Default: 98%)
  • Opacity at the edges of the vitality field
  • Range: 95-99%
  • Creates smooth fade effect from center to edges
  • Higher values = More subtle edge appearance


Vitality Field Size (Default: 8.0)
  • Controls the overall size of the vitality field
  • Range: 3.0-20.0
  • Based on ATR multiples for dynamic sizing
  • Lower values = Tighter field around price
  • Higher values = Broader field coverage


Recommended Settings by Trading Style
Scalping (1-5 minutes)
  • Base Length: 15
  • Volume MA Length: 20
  • Signal Cooldown: 5 bars
  • Vitality Field Size: 5.0
  • Higher sensitivity for quick moves


Day Trading (15-60 minutes)
  • Base Length: 25 (default)
  • Volume MA Length: 50 (default)
  • Signal Cooldown: 10 bars (default)
  • Vitality Field Size: 8.0 (default)
  • Balanced settings for intraday moves


Swing Trading (4H-Daily)
  • Base Length: 50
  • Volume MA Length: 100
  • Signal Cooldown: 20 bars
  • Vitality Field Size: 12.0
  • Longer-term perspective for multi-day moves


Conservative Trading
  • Minimum Signal Confluence: 85
  • Minimum Confluence Score: 80
  • Require all confirmations: True
  • Higher thresholds for maximum quality


Aggressive Trading
  • Minimum Signal Confluence: 75
  • Minimum Confluence Score: 65
  • Signal Cooldown: 5 bars
  • Lower thresholds for more opportunities

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.