BINANCE:BTCUSDT   Bitcoin / TetherUS
//@version=5
strategy("Estrategia Completa", overlay=true)

// Definir medias móviles
fastLength = input(9, title="Fast MA Length")
slowLength = input(21, title="Slow MA Length")
fastMA = sma(close, fastLength)
slowMA = sma(close, slowLength)

// Definir RSI
rsiLength = input(14, title="RSI Length")
rsiLevel = input(70, title="RSI Overbought Level")
rsiCondition = rsi(close, rsiLength) > rsiLevel

// Definir MACD
= macd(close, 12, 26, 9)
macdCondition = crossover(macdLine, signalLine)

// Definir volumen
volCondition = volume > sma(volume, 20)

// Condiciones de entrada y salida
longCondition = crossover(fastMA, slowMA) and rsiCondition and macdCondition and volCondition
shortCondition = crossunder(fastMA, slowMA) and rsiCondition and macdCondition and volCondition

// Ejecutar estrategia
strategy.entry("Long", strategy.long, when=longCondition)
strategy.entry("Short", strategy.short, when=shortCondition)
strategy.close("Long", when=shortCondition)
strategy.close("Short", when=longCondition)

// Plotear medias móviles
plot(fastMA, color=color.blue, title="Fast MA")
plot(slowMA, color=color.red, title="Slow MA")

// Plotear RSI
hline(rsiLevel, "RSI Overbought", color=color.red)

// Plotear MACD
plot(macdLine - signalLine, color=color.green, title="MACD Histogram")

// Plotear volumen
plot(volume, color=color.purple, title="Volume")
Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.