
쌍평선 교차 트렌드 추적 전략은 기술 분석과 종합적인 위험 관리를 결합한 양적 거래 시스템이다. 이 전략의 핵심은 빠른 간단한 이동 평균 (Fast SMA) 과 느린 간단한 이동 평균 (Slow SMA) 의 교차 신호를 사용하여 시장 추세 변화를 식별하고 여러 위험 제어 장치를 통해 자금 안전을 보장한다.
이 전략은 두 개의 간단한 이동 평균 사이의 상호 관계를 기반으로 거래 결정을 내립니다.
신호 생성 메커니즘:
시간제어를 실행: 전략은 K선 종결시 모든 거래 결정을 수행하여 전망 편향을 피하고, 재검토 결과의 신뢰성과 진실성을 보장한다.
자금 관리 시스템:
다단계 위험 제어:
이 전략은 일률적인 교차를 통해 트렌드를 포착하고, 거래의 안전과 지속성을 보장하기 위해 포괄적인 위험 관리 조치를 사용합니다.
강력한 트렌드 인식 메커니즘:
정확한 재무 관리:
다단계 위험보호:
거래 실행 시점 제어:
process_orders_on_close=true실제 거래 환경에 맞게 주문 처리를 보장하는 매개 변수적응된 추적 차단 시스템:
트렌드 인식 뒤처짐:
고정 변수 적응성 문제:
정지 활성화 시점을 추적합니다.:
자금 관리 위험:
기술의 한계:
신호 생성 메커니즘 최적화:
위험 관리 시스템 강화:
입시 최적화:
피드백 및 평가 프레임워크:
기술 발전:
쌍평선 교차 트렌드 추적 전략은 고전적인 기술 분석 방법과 현대적인 위험 관리 개념을 결합한 완전한 거래 시스템이다. 핵심 장점은 간결하고 명확한 트렌드 식별 장치와 다층적 인 위험 제어 시스템, 특히 정교한 자금 관리 및 고급 추적 스톱 메커니즘이 전략에 좋은 위험 조정 수익 잠재력을 제공합니다.
그러나, 이 전략은 또한 이동 평균에 내재된 지연성과 파라미터 적응성 등의 과제에 직면하고 있다. 적응성 파라미터를 도입하고, 신호 필터링 메커니즘을 강화하고, 위험 관리 시스템을 개선함으로써, 전략 성능이 더 향상될 전망이다.
전반적으로, 이것은 중기 및 장기 트렌드 추적 시스템의 기초가 될 수있는 구조적이고 논리적으로 명확한 정량 전략 프레임 워크입니다. 특히 명백한 트렌드 특성이있는 시장에는 적합합니다. 거래자에게는 단순한 복제 전략 매개 변수보다 위험 관리 개념을 이해하고 숙지하는 것이 더 중요합니다. 이것은 전략의 가장 가치있는 부분입니다.
/*backtest
start: 2025-06-04 00:00:00
end: 2025-06-11 00:00:00
period: 5m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title="Dual SMA Crossover Strategy", overlay=true, calc_on_every_tick=false, process_orders_on_close=true)
// --- Inputs ---
// SMA Lengths
fast_length = input.int(24, title="Fast SMA Length", minval=1)
slow_length = input.int(48, title="Slow SMA Length", minval=1)
// Risk Management
risk_per_trade_percent = input.float(2.0, title="Risk Per Trade (%)", minval=0.1, maxval=10.0, step=0.1) // % of equity to risk per trade
stop_loss_percent = input.float(0.8, title="Stop Loss (%)", minval=0.1, step=0.1) // % from entry price
risk_reward_ratio = input.float(2.0, title="Risk-Reward Ratio", minval=0.5, step=0.1) // 2.0 = 2R, 3.0 = 3R etc.
// Advanced Trailing Stop Loss
trailing_start_percent = input.float(1.0, title="Trailing Stop Start (%)", minval=0.1, step=0.1) // % profit to activate TSL
trailing_stop_percent = input.float(0.5, title="Trailing Stop Trail (%)", minval=0.1, step=0.1) // % to trail by once activated
// --- Calculations ---
// Calculate SMAs
fast_sma = ta.sma(close, fast_length)
slow_sma = ta.sma(close, slow_length)
// Plot SMAs on chart
plot(fast_sma, color=color.blue, title="Fast SMA")
plot(slow_sma, color=color.red, title="Slow SMA")
// Crossover conditions (calculated on previous bar to prevent look-ahead bias)
long_condition = ta.crossover(fast_sma[1], slow_sma[1])
short_condition = ta.crossunder(fast_sma[1], slow_sma[1])
// --- Money Management and Position Sizing ---
// Calculate account equity and risk amount
account_equity = strategy.initial_capital + strategy.netprofit
risk_amount = account_equity * (risk_per_trade_percent / 100)
// Calculate Stop Loss price based on entry and SL percentage
var float long_stop_price = na
var float short_stop_price = na
var float long_take_profit_price = na
var float short_take_profit_price = na
// --- Trailing Stop Loss Variables ---
var float trailing_long_activated_price = na // Price at which TSL is activated for long
var float trailing_short_activated_price = na // Price at which TSL is activated for short
var float current_trailing_stop_long = na
var float current_trailing_stop_short = na
var bool is_long_trailing_active = false
var bool is_short_trailing_active = false
// --- Strategy Entry and Exit Orders ---
if long_condition
// Reset TSL variables for a new entry
trailing_long_activated_price := na
current_trailing_stop_long := na
is_long_trailing_active := false
// Calculate SL, TP for long entry
long_stop_price := close * (1 - stop_loss_percent / 100) // SL below entry
long_take_profit_price := close * (1 + (stop_loss_percent * risk_reward_ratio) / 100) // TP above entry based on RRR
// Calculate position size for long entry
price_change_per_unit = close * (stop_loss_percent / 100)
if price_change_per_unit > 0
long_quantity = risk_amount / price_change_per_unit
strategy.entry("Long", strategy.long, qty=long_quantity, comment="Buy Signal")
else
strategy.entry("Long", strategy.long, comment="Buy Signal (Risk calculation skipped)") // Fallback if SL is 0 or negative
if short_condition
// Reset TSL variables for a new entry
trailing_short_activated_price := na
current_trailing_stop_short := na
is_short_trailing_active := false
// Calculate SL, TP for short entry
short_stop_price := close * (1 + stop_loss_percent / 100) // SL above entry
short_take_profit_price := close * (1 - (stop_loss_percent * risk_reward_ratio) / 100) // TP below entry based on RRR
// Calculate position size for short entry
price_change_per_unit = close * (stop_loss_percent / 100)
if price_change_per_unit > 0
short_quantity = risk_amount / price_change_per_unit
strategy.entry("Short", strategy.short, qty=short_quantity, comment="Sell Signal")
else
strategy.entry("Short", strategy.short, comment="Sell Signal (Risk calculation skipped)") // Fallback if SL is 0 or negative
// --- Stop Loss, Take Profit, Trailing Stop Logic ---
// Long position management
if strategy.position_size > 0 // We are in a long position
entry_price = strategy.opentrades.entry_price(0)
current_profit_percent = ((close - entry_price) / entry_price) * 100
// Initial SL and TP set at entry
strategy.exit("Exit Long", from_entry="Long", stop=long_stop_price, limit=long_take_profit_price, comment="TP/SL Long")
// Check for Trailing Stop activation
if not is_long_trailing_active and current_profit_percent >= trailing_start_percent
is_long_trailing_active := true
// Set initial trailing stop when activated
trailing_long_activated_price := high // Or close, depending on preference
current_trailing_stop_long := high * (1 - trailing_stop_percent / 100)
// If trailing stop is active, update it
if is_long_trailing_active
// Only move the trailing stop up (for long positions)
potential_new_stop = high * (1 - trailing_stop_percent / 100)
current_trailing_stop_long := math.max(current_trailing_stop_long, potential_new_stop)
// Ensure trailing stop is not below the initial long_stop_price
// This prevents the trailing stop from being less protective than the initial SL if the price drops after activation.
current_trailing_stop_long := math.max(current_trailing_stop_long, long_stop_price)
strategy.exit("Trailing Exit Long", from_entry="Long", stop=current_trailing_stop_long, comment="Trailing SL Long")
// Short position management
if strategy.position_size < 0 // We are in a short position
entry_price = strategy.opentrades.entry_price(0)
current_profit_percent = ((entry_price - close) / entry_price) * 100
// Initial SL and TP set at entry
strategy.exit("Exit Short", from_entry="Short", stop=short_stop_price, limit=short_take_profit_price, comment="TP/SL Short")
// Check for Trailing Stop activation
if not is_short_trailing_active and current_profit_percent >= trailing_start_percent
is_short_trailing_active := true
// Set initial trailing stop when activated
trailing_short_activated_price := low // Or close, depending on preference
current_trailing_stop_short := low * (1 + trailing_stop_percent / 100)
// If trailing stop is active, update it
if is_short_trailing_active
// Only move the trailing stop down (for short positions)
potential_new_stop = low * (1 + trailing_stop_percent / 100)
current_trailing_stop_short := math.min(current_trailing_stop_short, potential_new_stop)
// Ensure trailing stop is not above the initial short_stop_price
current_trailing_stop_short := math.min(current_trailing_stop_short, short_stop_price)
strategy.exit("Trailing Exit Short", from_entry="Short", stop=current_trailing_stop_short, comment="Trailing SL Short")
// Plot background color to indicate active position (optional)
bgcolor(strategy.position_size > 0 ? color.new(color.green, 90) : na, title="Long Position Background")
bgcolor(strategy.position_size < 0 ? color.new(color.red, 90) : na, title="Short Position Background")