OPEN-SOURCE SCRIPT

JJtrading

//version=5
indicator("Estrategia de Alto/Bajo Mejorada", overlay=true)

// Variables para almacenar altos y bajos
var float highestHigh = na
var float lowestLow = na
var float penultimateHigh = na
var float penultimateLow = na

// Definir períodos para los altos y bajos (ajusta el periodo según tu estrategia)
alto_mas_alto = ta.highest(high, 20)
bajo_mas_bajo = ta.lowest(low, 20)

// Actualizar los valores de altos y bajos
if (na(highestHigh) or high > highestHigh)
penultimateHigh := highestHigh
highestHigh := alto_mas_alto
if (na(lowestLow) or low < lowestLow)
penultimateLow := lowestLow
lowestLow := bajo_mas_bajo

// Dibujar líneas dinámicas para altos y bajos
var line highLine = line.new(na, na, na, na, color=color.green, width=2)
var line lowLine = line.new(na, na, na, na, color=color.red, width=2)
var line penultimateHighLine = line.new(na, na, na, na, color=color.green, width=1, style=line.style_dashed)
var line penultimateLowLine = line.new(na, na, na, na, color=color.red, width=1, style=line.style_dashed)

// Actualizar las posiciones de las líneas con los altos y bajos más recientes
line.set_xy1(highLine, bar_index[1], highestHigh)
line.set_xy2(highLine, bar_index, highestHigh)

line.set_xy1(lowLine, bar_index[1], lowestLow)
line.set_xy2(lowLine, bar_index, lowestLow)

line.set_xy1(penultimateHighLine, bar_index[1], penultimateHigh)
line.set_xy2(penultimateHighLine, bar_index, penultimateHigh)

line.set_xy1(penultimateLowLine, bar_index[1], penultimateLow)
line.set_xy2(penultimateLowLine, bar_index, penultimateLow)

// Condiciones de rompimiento para compra
compra = close > highestHigh
if (compra)
label.new(bar_index, high, text="Compra", style=label.style_label_up, color=color.green, textcolor=color.white)

// Condiciones de rompimiento para venta
venta = close < lowestLow
if (venta)
label.new(bar_index, low, text="Venta", style=label.style_label_down, color=color.red, textcolor=color.white)

// Opcional: Alerta cuando se cumpla la condición
alertcondition(compra, title="Alerta de Compra", message="Se ha roto el alto más alto, considera una compra.")
alertcondition(venta, title="Alerta de Venta", message="Se ha roto el bajo más bajo, considera una venta.")
Bands and Channels

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

면책사항