
この戦略は、移動平均クロスオーバー信号と動的リスク管理を組み合わせたトレンド追従型取引システムです。高速および低速の指数移動平均 (EMA) を使用して市場のトレンドを特定し、平均真の範囲 (ATR) インジケーターと組み合わせてエントリーのタイミングを最適化します。同時に、この戦略には、パーセンテージ ストップ ロス、目標利益、トレーリング ストップ ロスという 3 つの保護メカニズムが統合されています。
戦略の中核となるロジックは、次の主要な要素に基づいています。
これは、よく設計された、論理的に明確なトレンド追従戦略です。移動平均線のクロスオーバーを通じてトレンドを捉え、ATR を使用してリスクを制御し、複数のストップロス メカニズムと連携することで、完全な取引システムが形成されます。この戦略の主な利点は、包括的なリスク管理と高いカスタマイズ性ですが、実際の取引では、誤ったシグナルや取引コストの問題に注意する必要があります。提案された最適化の方向性を通じて、戦略をさらに改善する余地がまだあります。
/*backtest
start: 2024-12-29 00:00:00
end: 2025-01-05 00:00:00
period: 2m
basePeriod: 2m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jesusperezguitarra89
//@version=6
strategy("High Profit Buy/Sell Signals", overlay=true)
// Parámetros ajustables
fastLength = input.int(5, title="Fast EMA Length")
slowLength = input.int(20, title="Slow EMA Length")
atrLength = input.int(10, title="ATR Length")
atrMultiplier = input.float(2.5, title="ATR Multiplier")
stopLossPercent = input.float(1.0, title="Stop Loss %")
takeProfitPercent = input.float(5.0, title="Take Profit %")
trailingStop = input.float(2.0, title="Trailing Stop %")
// Cálculo de EMAs
fastEMA = ta.ema(close, fastLength)
slowEMA = ta.ema(close, slowLength)
// Cálculo del ATR
atr = ta.atr(atrLength)
// Señales de compra y venta
longCondition = ta.crossover(fastEMA, slowEMA) and close > slowEMA + atrMultiplier * atr
shortCondition = ta.crossunder(fastEMA, slowEMA) and close < slowEMA - atrMultiplier * atr
// Dibujar señales en el gráfico
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Estrategia de backtesting para marcos de tiempo en minutos
if longCondition
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit", from_entry="Buy", limit=close * (1 + takeProfitPercent / 100), stop=close * (1 - stopLossPercent / 100), trail_points=atr * trailingStop)
if shortCondition
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit", from_entry="Sell", limit=close * (1 - takeProfitPercent / 100), stop=close * (1 + stopLossPercent / 100), trail_points=atr * trailingStop)
// Mostrar EMAs
plot(fastEMA, color=color.blue, title="Fast EMA")
plot(slowEMA, color=color.orange, title="Slow EMA")