
이것은 4주기 간단한 이동 평균을 기반으로 한 거래 전략 시스템으로, 동적 스톱 스톱 손실 관리 메커니즘을 통합한다. 이 전략은 가격과 단기 평균의 교차 관계를 통해 시장 추세의 전환점을 포착하고, 위험 관리를 위해 백분율 방식으로 스톱 스톱을 설정한다. 전략의 핵심은 단기 평균의 시장에 대한 빠른 반응 특성을 활용하고, 엄격한 자본 관리 규칙과 결합하여 안정적인 거래 효과를 달성하는 것이다.
이 전략은 다음과 같은 핵심 논리에 기초하여 작동합니다: 우선 4주기 간단한 이동 평균 ((SMA) 을 주요 지표로 계산합니다. 가격이 SMA를 상향으로 통과하면, 시스템은 보잉 신호로 인식하고 더 많은 위치를 열립니다. 가격이 SMA를 하향으로 통과하면, 시스템은 보잉 신호로 인식하고 포지션을 열립니다.
이 전략은 체계적이고, 논리적으로 명확한 양적 거래 전략이다. 이 전략은 단기 평균선으로 시장의 동력을 포착하고, 엄격한 위험 제어 메커니즘을 지원하며, 안정적인 수익을 추구하는 거래자에게 적합하다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-28 00:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("4SMA Strategy with Targets and Stop Loss", overlay=true)
// Input parameters for SMA
smaLength = input.int(4, title="SMA Length", minval=1)
// Input parameters for stop loss and take profit
takeProfitPercent = input.float(2.0, title="Take Profit (%)", step=0.1) // Default: 2%
stopLossPercent = input.float(1.0, title="Stop Loss (%)", step=0.1) // Default: 1%
// Calculate 4-period SMA
sma = ta.sma(close, smaLength)
// Plot SMA
plot(sma, color=color.blue, title="4SMA Line")
// Entry Conditions
longCondition = ta.crossover(close, sma) // Price crosses above SMA (bullish signal)
shortCondition = ta.crossunder(close, sma) // Price crosses below SMA (bearish signal)
// Strategy Logic
if (longCondition)
strategy.entry("Long", strategy.long) // Enter long position
if (shortCondition)
strategy.entry("Short", strategy.short) // Enter short position
// Calculate Take Profit and Stop Loss
longTakeProfit = strategy.position_avg_price * (1 + takeProfitPercent / 100) // TP for long
longStopLoss = strategy.position_avg_price * (1 - stopLossPercent / 100) // SL for long
shortTakeProfit = strategy.position_avg_price * (1 - takeProfitPercent / 100) // TP for short
shortStopLoss = strategy.position_avg_price * (1 + stopLossPercent / 100) // SL for short
// Exit for Long
if (strategy.position_size > 0) // If in a long position
strategy.exit("Long TP/SL", from_entry="Long", limit=longTakeProfit, stop=longStopLoss)
// Exit for Short
if (strategy.position_size < 0) // If in a short position
strategy.exit("Short TP/SL", from_entry="Short", limit=shortTakeProfit, stop=shortStopLoss)