
이 전략은 다주기 평균선을 기반으로 한 트렌드 추적 거래 시스템이다. 전략은 89주기 및 21주기 간단한 이동 평균 (SMA) 을 사용하여 시장의 전반적인 트렌드 방향을 결정하고, 5주기 지수 이동 평균 (EMA) 의 최고점과 최저점을 결합하여 특정 거래 신호를 찾는다. 전략은 이중 포지션 관리 방식을 채택하고, 고정된 스톱 손실과 추적 스톱을 결합하여 위험을 제어한다.
전략의 핵심 논리에는 다음과 같은 핵심 요소가 포함됩니다.
이 전략은 구조적인 트렌드 추적 시스템으로, 다중 주기평균선 조합을 통해 시장 트렌드를 포착하고, 유연한 포지션 관리와 스톱 스톱 손실 방식을 사용하여 위험을 제어한다. 약간의 최적화 공간이 있지만, 전략의 기본 프레임 워크는 실용성과 확장성이 좋다. 다양한 거래 품종과 시장 환경에 맞게, 매개 변수를 조정하고 필터링 조건을 추가하여 전략의 안정성을 향상시킬 수 있다.
/*backtest
start: 2024-11-12 00:00:00
end: 2024-12-11 08:00:00
period: 2h
basePeriod: 2h
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/
// © tobiashartemink2
//@version=5
strategy("High 5 Trading Technique", overlay=true)
// --- Input parameters ---
sma89Length = input.int(title="SMA 89 Length", defval=89)
sma21Length = input.int(title="SMA 21 Length", defval=21)
ema5HighLength = input.int(title="EMA 5 High Length", defval=5)
ema5LowLength = input.int(title="EMA 5 Low Length", defval=5)
contracts = input.int(title="Aantal Contracten", defval=1)
stopLossPoints = input.int(title="Stop Loss Points per Contract", defval=25)
takeProfitPoints = input.int(title="Take Profit Points per Contract", defval=25)
// --- Calculate moving averages ---
sma89 = ta.sma(close, sma89Length)
sma21 = ta.sma(close, sma21Length)
ema5High = ta.ema(high, ema5HighLength)
ema5Low = ta.ema(low, ema5LowLength)
// --- Identify trend and order of moving averages ---
longSetup = close > sma89 and close > sma21 and ema5High > sma21 and sma21 > sma89
shortSetup = close < sma89 and close < sma21 and ema5Low < sma21 and sma21 < sma89
// --- Entry signals ---
longTrigger = longSetup and close <= ema5Low
shortTrigger = shortSetup and close >= ema5High
// --- Entry orders ---
if (longTrigger)
strategy.entry("Long 1", strategy.long, qty=contracts)
strategy.entry("Long 2", strategy.long, qty=contracts)
if (shortTrigger)
strategy.entry("Short 1", strategy.short, qty=contracts)
strategy.entry("Short 2", strategy.short, qty=contracts)
// --- Stop-loss and take-profit for long positions ---
if (strategy.position_size > 0)
strategy.exit("Exit Long 1", "Long 1", stop=strategy.position_avg_price - stopLossPoints, limit=strategy.position_avg_price + takeProfitPoints)
strategy.exit("Exit Long 2", "Long 2", stop=strategy.position_avg_price - stopLossPoints, trail_offset=takeProfitPoints, trail_points=takeProfitPoints)
// --- Stop-loss and take-profit for short positions ---
if (strategy.position_size < 0)
strategy.exit("Exit Short 1", "Short 1", stop=strategy.position_avg_price + stopLossPoints, limit=strategy.position_avg_price - takeProfitPoints)
strategy.exit("Exit Short 2", "Short 2", stop=strategy.position_avg_price + stopLossPoints, trail_offset=takeProfitPoints, trail_points=takeProfitPoints)
// --- Plot moving averages ---
plot(sma89, color=color.blue, linewidth=2)
plot(sma21, color=color.red, linewidth=2)
plot(ema5High, color=color.green, linewidth=2)
plot(ema5Low, color=color.orange, linewidth=2)