Indicator · Pine Script v6 · On the chart

Structural Levels & Key Zones

by dcaoyuan

Calculates swing points, dynamic support and resistance channels, and a baseline trend moving average directly on the price chart.

View on GitHub

GitHub stars55on the repository
Pine versionv6current
Lines of code29
Settings0inputs
LicenceApache-2.0
Last update6 months ago20 Apr 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

29 lines of Pine Script v6 from public/indicators/structual.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

structual.pine
//@version=6
indicator("Structural Levels & Key Zones", overlay=true)

// --- Logic for Structural Highs and Lows (Fractals) ---
// We identify local peaks and troughs to determine market structure
leftBars = 10
rightBars = 10
ph = ta.pivothigh(high, leftBars, rightBars)
pl = ta.pivotlow(low, leftBars, rightBars)

// Plotting Fractals (Key Swing Points)
plotshape(ph, title="Structural High", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, offset=-rightBars)
plotshape(pl, title="Structural Low", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, offset=-rightBars)

// --- Dynamic Support & Resistance using Donchian Channels ---
// This helps visualize the immediate trading range
len = 20
upper = ta.highest(len)
lower = ta.lowest(len)
basis = math.avg(upper, lower)

plot(upper, "Resistance Zone", color=color.new(color.red, 50), linewidth=1)
plot(lower, "Support Zone", color=color.new(color.green, 50), linewidth=1)
plot(basis, "Mid-Term Pivot", color=color.new(color.gray, 50), style=plot.style_circles)

// --- Key Moving Averages for Trend Structure ---
// 200 EMA often acts as the major structural floor/ceiling
ema200 = ta.ema(close, 200)
plot(ema200, "200 EMA Structure", color=color.orange, linewidth=2)

Overview

Structural Levels & Key Zones identifies structural highs and lows using 10-bar pivot logic, plotting colored triangles offset to confirmed swing bars. Dynamic resistance and support zones are derived from a 20-period Donchian Channel along with its midpoint pivot line. A 200-period Exponential Moving Average highlights long-term structural trend direction. Pivot markers appear retroactively after 10 confirmation bars pass.

Details

Published by

dcaoyuan on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Support & resistance, Trend, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

aicharttradingvibepinescripttechnical-analysispinestock

Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

257 stars

This indicator analyzes short-term price action on index futures and options charts by applying Rational Quadratic kernel smoothing to detect sideways consolidation ranges and potential breakouts. It processes pivot highs and lows over customizable loopback pe

Indicator v5 Support & resistanceTrend Repaints
Updated 6 weeks ago · None stated GitHub repository of SPX 30M - Trading Chart

Ichimoku Cloud

by harryguiacorn
219 stars

This indicator plots Ichimoku Cloud elements on the price chart, including Tenkan-sen, Kijun-sen, Senkou Span A and B lines with optional Chikou Span. It signals trend changes via Tenkan-sen and Kijun-sen crosses and places arrows at Kijun-sen direction shifts

Indicator v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ichimoku Cloud

MA Envelope (MAE)

by mihakralj
99 stars

The MA Envelope indicator calculates upper and lower channel bands shifted by a user-defined percentage around a baseline moving average. It supports Simple Moving Average, Exponential Moving Average, and Weighted Moving Average calculation types. The script p

Indicator v6 Moving averagesSupport & resistance
Updated 4 weeks ago · Apache-2.0 GitHub repository of MA Envelope (MAE)
56 stars

This indicator calculates an Exponential Moving Average and a Zero-Lag Moving Average to identify market trends on the price chart. It plots both moving averages and fills the space between them with color to highlight trend direction. Upon a crossover or cros

Indicator v5 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of No-Lag MA Trend Levels

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers