OPEN-SOURCE SCRIPT

ERL & IRL (Swing Levels) Sunnat

108
//version=5
indicator("ERL & IRL (Swing Levels)", overlay=true)

// Inputs
left_bars = input.int(5, "Left bars (swing strength)", minval=1)
right_bars = input.int(5, "Right bars (swing strength)", minval=1)
line_len = input.int(10, "Line length (bars)", minval=1) // short line

// Detect swing high (ERL) and swing low (IRL)
swingHigh = ta.pivothigh(high, left_bars, right_bars)
swingLow = ta.pivotlow(low, left_bars, right_bars)

// Draw ERL when swing high is found
if not na(swingHigh)
line.new(bar_index - right_bars, swingHigh,
bar_index - right_bars + line_len, swingHigh,
xloc=xloc.bar_index, extend=extend.none,
color=color.aqua, width=2)
label.new(bar_index - right_bars + line_len, swingHigh, "ERL",
xloc=xloc.bar_index, yloc=yloc.price,
color=color.new(color.aqua, 0), textcolor=color.black)

// Draw IRL when swing low is found
if not na(swingLow)
line.new(bar_index - right_bars, swingLow,
bar_index - right_bars + line_len, swingLow,
xloc=xloc.bar_index, extend=extend.none,
color=color.orange, width=2)
label.new(bar_index - right_bars + line_len, swingLow, "IRL",
xloc=xloc.bar_index, yloc=yloc.price,
color=color.new(color.orange, 0), textcolor=color.black)

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.