OPEN-SOURCE SCRIPT

Advanced Support and Resistance Levels[MAP]

197
Advanced Support and Resistance Levels Indicator
Author

Developed by: [MAP]

Overview

The "Advanced Support and Resistance Levels" indicator, created, is a sophisticated tool designed for TradingView's Pine Script v6 platform. It identifies and plots key support and resistance levels on a price chart, enhancing technical analysis by incorporating pivot strength, volume weighting, and level decay. The indicator overlays lines, zones, and labels on the chart, providing a visual representation of significant price levels where the market has historically reversed or consolidated.
Purpose

This indicator, authored by [MAP], aims to:

Detect significant pivot points (highs and lows) with customizable strength requirements.
Track and rank support/resistance levels based on their recency, volume, and number of touches.
Display these levels as lines and optional zones, with strength-based visual cues (e.g., line thickness and opacity).
Offer flexibility through user-configurable settings to adapt to different trading styles and market conditions.

Features

Pivot Detection:
Identifies high and low pivots using a strength parameter, requiring a specified number of bars on either side where no higher highs or lower lows occur.
Incorporates closing price checks and SMA-based trend confirmation to filter out noise and ensure pivots align with the broader market direction.
Level Management:
Maintains a dynamic array of levels with attributes: price, type (support/resistance), bars since last touch, strength, and volume.
Merges nearby levels within a tolerance percentage, updating prices with a strength-weighted average.
Prunes weaker or older levels when exceeding the maximum allowed, prioritizing those with higher calculated strength.
Strength Calculation:
Combines the number of touches (strength), volume (if enabled), and age decay (if enabled) into a single metric.
Volume weighting uses a logarithmic scale to emphasize high-volume pivots without over-amplifying extreme values.
Age decay reduces the importance of older levels over time, ensuring relevance to current price action.
Visualization:
Draws horizontal lines at each level, with thickness reflecting the number of touches (up to a user-defined maximum).
Optional price zones around levels, sized as a percentage of the price, to indicate areas of influence.
Labels display the level type (S for support, R for resistance), price, and strength score, with position (left or right) customizable.
Line opacity varies with strength, providing a visual hierarchy of level significance.
Plots small triangles at detected pivot points for reference.

Inputs

Lookback Period (lookback, default: 20): Number of bars to consider for trend confirmation via SMA. Range: 5–100.
Pivot Strength (strength, default: 2): Number of bars required on each side of a pivot to confirm it. Range: 1–10.
Price Tolerance % (tolerance, default: 0.5): Percentage range for merging similar levels. Range: 0.1–5.
Max Levels to Show (maxLevels, default: 10): Maximum number of levels displayed. Range: 2–50.
Zone Size % (zoneSizePercent, default: 0.1): Size of the S/R zone as a percentage of the price. Range: 0–1.
Line Width (lineWidth, default: 1): Maximum thickness of level lines. Range: 1–5.
Show Labels (showLabels, default: true): Toggle visibility of level labels.
Label Position (labelPos, default: "Right"): Position of labels ("Left" or "Right").
Level Strength Decay (levelDecay, default: true): Enable gradual reduction in strength for older levels.
Volume Weighting (volumeWeight, default: true): Incorporate volume into level strength calculations.
Support Color (supportColor, default: green): Color for support levels.
Resistance Color (resistColor, default: red): Color for resistance levels.

How It Works

Pivot Detection:
Checks for pivots only after enough bars (2 * strength) have passed.
A high pivot requires strength bars before and after with no higher highs or closes, and a short-term SMA above a long-term SMA.
A low pivot requires strength bars before and after with no lower lows or closes, and a short-term SMA below a long-term SMA.
Level Tracking:
New pivots create levels with initial strength and volume.
Existing levels within tolerance are updated: strength increases, volume takes the maximum value, and price adjusts via a weighted average.
Levels older than lookback * 4 bars with strength below 0.5 are removed.
If the number of levels exceeds maxLevels, the weakest (by calculated strength) are pruned using a selection sort algorithm.
Drawing:
Updates on the last confirmed bar or in real-time.
Lines extend lookback bars left and right from the current bar, with thickness based on touches.
Zones (if enabled) are drawn symmetrically around the level price.
Labels show detailed info, with opacity tied to strength.

Usage

Add to Chart: Apply the indicator to any TradingView chart via the Pine Script editor, as designed by [MAP].
Adjust Settings: Customize inputs to match your trading strategy (e.g., increase strength for stronger pivots, adjust tolerance for tighter level merging).
Interpret Levels: Focus on thicker, less transparent lines for stronger levels; use zones to identify potential reversal areas.
Combine with Other Tools: Pair with trend indicators or oscillators for confluence in trading decisions.

Notes

Performance: The indicator uses arrays and sorting, which may slow down on very long charts with many levels. Keep maxLevels reasonable for efficiency.
Accuracy: Enhanced by trend confirmation and volume weighting, making it more reliable than basic S/R indicators, thanks to [MAP]'s design.
Limitations: Real-time updates may shift levels as new pivots form; historical levels are more stable.

Example Settings

For day trading: lookback=10, strength=1, tolerance=0.3, maxLevels=5.
For swing trading: lookback=50, strength=3, tolerance=0.7, maxLevels=10.

Credits

Author: [MAP] – Creator of this advanced support and resistance tool, blending precision and customization for traders.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.