OPEN-SOURCE SCRIPT

Livelli Sensibili Orizzontali

110
//version=5
indicator("Livelli Sensibili Orizzontali", overlay=true)

// Funzione per trovare massimi/minimi SOLAMENTE sui punti più alti e più bassi raggiunti con almeno 3 candele decrescenti o crescenti dopo o prima
isSwingHigh(src) =>
ta.highestbars(src, 4) == 0 and high[1] < high and high[2] < high and high[3] < high and ta.valuewhen(high == ta.highest(high, 10), high, 0) == high

isSwingLow(src) =>
ta.lowestbars(src, 4) == 0 and low[1] > low and low[2] > low and low[3] > low and ta.valuewhen(low == ta.lowest(low, 10), low, 0) == low

// Identificazione dei livelli sensibili
var float lastHigh = na
var float lastLow = na

if isSwingHigh(high)
lastHigh := high
if isSwingLow(low)
lastLow := low

// Disegna linee orizzontali SOLO sui massimi e minimi effettivi
line.new(x1=bar_index[3], y1=lastHigh, x2=bar_index, y2=lastHigh, width=2, color=color.red)
line.new(x1=bar_index[3], y1=lastLow, x2=bar_index, y2=lastLow, width=2, color=color.green)

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.