
この戦略は,市場動向と取引タイミングを決定するために複数の技術指標を組み合わせた総合的なトレンド追跡取引システムである.戦略の核心は,高速と遅いシンプル移動平均 (SMA) の交差信号に基づいており,相対的に弱い指標 (RSI) と平均トレンド指数 (ADX) を介してトレンド確認を行い,実際の波幅 (ATR) を利用してリスク管理を行う.戦略は,資金管理の原則を採用し,単一の取引のリスクを口座資金の2%を超えないように制限する.
戦略の仕組みは,主に以下の重要な部分から構成されています.
この戦略は,複数の技術指標の組み合わせを適用することにより,比較的完全なトレンド追跡取引システムを構築している.戦略は,設計上,信号信頼性とリスク管理に重点を置く,優れた実用性を持っている.戦略は,最適化勧告の実施によって,パフォーマンスをさらに向上させる見通しがある.実地での適用の前に十分な反テストを推奨し,特定の取引品種の特性に応じてパラメータを最適化している.
/*backtest
start: 2025-02-16 17:00:00
end: 2025-02-20 00:00:00
period: 4m
basePeriod: 4m
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("SMA + RSI + ADX + ATR Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=2)
// === Input Parameters ===
sma_fast_length = input(10, title="SMA Fast Period")
sma_slow_length = input(200, title="SMA Slow Period")
rsi_length = input(14, title="RSI Period")
adx_length = input(14, title="ADX Period")
adx_smoothing = input(14, title="ADX Smoothing Period") // <-- New parameter!
atr_length = input(14, title="ATR Period")
// === Filtering Levels for RSI and ADX ===
rsi_buy_level = input(50, title="RSI Buy Level")
rsi_sell_level = input(50, title="RSI Sell Level")
adx_min_trend = input(20, title="ADX Minimum Trend Strength")
// === Trailing Stop ===
use_trailing_stop = input(true, title="Enable Trailing Stop")
trailing_stop_pips = input(30, title="Trailing Stop (Pips)")
trailing_step_pips = input(5, title="Trailing Step (Pips)")
// === Indicators ===
sma_fast = ta.sma(close, sma_fast_length)
sma_slow = ta.sma(close, sma_slow_length)
rsi_value = ta.rsi(close, rsi_length)
[diPlus, diMinus, adx_value] = ta.dmi(adx_length, adx_smoothing) // <-- Corrected: added `adx_smoothing`
atr_value = ta.atr(atr_length)
// === Entry Logic ===
longCondition = ta.crossover(sma_fast, sma_slow) and rsi_value > rsi_buy_level and adx_value > adx_min_trend
shortCondition = ta.crossunder(sma_fast, sma_slow) and rsi_value < rsi_sell_level and adx_value > adx_min_trend
// === Open Positions ===
if longCondition
strategy.entry("BUY", strategy.long)
if shortCondition
strategy.entry("SELL", strategy.short)
// === Trailing Stop ===
if use_trailing_stop
strategy.exit("Exit Long", from_entry="BUY", trail_points=trailing_stop_pips, trail_offset=trailing_step_pips)
strategy.exit("Exit Short", from_entry="SELL", trail_points=trailing_stop_pips, trail_offset=trailing_step_pips)
// === Visualization ===
plot(sma_fast, color=color.blue, title="SMA 10")
plot(sma_slow, color=color.red, title="SMA 200")
hline(rsi_buy_level, title="RSI Buy Level", color=color.green)
hline(rsi_sell_level, title="RSI Sell Level", color=color.red)
hline(adx_min_trend, title="ADX Min Trend Level", color=color.orange)