OPEN-SOURCE SCRIPT

Candle Equal High/Low with Connected Lines

Por ajwalia1
Atualizado
//version=5
indicator("Equal High/Low with Connected Lines", overlay=true)

// Set tolerance for price fluctuation
tolerance = input.float(0.5, title="Tolerance", tooltip="Allowed difference for equal highs/lows")

// Set a threshold for significant candles (total candle range)
min_candle_range = input.float(10, title="Minimum Candle Range", tooltip="Minimum range of candle high to low")

// Calculate candle range (difference between high and low)
candle_range = high - low

// Check for equal highs and lows with a tolerance and filter for larger candles
equal_high = math.abs(high - high[1]) <= tolerance and candle_range >= min_candle_range
equal_low = math.abs(low - low[1]) <= tolerance and candle_range >= min_candle_range

// Plot markers on equal highs and lows
plotshape(series=equal_high, title="Equal High", location=location.abovebar, color=color.green, style=shape.triangledown, text="High")
plotshape(series=equal_low, title="Equal Low", location=location.belowbar, color=color.red, style=shape.triangleup, text="Low")

// Declare variables to store the last equal high/low points and their bar indices
var float last_high = na
var int last_high_index = na
var float last_low = na
var int last_low_index = na

// Declare lines for connecting equal highs and lows
var line high_line = na
var line low_line = na

// If an equal high is found, connect it with the last equal high
if (equal_high)
if (not na(last_high) and not na(last_high_index))
line.new(x1=last_high_index, y1=last_high, x2=bar_index, y2=high, color=color.green, width=2, style=line.style_solid) // Connect the points
last_high := high // Update the last high
last_high_index := bar_index // Update the bar index of the last high

// If an equal low is found, connect it with the last equal low
if (equal_low)
if (not na(last_low) and not na(last_low_index))
line.new(x1=last_low_index, y1=last_low, x2=bar_index, y2=low, color=color.red, width=2, style=line.style_solid) // Connect the points
last_low := low // Update the last low
last_low_index := bar_index // Update the bar index of the last low

// Optional: Highlight the background when significant equal highs or lows occur
bgcolor(equal_high ? color.new(color.green, 80) : na)
bgcolor(equal_low ? color.new(color.red, 80) : na)
Notas de Lançamento
//version=5
indicator("Equal High/Low with Two-Candle Connection", overlay=true)

// Set tolerance for price fluctuation
tolerance = input.float(0.5, title="Tolerance", tooltip="Allowed difference for equal highs/lows")

// Set a threshold for significant candles (total candle range)
min_candle_range = input.float(10, title="Minimum Candle Range", tooltip="Minimum range of candle high to low")

// Calculate candle range (difference between high and low)
candle_range = high - low

// Check for equal highs and lows with a tolerance and filter for larger candles
equal_high = math.abs(high - high[1]) <= tolerance and candle_range >= min_candle_range
equal_low = math.abs(low - low[1]) <= tolerance and candle_range >= min_candle_range

// Plot markers on equal highs and lows
plotshape(series=equal_high, title="Equal High", location=location.abovebar, color=color.green, style=shape.triangledown, text="High")
plotshape(series=equal_low, title="Equal Low", location=location.belowbar, color=color.red, style=shape.triangleup, text="Low")

// Declare variables to store the last equal high/low points and their bar indices
var float last_high = na
var int last_high_index = na
var float last_low = na
var int last_low_index = na

// Declare lines for connecting equal highs and lows
var line high_line = na
var line low_line = na

// If an equal high is found, connect it with the previous candle's high if it also had an equal high
if (equal_high and equal_high[1])
line.new(x1=bar_index[1], y1=high[1], x2=bar_index, y2=high, color=color.green, width=2, style=line.style_solid)

// If an equal low is found, connect it with the previous candle's low if it also had an equal low
if (equal_low and equal_low[1])
line.new(x1=bar_index[1], y1=low[1], x2=bar_index, y2=low, color=color.red, width=2, style=line.style_solid)

// Optional: Highlight the background when significant equal highs or lows occur
bgcolor(equal_high ? color.new(color.green, 80) : na)
bgcolor(equal_low ? color.new(color.red, 80) : na)
Candlestick analysisChart patternsTrend Analysis

Script de código aberto

No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Quer usar esse script no gráfico?

Aviso legal