
이 전략은 다중 시간 프레임 분석, 트렌드 추적 및 동적 포지션 관리를 결합한 완전한 거래 시스템입니다. 전략은 EMA를 주요 트렌드 지표로 사용하고 MACD는 2 차 확인 지표로 사용하고 ATR과 함께 위험 제어 및 스톱 손실 설정을 수행합니다. 전략의 독특한 점은 8 시간 시간 프레임의 수량 가격 분석을 통해 거래 신호를 필터링하고 트렌드 강도에 따라 포지션 규모를 동적으로 조정하는 것입니다.
전략은 다음과 같은 핵심 구성 요소를 포함하는 계층적 설계 아이디어를 사용합니다.
이 전략은 다중 시간 프레임 분석과 동적 포지션 관리를 통해 완전한 트렌드 추적 거래 시스템을 구축한다. 전략의 장점은 체계화된 설계 사상과 완벽한 위험 제어 장치에 있다. 그러나 동시에 시장 환경 적응성과 파라미터 최적화 문제에 주의를 기울여야 한다. 제안된 최적화 방향을 통해 전략은 안정성과 수익 능력을 더욱 향상시킬 수 있다.
/*backtest
start: 2024-02-22 00:00:00
end: 2025-02-19 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy('Optimized Trend Strategy', overlay = true, initial_capital = 10000, default_qty_type = strategy.cash, default_qty_value = 50, commission_value = 0.1)
// 🟢 核心指標
ema7 = ta.ema(close, 7)
ema90 = ta.ema(close, 90)
atr = ta.atr(14)
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
// 🟢 8 小時多時間框架確認
h8Close = request.security(syminfo.tickerid, '480', close)
h8Volume = request.security(syminfo.tickerid, '480', volume)
h8Ema7 = ta.ema(h8Close, 7)
h8Signal = h8Close > h8Ema7 and h8Volume > ta.sma(h8Volume, 50)
// 🟢 動態風控
stopLoss = close - 1.5 * atr
takeProfit = close + 3 * atr
// 🟢 交易信號
longCondition = close > ema7 and ema7 > ema90 and ta.crossover(macdLine, signalLine) and h8Signal
shortCondition = close < ema7 and ema7 < ema90 and ta.crossunder(macdLine, signalLine) and h8Signal
// 🟢 倉位管理(根據趨勢強度)
trendStrength = (ema7 - ema90) / (atr / close)
var float positionSize = na
if trendStrength > 2
positionSize := strategy.equity * 0.7 / close
positionSize
else if trendStrength < 0.5
positionSize := strategy.equity * 0.3 / close
positionSize
else
positionSize := strategy.equity * 0.5 / close
positionSize
// 🟢 訂單執行
if longCondition
strategy.entry('Long', strategy.long, qty = positionSize)
strategy.exit('Long Exit', from_entry = 'Long', stop = stopLoss, limit = takeProfit)
if shortCondition
strategy.entry('Short', strategy.short, qty = positionSize)
strategy.exit('Short Exit', from_entry = 'Short', stop = stopLoss, limit = takeProfit)