
Die Strategie ist ein Multifaktor-Trend-Tracking-System, das die Parallax-Linie-Wechsel-Indikator (SAR), den Index-Moving-Average (EMA), den Relativ-Strength-Index (RSI) und den Average Trend-Index (ADX) kombiniert. Es identifiziert potenzielle Trendrichtungen durch die synchronische Wirkung mehrerer technischer Indikatoren und sendet Geschäfte aus, wenn Trends bestätigt werden. Die Signalstrategie verwendet auch eine dynamische Risikomanagement-Methode, die auf der durchschnittlichen tatsächlichen Breite (ATR) basiert, um automatisch Stop-Loss- und Stop-Loss-Levels zu berechnen.
Die Multi-Faktor-Trendstrategie zeichnet sich durch die Synergie der Indikatoren und das strenge Risikomanagement in den Trendmärkten aus. Die Kernvorteile liegen in der Mehrfachprüfung der Signale und der dynamischen Risikokontrolle, wobei jedoch auf die Parameter-Sensitivität und das Rückstandsrisiko zu achten ist. Zukünftige Optimierungen sollten sich auf die Anpassungsmechanismen der Parameter und die Identifizierung der Marktsituation konzentrieren, um die Robustheit der Strategie zu verbessern.
/*backtest
start: 2024-04-23 00:00:00
end: 2024-12-31 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"DOGE_USDT"}]
*/
//@version=5
strategy("🚀 Estrategia SAR+EMA+RSI con Alertas", overlay=true)
// ———— PARÁMETROS ————
riskPerTrade = input.float(2.0, title="Riesgo por operación (%)", minval=0.5, step=0.5)
sarStart = input.float(0.02, title="SAR Start", minval=0.001)
sarIncrement = input.float(0.02, title="SAR Increment", minval=0.001)
sarMax = input.float(0.2, title="SAR Max", minval=0.1)
rsiLength = input.int(6, title="RSI Length", minval=3, maxval=10)
emaFastLength = input.int(2, title="EMA Rápida", minval=1, maxval=5)
adxThreshold = input.int(30, title="ADX mínimo", minval=20, maxval=50)
atrMultiplier = input.float(1.5, title="Multiplicador ATR para SL", step=0.1)
// ———— INDICADORES ————
sar = ta.sar(sarStart, sarIncrement, sarMax)
emaFast = ta.ema(close, emaFastLength)
rsi = ta.rsi(close, rsiLength)
[diplus, diminus, adx] = ta.dmi(14, 14) // Ahora pasamos length y adxSmoothing
atr = ta.atr(14)
// ———— CONDICIONES ————
longCondition = ta.crossover(close, sar) and close > emaFast and rsi > 60 and adx >= adxThreshold
shortCondition = ta.crossunder(close, sar) and close < emaFast and rsi < 40 and adx >= adxThreshold
// ———— FUNCIÓN MENSAJE ALERTA ————
getAlertMessage(isLong) =>
slPoints = atr * atrMultiplier
message = (isLong ? "🚀 COMPRA " : "🔻 VENTA ") + syminfo.ticker + "\n" +
"Precio: " + str.tostring(math.round(close, 2)) + "\n" +
"SL: " + str.tostring(math.round(isLong ? (close - slPoints) : (close + slPoints), 2)) + "\n" +
"TP: " + str.tostring(math.round(isLong ? (close + slPoints * 2) : (close - slPoints * 2), 2)) + "\n" +
"RSI: " + str.tostring(math.round(rsi, 1)) + "\n" +
"ADX: " + str.tostring(math.round(adx, 1))
message
// ———— ALERTAS ————
if (longCondition)
alert(getAlertMessage(true), alert.freq_once_per_bar_close)
if (shortCondition)
alert(getAlertMessage(false), alert.freq_once_per_bar_close)
if (longCondition)
alert(getAlertMessage(true), alert.freq_once_per_bar_close)
if (shortCondition)
alert(getAlertMessage(false), alert.freq_once_per_bar_close)
// ———— ENTRADAS DE ESTRATEGIA ————
riskAmount = strategy.equity * (riskPerTrade / 100)
slPoints = atr * atrMultiplier
qty = riskAmount / close
if (longCondition)
strategy.entry("Long", strategy.long, qty=qty)
strategy.exit("Exit Long", "Long", stop=close - slPoints, limit=close + slPoints * 2)
if (shortCondition)
strategy.entry("Short", strategy.short, qty=qty)
strategy.exit("Exit Short", "Short", stop=close + slPoints, limit=close - slPoints * 2)
// ———— VISUALIZACIÓN ————
plot(sar, title="SAR", color=color.red, style=plot.style_cross)
plot(emaFast, title="EMA Rápida", color=color.blue)
bgcolor(longCondition ? color.new(color.green, 90) : shortCondition ? color.new(color.red, 90) : na)