Highest Indicator Pine Script — Complete TradingView Guide
The Highest indicator in Pine Script uses the built-in ta.highest(source, length) function to track the maximum value of a price series over a rolling lookback window. Applied to the high series, it plots the highest high over the last N bars as a continuous line on your TradingView chart — making it the foundational building block for Donchian Channels, breakout detection systems, and dynamic resistance overlays. It works on all asset classes (stocks, crypto, forex, futures) and all timeframes from 1-minute to weekly charts. This guide covers the complete Pine Script v6 implementation, all configurable parameters, three concrete trading strategies, and step-by-step instructions for generating it instantly with Pineify.
What Is the Highest Indicator?
The Highest indicator is a range-tracking overlay that continuously plots the maximum price value over a user-defined lookback period. Unlike momentum oscillators (RSI, MACD) that measure rate-of-change, the Highest indicator answers a single precise question: "What is the peak value within the last N bars?" This makes it fundamentally different from smoothing tools like moving averages, which average values and obscure the actual high-water mark.
In Pine Script v6, the Highest indicator is implemented via the built-in function ta.highest(source, length). The function scans the most recent length bars of source, ignores na values, and returns the single highest number. The result is a series float that updates on every bar.
Formula: Highest[t] = max(source[t], source[t-1], ..., source[t-length+1]), where t is the current bar index, and the result is the maximum across the window.
Best Markets
Stocks · Crypto · Forex · Futures
Best Timeframes
15m, 1H, 4H, Daily
Overlay
Yes — plots directly on price chart
Highest Indicator Pine Script Code
The code below plots the 5-bar highest high as a green line overlaid on the price chart. Copy it, open the TradingView Pine Script editor (Alt+P), paste it in, and click Add to chart. Change the 5 in ta.highest(high, 5) to any lookback period you need.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Pineify
//@version=6
indicator(title="Highest", overlay=true, max_labels_count=500)
// Returns the highest high over the last 5 bars
p_ind_1 = ta.highest(high, 5)
// Plot the result on the chart
plot(p_ind_1, "Highest", color.rgb(76, 175, 80, 0), 1)Chart Preview

Parameters
| Parameter | Default Value | Description | Recommended Range |
|---|---|---|---|
| source | high | The series to scan for the maximum. Any numeric series: high, close, or a calculated value. | Any numeric series |
| length | user-defined | Number of bars in the lookback window. Larger values produce a smoother, slower-moving line. Smaller values react faster to recent highs. | 5–252 depending on style |
Tuning Guide by Trading Style
- Scalping (1m–5m charts): length 5–10 — captures intraday swing highs with fast response
- Day trading (15m–1H charts): length 14–20 — balances noise reduction with timely signals
- Swing trading (4H–Daily charts): length 20–55 — the classic Turtle Trading channel lengths
- Position trading (Daily–Weekly charts): length 52–252 — tracks the 52-week high for major resistance
Trading Strategies Using the Highest Indicator
The Highest indicator is most effective as a dynamic resistance level or breakout trigger. Below are three concrete strategies with specific entry conditions.
Strategy 1 — Donchian Channel Breakout
Market environment: trending markets · Best timeframe: Daily, 4H
The Donchian Channel breakout is the core logic of the classic Turtle Trading system, developed by Richard Dennis and William Eckhardt in the 1980s. Pair ta.highest(high, 20) with ta.lowest(low, 20) to form the channel.
- Calculate the 20-bar highest high:
upper = ta.highest(high, 20)[1](use [1] offset to avoid repainting) - Calculate the 20-bar lowest low:
lower = ta.lowest(low, 20)[1] - Long entry: close crosses above
upper - Exit: close crosses below
lower, or use a 10-bar exit channel - Position size: risk 1–2% of account per trade
Strategy 2 — 52-Week High Momentum
Market environment: bull markets · Best timeframe: Daily, Weekly
Stocks making new 52-week highs exhibit strong momentum and are historically more likely to continue rising (momentum effect, documented by Jegadeesh and Titman, 1993).
- Calculate 252-day highest high on daily chart:
yearly_high = ta.highest(high, 252)[1] - Entry signal: close > yearly_high (new 52-week high on close)
- Confirm with above-average volume:
volume > ta.sma(volume, 20) * 1.5 - Stop loss: below the prior 10-bar lowest low
- Hold until close falls below the 20-day SMA
Strategy 3 — Highest High + RSI Divergence Filter
Market environment: topping / reversals · Best timeframe: 4H, Daily
When price makes a new highest high but RSI makes a lower high, bearish divergence warns of weakening momentum. This filters false breakouts.
- Plot 20-bar highest high:
upper = ta.highest(high, 20) - Calculate RSI(14):
rsi = ta.rsi(close, 14) - Bullish breakout confirmed: close > upper[1] AND rsi > rsi[1] (RSI confirms momentum)
- False breakout warning: close > upper[1] AND rsi < rsi[1] (bearish divergence — avoid or reduce size)
- Add volume confirmation: require volume > 20-bar average volume
Disclaimer: The strategies above are for educational purposes only and do not constitute investment advice. Past performance does not guarantee future results. Always apply proper risk management and position sizing.
How to Generate the Highest Indicator in Pineify
- 1
Open Pineify
Go to editor.pineify.app and sign in — a free account is sufficient.
- 2
Click "New Indicator"
Select "Indicator" as the script type from the creation menu.
- 3
Describe what you want
Type a prompt such as: "Plot the 20-bar highest high as a green overlay line on the price chart." Pineify's AI Coding Agent generates the complete Pine Script v6 code in seconds.
- 4
Copy to TradingView
Click "Copy to TradingView" to copy the code, then paste it into the TradingView Pine Script editor (Alt+P) and click "Add to chart".
- 5
Adjust the length parameter
In the TradingView indicator settings panel, change the lookback length to match your trading style — no code editing required.
Frequently Asked Questions
Build Your Highest Indicator in Seconds
Skip the manual coding. Pineify's AI Coding Agent generates complete, ready-to-use Pine Script indicators — including ta.highest() breakout strategies — instantly for free.
Try Pineify Free