//@version=4
study("Distance from high", "", true)
i_lookBack = input(100)
c_fillColor = color.green
var c_fills = array.new_color(5)
// Initialize the array elements with progressively lighter shades of the fill color.
array.set(c_fills, 0, color.new(c_fillColor, 70))
array.set(c_fills, 1, color.new(c_fillColor, 75))
array.set(c_fills, 2, color.new(c_fillColor, 80))
array.set(c_fills, 3, color.new(c_fillColor, 85))
array.set(c_fills, 4, color.new(c_fillColor, 90))
// Find the offset to highest high. Change its sign because the function returns a negative value.
lastHiBar = - highestbars(high, i_lookBack)
// Convert the offset to an array index, capping it to 4 to avoid a runtime error.
// The index used by `array.get()` will be the equivalent of `floor(fillNo)`.
fillNo = min(lastHiBar / (i_lookBack / 5), 4)
// Set background to a progressively lighter fill with increasing distance from location of highest high.
bgcolor(array.get(c_fills, fillNo))
// Plot key values to the Data Window for debugging.
plotchar(lastHiBar, "lastHiBar", "", location.top, size = size.tiny)
plotchar(fillNo, "fillNo", "", location.top, size = size.tiny)
Overview
Distance from High divides the lookback duration into five segments and applies a progressively lighter background color to the main price chart as the distance from the peak increases. It also outputs the calculated bar offset and tier index values to the Data Window for inspection.
Graduated background shading based on peak distance
Configurable lookback period for highest high detection
Pre-allocated color array with tiered transparency levels
Data Window diagnostics for bar offset and tier index
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
i_lookBack
int
100
i_lookBack
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.
Moving Average Channel plots separate simple moving averages for upper and lower bands on the price chart. It fills the space between bands with semi-transparent color and colors bars green above the upper band, red below the lower band, or gray in between. Us
This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and
This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale
This overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur
The BZ-tracker indicator marks ARK Invest buy and sell transactions on stock charts with labels. It plots green labels for purchases and red labels for sales, each annotated with a multiplier such as X1 or X2 to show the number of ARK ETFs trading the stock on
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