OPEN-SOURCE SCRIPT

ERL & IRL (Swing Levels) Sunnat

109
//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)

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。