OPEN-SOURCE SCRIPT
Jim Sloman's Adam Theory - Second Reflection Line

//version=5
indicator("Jim Sloman's Adam Theory - Second Reflection Line", overlay=true, shorttitle="Adam", max_lines_count=500)
//────────────────────────────
// 📥 Inputs
//────────────────────────────
src = input.source(close, "Source")
forecast = input.int(250, "Forecast", minval=1, maxval=500)
linewidth = input.int(2, "Line Width")
linecolor = input.color(color.purple, "Line Color")
ls_input = input.string("Solid", "Line Style", options = ["Solid", "Dashed", "Dotted"])
show_lines = input.bool(true, "Show Reflection Lines")
//────────────────────────────
// 🎨 Estilo de línea (versión corregida)
//────────────────────────────
ls_style = if ls_input == "Dashed"
line.style_dashed
else if ls_input == "Dotted"
line.style_dotted
else
line.style_solid
//────────────────────────────
// 🧱 Array persistente para líneas
//────────────────────────────
var line[] lines = array.new_line()
//────────────────────────────
// ✏️ Función para dibujar línea
//────────────────────────────
f_draw_line(_x1, _y1, _x2, _y2) =>
l = line.new(_x1, _y1, _x2, _y2, xloc = xloc.bar_index)
line.set_color(l, linecolor)
line.set_width(l, linewidth)
line.set_style(l, ls_style)
array.push(lines, l)
//────────────────────────────
// 🧠 Lógica principal
//────────────────────────────
if barstate.islast
// Limpiar líneas si el usuario las oculta
if not show_lines
for l in lines
line.delete(l)
array.clear(lines)
else
ref = src
// Evitar errores si forecast excede barras disponibles
valid_forecast = math.min(forecast, bar_index)
// Crear o actualizar las líneas
if array.size(lines) == 0
for i = 0 to valid_forecast - 2
d1 = src
d2 = src[i + 1]
inv_d1 = ref - (d1 - ref)
inv_d2 = ref - (d2 - ref)
f_draw_line(bar_index + i, inv_d1, bar_index + i + 1, inv_d2)
else
for i = 0 to valid_forecast - 2
d1 = src
d2 = src[i + 1]
inv_d1 = ref - (d1 - ref)
inv_d2 = ref - (d2 - ref)
l = array.get(lines, i)
line.set_xy1(l, bar_index + i, inv_d1)
line.set_xy2(l, bar_index + i + 1, inv_d2)
// Actualiza estilo visual por si el usuario cambia inputs
line.set_color(l, linecolor)
line.set_width(l, linewidth)
line.set_style(l, ls_style)
indicator("Jim Sloman's Adam Theory - Second Reflection Line", overlay=true, shorttitle="Adam", max_lines_count=500)
//────────────────────────────
// 📥 Inputs
//────────────────────────────
src = input.source(close, "Source")
forecast = input.int(250, "Forecast", minval=1, maxval=500)
linewidth = input.int(2, "Line Width")
linecolor = input.color(color.purple, "Line Color")
ls_input = input.string("Solid", "Line Style", options = ["Solid", "Dashed", "Dotted"])
show_lines = input.bool(true, "Show Reflection Lines")
//────────────────────────────
// 🎨 Estilo de línea (versión corregida)
//────────────────────────────
ls_style = if ls_input == "Dashed"
line.style_dashed
else if ls_input == "Dotted"
line.style_dotted
else
line.style_solid
//────────────────────────────
// 🧱 Array persistente para líneas
//────────────────────────────
var line[] lines = array.new_line()
//────────────────────────────
// ✏️ Función para dibujar línea
//────────────────────────────
f_draw_line(_x1, _y1, _x2, _y2) =>
l = line.new(_x1, _y1, _x2, _y2, xloc = xloc.bar_index)
line.set_color(l, linecolor)
line.set_width(l, linewidth)
line.set_style(l, ls_style)
array.push(lines, l)
//────────────────────────────
// 🧠 Lógica principal
//────────────────────────────
if barstate.islast
// Limpiar líneas si el usuario las oculta
if not show_lines
for l in lines
line.delete(l)
array.clear(lines)
else
ref = src
// Evitar errores si forecast excede barras disponibles
valid_forecast = math.min(forecast, bar_index)
// Crear o actualizar las líneas
if array.size(lines) == 0
for i = 0 to valid_forecast - 2
d1 = src
d2 = src[i + 1]
inv_d1 = ref - (d1 - ref)
inv_d2 = ref - (d2 - ref)
f_draw_line(bar_index + i, inv_d1, bar_index + i + 1, inv_d2)
else
for i = 0 to valid_forecast - 2
d1 = src
d2 = src[i + 1]
inv_d1 = ref - (d1 - ref)
inv_d2 = ref - (d2 - ref)
l = array.get(lines, i)
line.set_xy1(l, bar_index + i, inv_d1)
line.set_xy2(l, bar_index + i + 1, inv_d2)
// Actualiza estilo visual por si el usuario cambia inputs
line.set_color(l, linecolor)
line.set_width(l, linewidth)
line.set_style(l, ls_style)
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.