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)
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.