
이 전략은 단기 및 장기 이동 평균의 교차 신호를 비교하여 거래 결정을 내리고, 교류 지표를 합성합니다. 단기 평균이 장기 평균을 상향으로 가로질러 거래량이 크게 증가하면 시스템이 여러 신호를 발산합니다. 동시에, 전략은 위험을 제어하기 위해 손해 제도를 설정합니다.
전략의 핵심 논리는 다음과 같은 핵심 요소에 기초합니다.
흔들림 시장의 위험: 가로판 흔들림 시장에서, 빈번한 평행선 교차는 여러 개의 가짜 돌파구를 초래할 수 있다. 해결책: ADX 또는 트렌드 강도 지표와 같은 트렌드 확인 지표를 추가할 수 있습니다.
슬라이드 포인트 위험: 거래량이 급격히 증가할 때, 큰 슬라이드 포인트 손실에 직면할 수 있다. 해결책: 합리적인 슬라이드 포인트 허용을 설정하고, 포지션을 개시할 때 제한 가격을 사용하십시오.
정지 손실 트리거 위험: 고정 비율 정지 손실은 시장의 변동이 커질 때 너무 민감할 수 있습니다. 해결책: ATR의 동적 상쇄 또는 변동률 조정으로 상쇄하는 방법을 고려할 수 있습니다.
이 전략은 가격 추세와 거래량 변화를 결합하여 비교적 완전한 거래 시스템을 구축한다. 이 전략의 장점은 여러 확인 메커니즘과 완벽한 위험 통제에 있다. 그러나, 불안한 시장에서 가짜 돌파의 위험에 직면할 수 있다. 동적 파라미터 최적화와 신호 최적화를 통해, 이 전략에는 더 많은 개선의 여지가 있다.
/*backtest
start: 2024-02-18 00:00:00
end: 2025-02-17 00:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("MA Crossover with Volume (Long Only) + Stop Loss", overlay=true)
// Input settings for Moving Averages
shortMaLength = input.int(9, title="Short MA Length", minval=1)
longMaLength = input.int(21, title="Long MA Length", minval=1)
// Input settings for Volume
volumeMaLength = input.int(20, title="Volume MA Length", minval=1)
volumeThresholdMultiplier = input.float(1.5, title="Volume Multiplier (x times the average)", step=0.1)
// Input settings for Stop Loss
stopLossPercent = input.float(2.0, title="Stop Loss (%)", minval=0.1, step=0.1) / 100 // Stop loss in percentage
// Calculating Moving Averages
shortMa = ta.sma(close, shortMaLength)
longMa = ta.sma(close, longMaLength)
// Calculating Volume Metrics
volumeMa = ta.sma(volume, volumeMaLength) // Average volume
isVolumeAboveAverage = volume > (volumeMa * volumeThresholdMultiplier) // Volume above threshold
isVolumeIncreasing = volume > volume[1] // Volume increasing compared to the previous bar
// Plotting Moving Averages
plot(shortMa, color=color.blue, title="Short MA")
plot(longMa, color=color.orange, title="Long MA")
// Buy Condition with Volume
longCondition = ta.crossover(shortMa, longMa) and isVolumeAboveAverage and isVolumeIncreasing
exitCondition = ta.crossunder(shortMa, longMa) // Exit when the MAs cross downward
// Calculate Stop Loss Level
var float entryPrice = na // Variable to store entry price
if (strategy.position_size > 0 and na(entryPrice)) // Update entry price only when entering a new trade
entryPrice := strategy.position_avg_price
stopLossLevel = entryPrice * (1 - stopLossPercent) // Stop-loss level based on entry price
// Strategy Entry (Long Only)
if (longCondition)
strategy.entry("Long", strategy.long)
// Close position on Stop Loss or Exit Condition
if (strategy.position_size > 0)
if (low < stopLossLevel) // If the price drops below the stop-loss level
strategy.close("Long", comment="Stop Loss Hit")
if (exitCondition)
strategy.close("Long", comment="Exit Signal Hit")
// Debugging Plots
plot(volumeMa, color=color.purple, title="Volume MA", style=plot.style_area, transp=80)
hline(0, "Zero Line", color=color.gray)