다중 타겟 스마트 변동성 모멘텀 거래 전략

SMA RSI TP SL
생성 날짜: 2024-12-12 14:45:04 마지막으로 수정됨: 2024-12-12 14:45:04
복사: 2 클릭수: 350
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

다중 타겟 스마트 변동성 모멘텀 거래 전략

이 전략은 거래량, 가격 운동, 그리고 다중 스톱 스톱 손실을 결합한 지능적인 거래 시스템이다. 거래량, 가격 상승, 그리고 운동 지표의 조합을 모니터링하여 잠재적인 거래 기회를 식별하고, 계층화된 스톱 스톱 손실 관리를 사용하여 위험 수익률을 최적화한다.

전략 원칙

이 전략은 세 가지 핵심 거래 신호에 기반합니다: 1) 거래량 돌파구 - 현재 거래량이 지난 20 주기의 평균 거래량의 2배 이상; 2) 가격 상승 - 최근 가격 상승이 설정된 하락값을 초과하고; 3) 동력 확인 - RSI가 55보다 크고 가격이 50 주기의 평균선 위에 있습니다. 이 세 가지 조건이 동시에 충족되면 시스템은 더 많이 발송됩니다. 신호 전략은 트리플 스톱 () 15%, 25%, 35%, 트리플 스톱 손실 () -2%, -5%, -10%를 사용하여 포지션을 관리하며, 각 평준 포지션의 포지션 비율도 유연하게 설정할 수 있습니다.

전략적 이점

  1. 다중 신호 확인은 거래의 정확성을 향상시킵니다.
  2. 계층화 된 스톱 스톱 손실 계획은 수익을 잠금하고 위험을 통제합니다.
  3. 다양한 시장 환경에 적응할 수 있는 변수
  4. 기술 지표와 거래량 분석을 결합하여 신호가 더 안정적입니다.
  5. 실시간 경보 기능으로 기회를 잡을 수 있습니다.

전략적 위험

  1. 잘못된 매개 변수 설정으로 인해 과도한 거래가 발생할 수 있습니다.
  2. 시장의 급격한 변동이 발생할 경우 자주 중단될 수 있습니다.
  3. 유동성이 낮은 시장에서 손실을 막기 위해
  4. 근본적인 요소를 고려하지 않으면 중요한 영향을 놓칠 수 있습니다.
  5. 기술 지표에 지나치게 의존하는 것은 수평 시장에서 실패할 수 있습니다.

전략 최적화 방향

  1. 시장 상황에 대한 판단을 도입하고, 다른 상황에서 다른 파라미터를 사용한다.
  2. 거래량 품질 분석을 추가하고 가짜 방출 신호를 필터링합니다.
  3. 트렌드 강도 지표를 추가하여 트렌드 추적 능력을 향상시킵니다.
  4. 시장의 변동 특성에 맞게 스티프/스트로스 간격을 최적화
  5. 재정 곡선의 안정성을 높이기 위해 철회 제어를 추가하는 것을 고려하십시오

요약하다

이것은 여러 가지 기술적 분석 요소를 통합하는 성숙한 거래 전략이다. 엄격한 신호 필터링과 유연한 포지션 관리로 트렌드 기회를 잡는 동시에 위험을 잘 통제한다. 여전히 최적화 할 여지가 있지만 전체적인 디자인은 합리적이며 실제에서 검증하고 사용할 가치가 있습니다.

전략 소스 코드
/*backtest
start: 2024-11-11 00:00:00
end: 2024-12-10 08:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Volume Spike & Momentum Strategy with Alerts", overlay=true)

// Inputs for customization
priceGainPercent = input.float(5, title="Minimum Price Gain (%)", minval=1)
volumeLookback = input.int(20, title="Volume Lookback Period (Bars)", minval=1)
momentumSmaLength = input.int(50, title="SMA Length for Momentum (Bars)", minval=1)
rsiThreshold = input.float(55, title="RSI Threshold for Momentum", minval=1)

// Take Profit percentages
tp1Percent = input.float(15, title="Take Profit 1 (%)", minval=1)
tp2Percent = input.float(25, title="Take Profit 2 (%)", minval=1)
tp3Percent = input.float(35, title="Take Profit 3 (%)", minval=1)

// Percentage of position to close at each take-profit
tp1ClosePercent = input.float(30, title="Close % at TP1", minval=1, maxval=100)
tp2ClosePercent = input.float(40, title="Close % at TP2", minval=1, maxval=100)
tp3ClosePercent = input.float(30, title="Close % at TP3", minval=1, maxval=100)

// Stop-loss percentages
sl1Percent = input.float(2, title="Stop Loss 1 (%)", minval=0.1)
sl2Percent = input.float(5, title="Stop Loss 2 (%)", minval=0.1)
sl3Percent = input.float(10, title="Stop Loss 3 (%)", minval=0.1)

// Percentage of position to close at each stop-loss
sl1ClosePercent = input.float(30, title="Close % at SL1", minval=1, maxval=100)
sl2ClosePercent = input.float(40, title="Close % at SL2", minval=1, maxval=100)
sl3ClosePercent = input.float(30, title="Close % at SL3", minval=1, maxval=100)

// Detect volume spikes
avgVolume = ta.sma(volume, volumeLookback)   // Average volume over the last X bars (customizable)
volumeSpike = volume > avgVolume * 2         // Spike in volume if current volume is 2x the average

// Detect price gain over the recent period (e.g., 5-10% gain over the last X bars)
priceChangePercent = (close - ta.lowest(close, 5)) / ta.lowest(close, 5) * 100
priceGainCondition = priceChangePercent >= priceGainPercent

// Check for overall momentum using an SMA and RSI
longTermSma = ta.sma(close, momentumSmaLength)
rsi = ta.rsi(close, 14)
momentumCondition = close > longTermSma and rsi >= rsiThreshold

// Store the entry price on a new trade
var float entryPrice = na
if (strategy.opentrades == 0 and (volumeSpike and priceGainCondition and momentumCondition))
    entryPrice := close  // Capture the entry price on a new trade

// Calculate take-profit levels based on the entry price
tp1Price = entryPrice * (1 + tp1Percent / 100)
tp2Price = entryPrice * (1 + tp2Percent / 100)
tp3Price = entryPrice * (1 + tp3Percent / 100)

// Calculate stop-loss levels based on the entry price
sl1Price = entryPrice * (1 - sl1Percent / 100)
sl2Price = entryPrice * (1 - sl2Percent / 100)
sl3Price = entryPrice * (1 - sl3Percent / 100)

// Exit conditions for multiple take-profits
tp1Condition = high >= tp1Price  // Exit partial if price hits take-profit 1
tp2Condition = high >= tp2Price  // Exit partial if price hits take-profit 2
tp3Condition = high >= tp3Price  // Exit full if price hits take-profit 3

// Exit conditions for multiple stop-losses
sl1Condition = low <= sl1Price  // Exit partial if price hits stop-loss 1
sl2Condition = low <= sl2Price  // Exit partial if price hits stop-loss 2
sl3Condition = low <= sl3Price  // Exit full if price hits stop-loss 3

// Buy Condition: When volume spike, price gain, and momentum conditions are met
if (volumeSpike and priceGainCondition and momentumCondition)
    strategy.entry("Buy", strategy.long)

// Alerts for conditions
alertcondition(volumeSpike and priceGainCondition and momentumCondition, title="Entry Alert", message="Entry conditions met: Volume spike, price gain, and momentum detected!")

alertcondition(tp1Condition, title="Take Profit 1", message="Take Profit 1 hit!")
alertcondition(tp2Condition, title="Take Profit 2", message="Take Profit 2 hit!")
alertcondition(tp3Condition, title="Take Profit 3", message="Take Profit 3 hit!")

alertcondition(sl1Condition, title="Stop Loss 1", message="Stop Loss 1 hit!")
alertcondition(sl2Condition, title="Stop Loss 2", message="Stop Loss 2 hit!")
alertcondition(sl3Condition, title="Stop Loss 3", message="Stop Loss 3 hit!")

// Exit conditions: Multiple take-profits and stop-losses
if (tp1Condition)
    strategy.exit("Take Profit 1", "Buy", limit=tp1Price, qty_percent=tp1ClosePercent)

if (tp2Condition)
    strategy.exit("Take Profit 2", "Buy", limit=tp2Price, qty_percent=tp2ClosePercent)

if (tp3Condition)
    strategy.exit("Take Profit 3", "Buy", limit=tp3Price, qty_percent=tp3ClosePercent)

// Stop-loss exits
if (sl1Condition)
    strategy.exit("Stop Loss 1", "Buy", stop=sl1Price, qty_percent=sl1ClosePercent)

if (sl2Condition)
    strategy.exit("Stop Loss 2", "Buy", stop=sl2Price, qty_percent=sl2ClosePercent)

if (sl3Condition)
    strategy.exit("Stop Loss 3", "Buy", stop=sl3Price, qty_percent=sl3ClosePercent)

// Plotting take-profit and stop-loss levels on the chart
plot(tp1Price, color=color.green, style=plot.style_linebr, title="TP1 Level")
plot(tp2Price, color=color.green, style=plot.style_linebr, title="TP2 Level")
plot(tp3Price, color=color.green, style=plot.style_linebr, title="TP3 Level")

plot(sl1Price, color=color.red, style=plot.style_linebr, title="SL1 Level")
plot(sl2Price, color=color.red, style=plot.style_linebr, title="SL2 Level")
plot(sl3Price, color=color.red, style=plot.style_linebr, title="SL3 Level")