
¿Sabías que esta estrategia es como un triple seguro para tu operación? En primer lugar, utiliza la EMA200 para determinar la dirección de la tendencia general, luego, el volumen de transacción para confirmar la autenticidad de la ruptura, y finalmente, el ATR para proteger los beneficios.
No es una transacción mecánica, sino una estrategia inteligente para “observar los cambios”. Cuando el precio supera el EMA200, también debe verificar si el volumen de transacción es lo suficientemente grande (por defecto, 1,5 veces el promedio) para evitar falsas brechas.
¡Y ahora llega la parte más emocionante! El stop loss de esta estrategia no es un valor fijo de la barra, sino una protección dinámica que “subirá por las escaleras”.
Es muy simple.:
¡Así se protegen las ganancias y se da suficiente espacio para que la tendencia crezca!
El mayor problema de muchas estrategias de brecha es que son falsas, como en la historia de “Los lobos están aquí”. Esta estrategia resuelve este problema mediante la confirmación de la transacción:
El volumen de transacciones debe ser más de 1,5 veces el promedio de 20 días¡Imagínese que si una noticia es difundida por sólo unas pocas personas, puede ser falsa; pero si toda la ciudad está hablando de ella, entonces vale la pena preocuparse!
Este diseño te ayuda a filtrar los falsos avances de las “falsificaciones” y a aprovechar las oportunidades de tendencias realmente financiadas.
Apto para el público:
Los problemas centrales resueltos:
Recuerde que el mayor valor de esta estrategia no es hacerse rico de la noche a la mañana, sino ayudarlo a obtener ganancias estables en los mercados de tendencia, mientras maximiza la seguridad de su dinero. ¡Es como si su transacción estuviera equipada con un sistema de navegación GPS + cápsula de seguridad + protección contra colisiones!
/*backtest
start: 2024-08-26 00:00:00
end: 2025-08-24 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("EMA Break + Stop ATR", overlay = true)
// =============================================================================
// STRATEGY PARAMETERS
// =============================================================================
// User inputs for strategy customization
shortPeriod = input.int(20, title = "Stop Period", minval = 1, maxval = 100, tooltip = "Period for lowest low calculation")
atrPeriod = 1 // ATR period always set to 1
initialStopLoss = 0.0 // Initial stop loss always set to 0 (auto based on ATR)
// Confirmation indicator settings
useVolumeConfirmation = input.bool(true, title = "Use Volume Confirmation", tooltip = "Require volume above average for breakout confirmation")
volumeMultiplier = input.float(1.5, title = "Volume Multiplier", minval = 1.0, maxval = 5.0, step = 0.1, tooltip = "Volume must be this times above average")
// Strategy variables
var float STOP_LOSS = 0.0 // Dynamic stop loss value
var float TRAILING_STOP = na // Trailing stop based on lowest low
// =============================================================================
// TECHNICAL INDICATORS
// =============================================================================
// Calculate True Range and its Simple Moving Average
trueRange = ta.tr(true)
smaTrueRange = ta.sma(trueRange, atrPeriod)
// Calculate 200-period Exponential Moving Average
ema200 = ta.ema(close, 200)
// Calculate lowest low over the short period
lowestLow = ta.lowest(input(low), shortPeriod)
// Calculate potential stop loss level (always available)
potentialStopLoss = close - 2 * smaTrueRange
// Volume confirmation for breakout validation
volumeSMA = ta.sma(volume, 20) // 20-period average volume
isVolumeConfirmed = not useVolumeConfirmation or volume > volumeSMA * volumeMultiplier
// =============================================================================
// STOP LOSS MANAGEMENT
// =============================================================================
// Update trailing stop based on lowest low (always, not just when in position)
if na(TRAILING_STOP) or lowestLow > TRAILING_STOP
TRAILING_STOP := lowestLow
// Update stop loss if we have an open position and new lowest low is higher
if (strategy.position_size > 0) and (STOP_LOSS < lowestLow)
strategy.cancel("buy_stop")
STOP_LOSS := lowestLow
// Soft stop loss - exit only when close is below stop level
if (strategy.position_size > 0) and (close < STOP_LOSS)
strategy.close("buy", comment = "Soft Stop Loss")
alert("Position closed: Soft Stop Loss triggered at " + str.tostring(close), alert.freq_once_per_bar)
// =============================================================================
// ENTRY CONDITIONS
// =============================================================================
// Enhanced entry signal with volume confirmation to avoid false breakouts
isEntrySignal = ta.crossover(close, ema200) and (strategy.position_size == 0) and isVolumeConfirmed
if isEntrySignal
// Cancel any pending orders
strategy.cancel("buy")
strategy.cancel("sell")
// Enter long at market on crossover
strategy.entry("buy", strategy.long)
// Set initial stop loss (2 * ATR below close, or use custom value if specified)
if initialStopLoss > 0
STOP_LOSS := initialStopLoss
else
STOP_LOSS := close - 2 * smaTrueRange
// Alert for position opened
alert("Position opened: Long entry at " + str.tostring(close) + " with stop loss at " + str.tostring(STOP_LOSS), alert.freq_once_per_bar)
// =============================================================================
// PLOTTING
// =============================================================================
// Plot EMA 200
plot(ema200, color = color.blue, title = "EMA 200", linewidth = 2)
// Plot Stop Loss
plot(strategy.position_size > 0 ? STOP_LOSS : lowestLow, color = color.red, title = "Stop Loss", linewidth = 2)
// Plot confirmation signals
plotshape(isEntrySignal, title="Confirmed Breakout", location=location.belowbar,
color=color.green, style=shape.triangleup, size=size.normal)
// Plot volume confirmation (only if enabled)
bgcolor(useVolumeConfirmation and isVolumeConfirmed and ta.crossover(close, ema200) ? color.new(color.green, 90) : na, title="Volume Confirmed")