OPEN-SOURCE SCRIPT

Advanced Psychological Levels with Dynamic Spacing

115
═══════════════════════════════════════
ADVANCED PSYCHOLOGICAL LEVELS WITH DYNAMIC SPACING
═══════════════════════════════════════

A comprehensive psychological price level indicator that automatically identifies and displays round number levels across multiple timeframes. Features dynamic ATR-based spacing, smart crypto detection, distance tracking, and customizable alert system.

───────────────────────────────────────
WHAT THIS INDICATOR DOES
───────────────────────────────────────

This indicator automatically draws psychological price levels (round numbers) that often act as support and resistance:

- Dynamic ATR-Based Spacing - Adapts level spacing to market volatility
- Multiple Level Types - Major (250 pip), Standard (100 pip), Mid, and Intraday levels
- Smart Asset Detection - Automatically adjusts for Forex, Crypto, Indices, and CFDs
- Crypto Price Adaptation - Intelligent level spacing based on cryptocurrency price magnitude
- Distance Information Table - Real-time percentage distance to nearest levels
- Combined Level Labels - Clear identification when multiple level types coincide
- Performance Optimized - Configurable visible range and label limits
- Comprehensive Alerts - Notifications when price crosses any level type

───────────────────────────────────────
HOW IT WORKS
───────────────────────────────────────

PSYCHOLOGICAL LEVELS CONCEPT:

Psychological levels are round numbers where traders tend to place orders, creating natural support and resistance zones. These include:
- Forex: 1.0000, 1.0100, 1.0050 (pips)
- Crypto: $100, $1,000, $10,000 (whole numbers)
- Indices: 10,000, 10,500, 11,000 (points)

Why They Matter:
- Traders naturally gravitate to round numbers
- Stop losses cluster at these levels
- Take profit orders concentrate here
- Institutional algorithmic trading often targets these levels

DYNAMIC ATR-BASED SPACING:

Traditional Method:
- Fixed spacing regardless of volatility
- May be too tight in volatile markets
- May be too wide in quiet markets

Dynamic Method (Recommended):
- Uses ATR (Average True Range) to measure volatility
- Automatically adjusts level spacing
- Tighter levels in low volatility
- Wider levels in high volatility

Calculation:
1. Calculate ATR over specified period (default: 14)
2. Multiply by ATR multiplier (default: 2.0)
3. Round to nearest psychological level
4. Generate levels at dynamic intervals

Benefits:
- Adapts to market conditions
- More relevant levels in all volatility regimes
- Reduces clutter in trending markets
- Provides more detail in ranging markets

LEVEL TYPES:

Major Levels (250 pip/point):
- Highest significance
- Primary support/resistance zones
- Color: Red (default)
- Style: Solid lines
- Spacing: 2.5x standard step

Standard Levels (100 pip/point):
- Secondary importance
- Common psychological barriers
- Color: Blue (default)
- Style: Dashed lines
- Spacing: Standard step

Mid Levels (50% between major):
- Optional intermediate levels
- Halfway between major levels
- Color: Gray (default)
- Style: Dotted lines
- Usage: Additional confluence points

Intraday Levels (sub-100 pip):
- For intraday traders
- Fine-grained precision
- Color: Yellow (default)
- Style: Dotted lines
- Only shown on intraday timeframes

SMART ASSET DETECTION:

Forex Pairs:
- Detects major currency pairs automatically
- Uses pip-based calculations
- Standard: 100 pips (0.0100)
- Major: 250 pips (0.0250)
- Intraday: 20, 50, 80 pip subdivisions

Cryptocurrencies:
- Automatic price magnitude detection
- Adaptive spacing based on price:
* Under $0.10: Levels at $0.01, $0.05
* $0.10-$1: Levels at $0.10, $0.50
* $1-$10: Levels at $1, $5
* $10-$100: Levels at $10, $50
* $100-$1,000: Levels at $100, $500
* $1,000-$10,000: Levels at $1,000, $5,000
* Over $10,000: Levels at $5,000, $10,000

Indices & CFDs:
- Fixed point-based system
- Major: 500 point intervals (with 250 sub-levels)
- Standard: 100 point intervals
- Suitable for stock indices like SPX, NASDAQ

COMBINED LEVEL LABELS:

When multiple level types coincide at the same price:
- Single line drawn (highest priority color)
- Combined label shows all types
- Priority: Major > Standard > Mid > Intraday

Example Label Formats:
- "1.1000 Major" - Major level only
- "1.1000 Std + Major" - Both standard and major
- "50000 Intra + Mid + Std" - Three levels coincide

Benefits:
- Cleaner chart appearance
- Clear identification of confluence
- Reduced visual clutter
- Easy to spot high-importance levels

DISTANCE INFORMATION TABLE:

Real-time tracking of nearest levels:

Table Contents:
- Nearest major level above (price and % distance)
- Nearest standard level above (price and % distance)
- Nearest standard level below (price and % distance)

Display:
- Top right corner (configurable)
- Color-coded by level type
- Real-time percentage calculations
- Helpful for position management

Usage:
- Identify proximity to key levels
- Set realistic profit targets
- Gauge potential move magnitude
- Monitor approaching resistance/support

ALERT SYSTEM:

Comprehensive crossing alerts:

Alert Types:
- Major Level Crosses
- Standard Level Crosses
- Intraday Level Crosses

Alert Modes:
- First Cross Only: Alert once when level is crossed
- All Crosses: Alert every time level is crossed

Alert Information:
- Level type crossed
- Specific price level
- Direction (above/below)
- One alert per bar to prevent spam

Configuration:
- Enable/disable by level type
- Choose alert frequency
- Customize for your trading style

───────────────────────────────────────
HOW TO USE
───────────────────────────────────────

INITIAL SETUP:

General Settings:
1. Enable "Use Dynamic ATR-Based Spacing" (recommended)
2. Set ATR Period (14 is standard)
3. Adjust ATR Multiplier (2.0 is balanced)

Visibility Settings:
1. Set Visible Range % (10% recommended for clarity)
2. Adjust Label Offset for readability
3. Configure performance limits if needed

Level Selection:
1. Enable/disable level types based on trading style
2. Adjust line counts for each type
3. Choose line styles and colors for visibility

TRADING STRATEGIES:

Breakout Trading:
1. Wait for price to approach major or standard level
2. Monitor for consolidation near level
3. Enter on confirmed break above/beyond level
4. Stop loss just beyond the broken level
5. Target: Next major or standard level

Rejection Trading:
1. Identify major psychological level
2. Wait for price to test the level
3. Look for rejection signals (wicks, bearish/bullish candles)
4. Enter in direction of rejection
5. Stop beyond the level
6. Target: Previous level or mid-level

Range Trading:
1. Identify range between two major levels
2. Buy at lower psychological level
3. Sell at upper psychological level
4. Use standard and mid-levels for position management
5. Exit if major level breaks with volume

Confluence Trading:
1. Look for combined levels (Std + Major)
2. These represent high-probability zones
3. Use as primary support/resistance
4. Increase position size at confluence
5. Expect stronger reactions at these levels

Session-Based Trading:
1. Note opening level at session start (Asian/London/NY)
2. Trade breakouts of major levels during high-volume sessions
3. London/NY sessions: More likely to break levels
4. Asian session: More likely to respect levels (range trading)

RISK MANAGEMENT WITH PSYCHOLOGICAL LEVELS:

Stop Loss Placement:
- Place stops just beyond psychological levels
- Add buffer (5-10 pips for forex)
- Avoid exact round numbers (stop hunting risk)
- Use previous major level as maximum stop

Take Profit Strategy:
- First target: Next standard level (partial profit)
- Second target: Next major level (remaining position)
- Trail stops to breakeven at first target
- Use distance table to calculate risk/reward

Position Sizing:
- Larger positions at major levels (higher probability)
- Smaller positions at intraday levels (lower probability)
- Scale in at standard levels between major levels
- Reduce size when multiple levels are close together

TIMEFRAME CONSIDERATIONS:

Higher Timeframes (4H, Daily, Weekly):
- Focus on Major and Standard levels only
- Disable Intraday and Mid levels
- Wider level spacing expected
- Use for swing trading and position trading

Lower Timeframes (5m, 15m, 1H):
- Enable all level types
- Use Intraday levels for precision
- Tighter level spacing acceptable
- Good for day trading and scalping

Multi-Timeframe Approach:
- Identify major levels on Daily/4H charts
- Refine entries using 15m/1H intraday levels
- Trade in direction of higher timeframe bias
- Use lower timeframe levels for position management

───────────────────────────────────────
CONFIGURATION GUIDE
───────────────────────────────────────

GENERAL SETTINGS:

Dynamic ATR-Based Spacing:
- Enabled: Recommended for most markets
- Disabled: Fixed psychological levels
- ATR Period: 14 (standard), 10 (responsive), 20 (smooth)
- ATR Multiplier: 1.0-5.0 (2.0 is balanced)

VISIBILITY SETTINGS:

Visible Range %:
- 5%: Very tight range, minimal clutter
- 10%: Balanced view (recommended)
- 20%: Wide range, more context
- 50%: Maximum range, all levels visible

Label Offset:
- 10-20 bars: Close to current price
- 30-50 bars: Moderate distance
- 50-100 bars: Far from price action

Performance Limits:
- Max Historical Bars: Reduce if indicator loads slowly
- Max Labels: Reduce for cleaner chart (20-30 recommended)

LEVEL CUSTOMIZATION:

Line Count:
- Lower (1-3): Cleaner chart, fewer levels
- Medium (4-6): Balanced view
- Higher (7-10): More context, busier chart

Line Styles:
- Solid: High importance, easy to see
- Dashed: Medium importance, clear but subtle
- Dotted: Low importance, minimal visual weight

Colors:
- Use contrasting colors for different level types
- Red/Blue/Yellow default works well
- Adjust based on chart background and personal preference

DISTANCE TABLE:

Position:
- Top Right: Doesn't interfere with price action
- Top Left: Good for right-side price scale
- Bottom positions: Less common but available

Colors:
- Default (white text, dark background) works for most charts
- Match your chart theme for consistency
- Ensure text is readable against background

ALERT CONFIGURATION:

Alert by Level Type:
- Major: Most important, fewer false signals
- Standard: Balance of frequency and importance
- Intraday: Many signals, best for active traders

Alert Frequency:
- First Cross Only: Cleaner, less noise (recommended for swing trading)
- All Crosses: Every touch, good for scalping

Alert Setup in TradingView:
1. Configure desired alert types in indicator settings
2. Right-click chart → Add Alert
3. Select this indicator
4. Choose "Any alert() function call"
5. Set delivery method (mobile, email, webhook)

───────────────────────────────────────
ASSET-SPECIFIC TIPS
───────────────────────────────────────

FOREX (EUR/USD, GBP/USD, etc.):
- Major levels at x.x000, x.x500
- Standard levels at x.xx00
- Intraday levels at 20/50/80 pips
- Most effective during London/NY sessions
- Watch for "figure" levels (1.0000, 1.1000)

CRYPTOCURRENCIES (BTC, ETH, etc.):
- Enable dynamic spacing for volatile markets
- Levels adjust automatically based on price
- Watch major $1,000 increments for BTC
- $100 levels important for ETH
- Smaller caps: Use standard levels
- High volatility: Increase ATR multiplier to 3.0

STOCK INDICES (SPX, NASDAQ, etc.):
- 100-point levels most important
- 500-point levels for major S/R
- 50-point mid-levels for refinement
- Watch end-of-day for level reactions
- Futures often lead spot on level breaks

GOLD/COMMODITIES:
- Major levels at $50 increments ($1,900, $1,950)
- Standard levels at $10 increments
- Very reactive to psychological levels
- Watch for false breaks during low volume
- Best reactions during active trading hours

───────────────────────────────────────
BEST PRACTICES
───────────────────────────────────────

Chart Setup:
- Use clean price action charts
- Avoid too many indicators
- Ensure psychological levels are clearly visible
- Match colors to your chart theme

Level Selection:
- Start with Major and Standard levels only
- Add Mid and Intraday as needed
- Less is more - avoid chart clutter
- Adjust based on timeframe

Combining with Other Tools:
- Volume profile for confluence
- Trendlines intersecting psychological levels
- Moving averages near round numbers
- Fibonacci levels coinciding with psychological levels

Common Mistakes to Avoid:
- Trading every level touch (be selective)
- Ignoring volume confirmation
- Setting stops exactly at levels (stop hunting)
- Forgetting to adjust for different assets
- Over-relying on levels without price action confirmation

Performance Optimization:
- Reduce visible range for faster loading
- Lower max historical bars on lower timeframes
- Limit labels to 30-50 for clarity
- Disable unused level types

───────────────────────────────────────
EDUCATIONAL DISCLAIMER
───────────────────────────────────────

This indicator identifies psychological price levels based on round numbers that tend to act as support and resistance. The methodology includes:

- Round number detection algorithms
- ATR-based dynamic spacing calculations
- Asset-specific level determination
- Distance percentage calculations

Psychological levels are a recognized concept in technical analysis, studied by traders and institutions. However, they do not guarantee price reactions and should be used as part of a comprehensive trading strategy including proper risk management, volume analysis, and price action confirmation.

───────────────────────────────────────
USAGE DISCLAIMER
───────────────────────────────────────

This tool is for educational and analytical purposes. Psychological levels can act as support or resistance but price reactions are not guaranteed. Dynamic spacing may generate different levels in different market conditions. Always conduct independent analysis, use proper risk management, and never risk capital you cannot afford to lose. Past performance does not indicate future results.
───────────────────────────────────────
CREDITS & ATTRIBUTION
───────────────────────────────────────
Original Concept: Sonar Lab

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。