actualizame este script para la version 6 del editor Pine.  @version=5
indicator("Combined Indicators with Alerts", overlay=true)

// --- CM_Stochastic_MTF ---
len = input(14, minval=1, title="Length for Main Stochastic")
smoothK = input(3, minval=1, title="SmoothK for Main Stochastic")
smoothD = input(3, minval=1, title="SmoothD for Main Stochastic")
upLine = input(90, minval=50, maxval=90, title="Upper Line Value?") // Cambiado a 90
lowLine = input(10, minval=10, maxval=50, title="Lower Line Value?") // Cambiado a 10
sml = input(true, title="Show Mid Line?")
sbh = input(false, title="Show Back Ground Highlights When Stoch is Above/Below High/Low Lines?")
sch = input(true, title="Show Back Ground Highlights When Stoch Cross - Strict Criteria - K Greater/LesThan High/Low Line - Crosses D?")
sl = input(true, title="Show 'B' and 'S' Letters When Stoch Crosses High/Low Line & D?")
sac = input(false, title="Show Back Ground Highlights When Stoch Cross - Any Cross?")
sacl = input(false, title="Show 'B' and 'S' Letters When Stoch Crosses - Any Cross?")
useCurrentRes = input(true, title="Use Current Chart Resolution?")
resCustom = input.timeframe("60", title="Use Different Timeframe? Uncheck Box Above")
ssStoch = input(false, title="Show 2nd Stoch?")
resCustom2 = input.timeframe("D", title="Use 2nd Stoch? Check Box Above")
len2 = input(14, minval=1, title="2nd Stoch Length")
smoothK2 = input(3, minval=1, title="SmoothK for 2nd Stoch")
smoothD2 = input(3, minval=1, title="SmoothD for 2nd Stoch")

// Resolution for MTF
res = useCurrentRes ? timeframe.period : resCustom
k = ta.sma(ta.stoch(close, high, low, len), smoothK)
d = ta.sma(k, smoothD)
outK = request.security(syminfo.tickerid, res, k)
outD = request.security(syminfo.tickerid, res, d)

k2 = ta.sma(ta.stoch(close, high, low, len2), smoothK2)
d2 = ta.sma(k2, smoothD2)
outK2 = request.security(syminfo.tickerid, resCustom2, k2)
outD2 = request.security(syminfo.tickerid, resCustom2, d2)

// Definitions for Cross
crossUp = (outK[1] < outD[1]) and (outK > outD and outK > upLine)
crossDn = (outK[1] > outD[1]) and (outK < outD and outK < lowLine)

// Plot main Stochastic
plot(outK, title="Stoch K", color=color.lime, linewidth=3)
plot(outD, title="Stoch D", color=color.red, linewidth=3)

// --- WMAMulti ---
tf1 = input("15", title="time frame 1")
tf2 = input("30", title="time frame 2")
tf3 = input("60", title="time frame 3")
length = input(20, title="length")

ma1 = request.security(syminfo.tickerid, tf1, ta.wma(hl2, length))
ma2 = request.security(syminfo.tickerid, tf2, ta.wma(hl2, length))
ma3 = request.security(syminfo.tickerid, tf3, ta.wma(hl2, length))

getcolor(avg, tf) =>
prev = request.security(syminfo.tickerid, tf, ta.wma(hl2, length)[1])
avg >= prev ? color.green : color.red

// Plot WMA
plot(ma1, color=getcolor(ma1, tf1), linewidth=3)
plot(ma2, color=getcolor(ma2, tf2), linewidth=3)
plot(ma3, color=getcolor(ma3, tf3), linewidth=3)

// Cruces WMA
crossWMA_UP = ta.crossover(ma1, ma2) // MA de 15 cruza por encima de MA de 30
crossWMA_DOWN = ta.crossover(ma2, ma1) // MA de 30 cruza por encima de MA de 15

// --- SQZMOM_LB ---
lengthSQZ = input(20, title="BB Length")
mult = input(2.0, title="BB MultFactor")
lengthKC = input(20, title="KC Length")
multKC = input(1.5, title="KC MultFactor")
useTrueRange = input(true, title="Use TrueRange (KC)", type=input.bool)

// Calculate BB
source = close
basis = ta.sma(source, lengthSQZ)
dev = multKC * ta.stdev(source, lengthSQZ)
upperBB = basis + dev
lowerBB = basis - dev

// Calculate KC
ma = ta.sma(source, lengthKC)
range = useTrueRange ? ta.tr : (high - low)
rangema = ta.sma(range, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC

sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz = not sqzOn and not sqzOff

val = ta.linreg(source - math.avg(math.highest(high, lengthKC), math.lowest(low, lengthKC)), lengthKC, 0)

bcolor = val > 0 ? (val > nz(val[1]) ? color.lime : color.green) : (val < nz(val[1]) ? color.red : color.maroon)
scolor = noSqz ? color.blue : sqzOn ? color.black : color.gray

plot(val, color=bcolor, style=plot.style_histogram, linewidth=4)
plot(0, color=scolor, style=plot.style_cross, linewidth=2)

// --- Alerts ---
// Alert conditions
buyCondition = crossUp and sqzOn and crossWMA_UP and close > ma3 // Cruza hacia arriba, squeeze on, cruza WMA y precio por encima de la MA de 60
sellCondition = crossDn and sqzOff and crossWMA_DOWN and close < ma3 // Cruza hacia abajo, squeeze off, cruza WMA y precio por debajo de la MA de 60

// Alert conditions
alertcondition(buyCondition, title="Buy Alert", message="Buy Signal: Stochastic Cross Up in Overbought Zone + Squeeze On + WMA Cross Up + Price Above WMA!")
alertcondition(sellCondition, title="Sell Alert", message="Sell Signal: Stochastic Cross Down in Oversold Zone + Squeeze Off + WMA Cross Down + Price Below WMA!")

// Optional plot for visual verification
plotshape(buyCondition, style=shape.labelup, location=location.belowbar, color=color.green, size=size.small, title="Buy Alert Signal", text="BUY")
plotshape(sellCondition, style=shape.labeldown, location=location.abovebar, color=color.red, size=size.small, title="Sell Alert Signal", text="SELL")