OPEN-SOURCE SCRIPT

Trendlines & SR Zones

114
It's a comprehensive indicator (Pine Script v6) that represents two powerful technical analysis tools: automatic trendline detection based on pivot points and volume delta analysis with support/resistance zone identification. This overlay indicator helps traders identify potential trend directions and key price levels where significant buying or selling pressure has occurred.

Features: =
1. Price Trendlines
The indicator automatically identifies and draws trendlines based on pivot points, creating dynamic support and resistance levels.

Key Components:
Pivot Detection: Uses configurable left and right bars to identify significant pivot highs and lows
Trendline Filtering: Only draws downward-sloping resistance trendlines and upward-sloping support trendlines
Zone Creation: Creates filled zones around trendlines based on average price volatility
Automatic Management: Maintains only the 3 most recent significant trendlines to avoid chart clutter

Customization Options:
Left/Right Bars for Pivot: Adjust sensitivity of pivot detection (default: 10 bars each side)
Extension Length: Control how far trendlines extend past the second pivot (default: 50 bars)
Average Body Periods: Set the lookback period for volatility calculation (default: 100)
Tolerance Multiplier: Adjust the width of the trendline zones (default: 1.0)
Color Customization: Separate colors for high (resistance) and low (support) trendlines and their fills
2. Volume Delta % Bars
The indicator analyzes volume distribution across price levels to identify significant supply and demand zones.

Key Components:
Volume Profile Analysis: Divides the price range into rows and calculates volume delta at each level
Delta Visualization: Displays horizontal bars showing the percentage difference between buying and selling volume
Zone Identification: Automatically identifies the most significant supply and demand zones
Visual Integration: Connects volume delta bars with corresponding support/resistance zones on the price chart

Customization Options:
Lookback Period: Set the number of bars to analyze for volume (default: 200)
Price Rows: Control the granularity of the volume analysis (default: 50 rows)
Delta Sections: Adjust the number of horizontal delta bars displayed (default: 20)
Panel Appearance: Customize width, position, and direction of the delta panel
Zone Settings: Control the number of supply/demand zones and their extension (default: 3 zones)

How It Works-
Trendline Logic:
The script continuously scans for pivot highs and lows based on the specified left and right bars
When a pivot is detected, it creates a horizontal line at that price level
The script then looks for the previous pivot of the same type (high or low)
It connects these pivots with a trendline, extending it based on the user-specified setting
A parallel line is created to form a zone, with the distance based on average price volatility
The script filters out invalid trendlines (upward-sloping resistance and downward-sloping support). Only the 3 most recent trendlines are maintained to prevent chart clutter

Volume Delta Logic:
The script divides the price range over the lookback period into the specified number of rows
For each bar in the lookback period, it categorizes volume as bullish (close > open) or bearish (close < open). This volume is assigned to the appropriate price level based on the HLC3 price.
The price levels are grouped into sections, and the net delta (bullish - bearish volume) is calculated for each Horizontal bars are drawn to represent these delta percentages.
The most significant positive and negative deltas are identified and displayed as support and resistance zones. These zones are extended to the left on the price chart and connected to the delta panel with dotted lines.

Ideal Timeframes:
The indicator is versatile and can be used across multiple timeframes, but it performs optimally on specific timeframes depending on your trading style:

For Day Trading:
Optimal Timeframes: 15-minute to 1-hour charts
Why: These timeframes provide a good balance between noise reduction and sufficient volume data. The volume delta analysis is particularly effective on these timeframes as it captures intraday accumulation/distribution patterns while the trendlines remain reliable enough for intraday trading decisions.

For Swing Trading:
Optimal Timeframes: 1-hour to 4-hour charts
Why: These timeframes offer the best combination of reliable trendline formation and meaningful volume analysis. The trendlines on these timeframes are less prone to whipsaws, while the volume delta analysis captures multi-day trading sessions and institutional activity.

For Position Trading:
Optimal Timeframes: Daily and weekly charts
Why: On these higher timeframes, trendlines become extremely reliable as they represent significant market structure points. The volume delta analysis reveals longer-term accumulation and distribution patterns that can define major support and resistance zones for weeks or months.

Timeframe-Specific Adjustments:
Lower Timeframes (1-15 minutes):
Reduce left/right bars for pivots (5-8 bars)
Decrease lookback period for volume delta (50-100 bars)
Increase tolerance multiplier (1.2-1.5) to account for higher volatility
Higher Timeframes (Daily+):
Increase left/right bars for pivots (15-20 bars)
Extend lookback period for volume delta (300-500 bars)
Consider increasing the number of price rows (70-100) for more detailed volume analysis

Usage Guidelines-

For Trendline Analysis:
Use the trendlines as dynamic support and resistance levels
Price reactions at these levels can indicate potential trend continuation or reversal points
The filled zones around trendlines represent areas of price volatility or uncertainty
Consider the slope of the trendline as an indication of trend strength

For Volume Delta Analysis:
The horizontal delta bars show where buying or selling pressure has been concentrated
Green bars indicate areas where buying volume exceeded selling volume (demand)
Red bars indicate areas where selling volume exceeded buying volume (supply)
The highlighted supply and demand zones on the price chart represent significant price levels
These zones can act as future support or resistance areas as price revisits them

Customization Tips:
Trendline Sensitivity: Decrease left/right bars values to detect more pivots (more sensitive) or increase them for fewer, more significant pivots
Zone Width: Adjust the tolerance multiplier to make trendline zones wider or narrower based on your trading style
Volume Analysis: Increase the lookback period for a longer-term volume profile or decrease it for more recent activity
Visual Clarity: Adjust colors and transparency settings to match your chart theme and preferences

Conclusion:
This indicator provides traders with a comprehensive view of both trend dynamics and volume-based support/resistance levels. With these two analytical approaches, the indicator offers valuable insights for identifying potential entry and exit points, trend strength, and key price levels where significant market activity has occurred. The extensive customization options allow traders to adapt the indicator to various trading styles and timeframes, with optimal performance on 15-minute to daily charts depending on their trading horizon.

Chart Attached: NSE HINDZINC, EoD 12/12/25

DISCLAIMER: This information is provided for educational purposes only and should not be considered financial, investment, or trading advice. Please do boost if you like it. Happy Trading.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.