
이 전략은 50일 및 200일 간단한 이동 평균 (SMA) 을 사용하여 트렌드를 식별하고 50일 평균에서 200일 평균선을 통과하면 구매 신호를 발생시킵니다. 동시에, 이 전략은 2.5%의 계좌 총액을 기반으로 하는 위험 제어 방법을 채택하고, 거래 당 거래의 포지션 크기를 동적으로 계산하고, 200일 평균선에 대한 상대적인 비율을 사용하여 이익을 보호하기 위해 스톱을 사용합니다.
이 쌍평선 골드 크로스 기반의 자기 적응 위험 관리 전략은 고전적인 기술 분석 방법과 현대적인 위험 관리 기술을 결합하여 거래자에게 비교적 안정적인 거래 시스템을 제공합니다. 중장기 트렌드를 포착 할 수있을뿐만 아니라 위험을 효과적으로 제어 할 수 있으며 안정적인 수익을 추구하는 투자자에게 적합합니다. 그러나 이 전략을 사용하는 거래자는 여전히 시장 변화를 면밀히 관찰하고 실제 거래 성과에 따라 변수를 지속적으로 최적화하여 최적의 위험-수익 비율을 달성해야합니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-09-24 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Golden Cross with 1.5% Stop-Loss & MA Exit", overlay=true)
// Define the 50-day and 200-day moving averages
ma50 = ta.sma(close, 50)
ma200 = ta.sma(close, 200)
// Entry condition: 50-day MA crosses above 200-day MA (Golden Cross)
goldenCross = ta.crossover(ma50, ma200)
// Exit condition: price drops below the 200-day MA
exitCondition = close < ma200
// Set the stop-loss to 1.5% below the 200-day moving average
stopLoss = ma200 * 0.985 // 1.5% below the 200-day MA
// Risk management (1.5% of total equity)
riskPercent = 0.025 // 1.5% risk
equity = strategy.equity
riskAmount = equity * riskPercent
// Calculate the distance between the entry price (close) and the stop-loss
stopDistance = close - stopLoss
// Calculate position size based on the risk amount and stop-loss distance
if (goldenCross and stopDistance > 0)
positionSize = riskAmount / stopDistance
strategy.entry("Long", strategy.long, qty=positionSize)
// Exit the trade when the price crosses below the 200-day moving average
if (exitCondition)
strategy.close("Long")
// Plot the moving averages on the chart for visualization
plot(ma50, color=color.blue, linewidth=2, title="50-day MA")
plot(ma200, color=color.red, linewidth=2, title="200-day MA")