//@version=5
indicator("jhonmas", overlay=true, max_bars_back=1000, max_labels_count=500,
max_lines_count=500, max_boxes_count=500)
// =========================
// CLAVE ÚNICA
// =========================
claveIngresada = [Link](defval="", title="🔐 Ingrese su contraseña")
claveValida = "\\6bS61a\\Jhon*1986"
if claveIngresada != claveValida
[Link]("❌ Acceso denegado. Clave incorrecta. Indicador protegido por Jhon Fredy
Martinez Rosas.")
// =========================
// --- COLOREO DE VELAS ---
// =========================
volLength = [Link](20, title="Longitud Promedio de Volumen")
volMultiplier = [Link](1.5, title="Multiplicador de Volumen")
imbalanceThreshold = [Link](0.5, title="% Imbalance", step=0.01)
rsiLength = [Link](14, title="RSI Length")
useHTFConfirm = [Link](true, "Usar confirmación RSI HTF")
htf = [Link]("30", "Temporalidad HTF")
avgVol = [Link](volume, volLength)
volSpike = volume > avgVol * volMultiplier
bid = close < open ? low : open
ask = close > open ? high : close
spread = ask - bid
imbalance = spread != 0 ? [Link](close - open) / spread : 0
isBullVol = volSpike and close > open and imbalance > imbalanceThreshold
isBearVol = volSpike and close < open and imbalance > imbalanceThreshold
rsi = [Link](close, rsiLength)
rsiHTF = [Link]([Link], htf, [Link](close, rsiLength))
isRSIOverbought = useHTFConfirm ? (rsi > 70 and rsiHTF > 60) : (rsi > 70)
isRSIOversold = useHTFConfirm ? (rsi < 30 and rsiHTF < 40) : (rsi < 30)
color colorOriginal = na
colorOriginal := isBullVol and isRSIOverbought ? #FF0000 :
isBearVol and isRSIOversold ? #00FF00 :
isRSIOverbought ? #FFA500 :
isRSIOversold ? #800080 :
isBullVol ? #0000FF :
isBearVol ? #FFFF00 : na
// =========================
// --- SESIONES HISTÓRICAS ---
// =========================
f_draw_sessions(_enabled, _session, _color) =>
var float hi = na
var float lo = na
var int startTime = na
inSession = not na(time([Link], _session))
newSession = inSession and not inSession[1]
endSession = not inSession and inSession[1]
if _enabled
if newSession
hi := high
lo := low
startTime := time
else if inSession
hi := [Link](hi, high)
lo := [Link](lo, low)
if endSession
[Link](left=startTime, right=time, top=hi, bottom=lo, xloc=xloc.bar_time, bgcolor=_color,
border_width=0)
showAsia = [Link](true, title="Mostrar sesión Asia")
timeAsia = [Link]("1700-0100", title="Horario Asia")
colorAsia = [Link]([Link](#1E90FF, 85), title="Color Asia")
showLondon = [Link](true, title="Mostrar sesión Londres")
timeLondon = [Link]("0300-0700", title="Horario Londres")
colorLondon = [Link]([Link](#32CD32, 85), title="Color Londres")
showNewYork = [Link](true, title="Mostrar sesión NY")
timeNY = [Link]("0830-1100", title="Horario NY")
colorNY = [Link]([Link](#FFA500, 85), title="Color NY")
f_draw_sessions(showAsia, timeAsia, colorAsia)
f_draw_sessions(showLondon, timeLondon, colorLondon)
f_draw_sessions(showNewYork, timeNY, colorNY)
// =========================
// --- CÁLCULO DEL PIP CORRECTO ---
// =========================
get_pip_size() =>
isJPY = [Link]([Link], "JPY")
isXAU = [Link] == "XAUUSD"
isUS30 = [Link] == "US30"
isUS100 = [Link] == "US100"
isWTI = [Link] == "WTI"
isJPY ? 0.01 :
isXAU ? 1 :
isUS30 ? 10 :
isUS100 ? 5 :
isWTI ? 0.1 : 0.0001
pip = get_pip_size()
// =========================
// --- NIVELES INSTITUCIONALES (M30) ---
// =========================
showLines = [Link](true, title="🔍 Mostrar niveles institucionales")
lineColorUp = [Link]([Link], "Color líneas +100 pips")
lineColorDown = [Link]([Link], "Color líneas -100 pips")
lineThickness = [Link](1, title="Grosor de líneas", minval=1, maxval=5)
visible = timeframe.in_seconds([Link]) <= timeframe.in_seconds("30")
enM30 = [Link] == "30"
baseLevel = [Link]([Link], "30", [Link](close / pip) * pip)
var float anchor = na
if (bar_index == 0)
anchor := baseLevel
else
rompimientoSuperior = close > anchor + pip * 100 and open > anchor + pip * 100
rompimientoInferior = close < anchor - pip * 100 and open < anchor - pip * 100
if enM30 and (rompimientoSuperior or rompimientoInferior)
anchor := baseLevel
if showLines and visible
for i = -100 to 100 by 25
nivel = anchor + pip * i
colorNivel = i == 0 or i == 100 or i == -100 ? [Link] : i > 0 ? lineColorUp : lineColorDown
[Link](bar_index, nivel, bar_index + 1, nivel, color=colorNivel, width=lineThickness,
extend=[Link])
// =========================
// --- MEJORA: ROMPIMIENTO CON MECHA + RSI EXTREMO ---
// =========================
isWickBreak = false
for i = -100 to 100 by 25
nivel = anchor + pip * i
rompeConMechaArriba = high > nivel and close < nivel and open < nivel
rompeConMechaAbajo = low < nivel and close > nivel and open > nivel
isWickBreak := isWickBreak or (rompeConMechaArriba or rompeConMechaAbajo)
highlightBar = visible and isWickBreak and (isRSIOverbought or isRSIOversold)
barcolor(highlightBar ? [Link] : colorOriginal)