This overlay indicator smooths a rolling highest low and lowest high with a rational quadratic kernel, then holds a step line that switches between those two smoothed levels when the selected source crosses them.
1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
52 lines of Pine Script v5 from highest-lowest-visual.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
highest-lowest-visual.txt
// This Pine Scriptβ’ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
indicator("Donald - Highest-Lowest Visual", shorttitle = "Donald - Highest-Lowest Visual", overlay = true)
import jdehorty/KernelFunctions/2 as kernels
/// ππππ ππππππ ///
int length = input(6, group = "οΌ³ο½ ο½ο½ο½ο½ο½ο½")
int offset = input(4, group = "οΌ³ο½ ο½ο½ο½ο½ο½ο½")
series float src = input(close, group = "οΌ³ο½ ο½ο½ο½ο½ο½ο½")
bool Use_High_and_Low = input(false, group = "οΌ³ο½ ο½ο½ο½ο½ο½ο½")
// Visual
bool bar_color = input(false, group = "οΌΆο½ο½ο½ο½ο½")
color color_up = input(color.blue, group = "οΌΆο½ο½ο½ο½ο½")
color color_dn = input(color.red, group = "οΌΆο½ο½ο½ο½ο½")
// Kernel Settings
lookbackWindow = input.int(8, "Lookback Window", tooltip="The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars. Recommended range: 3-50", group="Kernel Settings")
relativeWeighting = input.float(8., "Relative Weighting", step=0.25, tooltip="Relative weighting of time frames. As this value approaches zero, the longer time frames will exert more influence on the estimation. As this value approaches infinity, the behavior of the Rational Quadratic Kernel will become identical to the Gaussian kernel. Recommended range: 0.25-25", group="Kernel Settings")
startBar = input.int(25, "Start Regression at Bar", tooltip="Bar index on which to start regression. The first bars of a chart are often highly volatile, and omission of these initial bars often leads to a better overall fit. Recommended range: 5-25", group="Kernel Settings")
highestHigh = kernels.rationalQuadratic(ta.highest(low, length), lookbackWindow, relativeWeighting, startBar)
lowestLow = kernels.rationalQuadratic(ta.lowest(high, length), lookbackWindow, relativeWeighting, startBar)
/// πππΏππΎπΌπππ πΎπΌππΎπππΌππππ ///
var series float hlt = 0.0
series float upper = highestHigh
series float lower = lowestLow
hlt := src > upper ?
lower : src < lower ?
upper : nz(hlt)
/// ππππ ///
color color = src >= hlt
? color_up
: color_dn
p1 = plot(hlt,
color = color,
style = plot.style_cross
)
p2 = plot(src, display = display.none)
fill(p1, p2, color = color.new(color, 80))
// Bar color
barcolor(bar_color ? color : na)
Overview
Donald - Highest-Lowest Visual plots that line as crosses on the price chart, fills the area between the line and the source, and can color bars with the same up or down state. Length, source, kernel lookback, relative weighting, and the regression start bar change the calculation. It is visual only and has no trade entries or exits.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
length
int
6
length
offset
int
4
offset
src
source
close
src
Use_High_and_Low
bool
false
Use_High_and_Low
bar_color
bool
false
bar_color
color_up
color
color.blue
color_up
color_dn
color
color.red
color_dn
Lookback Window
int
8
lookbackWindow
Relative Weighting
float
8.
relativeWeighting
Start Regression at Bar
int
25
startBar
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.
This indicator detects equal highs and lows by comparing prices within user-defined left and right bars using a tolerance percentage. It plots horizontal lines on the price chart for equal highs in one color and lows in another. A screener allows input of mult
This indicator fits a linear regression through stored pivot highs and lows and draws the resulting channel on the price chart. A function returns predicted values, maximum and minimum deviations, and the average absolute deviation. Confirmed two-bar pivots up
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
This indicator identifies local swing highs and swing lows to construct a Zig Zag pattern on the main price chart. It evaluates pivot points based on a customizable number of surrounding left and right bars. Using persistent variables, the script tracks previo
Dynamic Linear Regression calculates and plots linear regression trendlines and standard deviation channels directly on the price chart over a user-selected time period. Traders can configure static channels locked at the end time, dynamic channels that contin
This indicator implements the Fractal Model concept to plot market structure shifts, liquidity sweeps, and Change in State of Delivery (CISD) levels. It overlays custom higher-timeframe candle previews, open prices, and time markers directly on the price chart