
La estrategia es un sistema de negociación que combina la señal de sobreventa y sobreventa del RSI con el límite de la banda de Brin para administrar el riesgo de negociación mediante el establecimiento de un stop loss dinámico y un stop loss basado en el riesgo-beneficio. El núcleo de la estrategia es generar una señal de negociación cuando el RSI cruza con el nivel de sobreventa y sobreventa, y combinar la posición del precio en la banda de Brin para mejorar la precisión de la negociación.
La estrategia se basa principalmente en los siguientes principios centrales:
La estrategia construye un sistema de negociación completo mediante la combinación de señales de sobreventa y sobreventa en el RSI y la posición en el límite de la banda de Brin. Las ventajas centrales de la estrategia residen en la gestión dinámica del riesgo y la configuración clara de la relación riesgo-beneficio, pero se debe tener en cuenta el riesgo de falsas rupturas y los cambios en el entorno del mercado.
/*backtest
start: 2024-11-23 00:00:00
end: 2025-02-19 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © humblehustle
//@version=5
strategy("RSI Oversold Crossover Strategy", overlay=true)
// === INPUT PARAMETERS ===
rsi_length = input(14, title="RSI Length")
rsi_overbought = input(70, title="RSI Overbought Level")
rsi_oversold = input(30, title="RSI Oversold Level")
// === RSI CALCULATION ===
rsi = ta.rsi(close, rsi_length)
// === ENTRY CONDITIONS ===
long_condition = ta.crossover(rsi, rsi_oversold) // RSI crosses above 30
short_condition = ta.crossunder(rsi, rsi_overbought) // RSI crosses below 70
// === STOP LOSS & TARGET CALCULATION ===
longStop = ta.lowest(low, 10) // Recent swing low for longs
shortStop = ta.highest(high, 10) // Recent swing high for shorts
longTarget = close + (close - longStop) * 2 // 2:1 Risk-Reward
shortTarget = close - (shortStop - close) * 2 // 2:1 Risk-Reward
// === EXECUTE TRADES ===
if long_condition
strategy.entry("Long", strategy.long)
strategy.exit("ExitLong", from_entry="Long", stop=longStop, limit=longTarget)
if short_condition
strategy.entry("Short", strategy.short)
strategy.exit("ExitShort", from_entry="Short", stop=shortStop, limit=shortTarget)
// === ALERTS ===
alertcondition(long_condition, title="Long Signal", message="BUY: RSI Crossed Above 30 (Oversold)")
alertcondition(short_condition, title="Short Signal", message="SELL: RSI Crossed Below 70 (Overbought)")
// === PLOTTING INDICATORS & SIGNALS ===
hline(rsi_overbought, "RSI Overbought", color=color.red)
hline(rsi_oversold, "RSI Oversold", color=color.green)
plot(rsi, title="RSI", color=color.blue, linewidth=2)
plotshape(series=long_condition, location=location.belowbar, color=color.green, style=shape.labelup, title="BUY Signal", size=size.large)
plotshape(series=short_condition, location=location.abovebar, color=color.red, style=shape.labeldown, title="SELL Signal", size=size.large)