MA/VWAP 크로스오버를 기반으로 한 유연한 손절매 및 이익 실현 전략


생성 날짜: 2023-12-20 14:06:18 마지막으로 수정됨: 2023-12-20 14:06:18
복사: 0 클릭수: 734
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

MA/VWAP 크로스오버를 기반으로 한 유연한 손절매 및 이익 실현 전략

개요

이 전략은 빠른 이동 평균, 느린 이동 평균 및 교차량 가중 평균을 계산하여 그 사이의 교차 신호를 식별하여 가격 움직임을 포착합니다. 빠른 MA가 위쪽에서 VWAP와 느린 MA를 통과하면 구매 신호가 발생하고 빠른 MA가 위쪽에서 VWAP와 느린 MA를 통과하면 판매 신호가 발생합니다.

전략 원칙

이 전략은 이동 평균과 거래량 가중 평균 가격의 장점을 결합한다. 이동 평균은 시장 소음을 효과적으로 필터링하여 트렌드 방향을 판단한다. 거래량 가중 평균은 큰 자본의 의도를 더 정확하게 반영한다. 빠른 MA는 단기 트렌드를 포착하고, 느린 MA는 가짜 신호를 필터링한다. 빠른 MA 위에 느린 MA와 VWAP를 통과하면 단기 트렌드가 부시로 전환되어 구매 신호를 생성하고, 아래로 통과하면 상향으로 전환되어 판매 신호를 생성한다.

우위 분석

  • 이중 MA 필터링을 사용하여 가짜 신호를 줄이십시오.
  • VWAP는 큰 자본의 의도를 정확하게 판단할 수 있습니다.
  • 다른 주기에 적응하기 위해 MA 파라미터를 유연하게 설정
  • 스탠드 로즈 스과 함께, 효과적으로 위험을 통제합니다.

위험 분석

  • 시장의 큰 흔들림으로 인해 여러 가지 잘못된 신호가 발생할 수 있습니다.
  • VWAP 파라미터가 설정되어 있지 않은 상태에서 재단의 의도를 정확하게 판단할 수 없습니다.
  • 스톱포인트가 너무 가까워진다면 추세를 추적할 수 없고, 너무 멀리 떨어진다면 너무 위험할 수 있습니다.

최적화 방향

  • MA와 VWAP의 매개 변수를 최적화하여 다양한 상황에 맞게 조정합니다.
  • RSI와 같은 다른 지표와 함께 신호를 필터링
  • 동적으로 조정된 스톱 스탠드 비율

요약하다

이 전략은 이동 평균과 VWAP의 장점을 통합하고, 쌍중 필터링을 통해 교차 신호를 인식하고, 유연한 스톱 스톱 메커니즘과 함께 위험을 효과적으로 제어할 수 있으며, 추천되는 트렌드 추적 전략이다.

전략 소스 코드
/*backtest
start: 2023-11-19 00:00:00
end: 2023-12-19 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Flexible MA VWAP Crossover Strategy with SL/TP", shorttitle="MA VWAP Crossover", overlay=true)

// Input parameters
fast_length = input(9, title="Fast MA Length", minval=1)
slow_length = input(21, title="Slow MA Length", minval=1)
vwap_length = input(14, title="VWAP Length", minval=1)

// Stop Loss and Take Profit inputs
stop_loss_percent = input(1.0, title="Stop Loss (%)", minval=0.1, maxval=5.0, step=0.1)
take_profit_percent = input(2.0, title="Take Profit (%)", minval=1.0, maxval=10.0, step=0.1)

// Calculate moving averages
fast_ma = sma(close, fast_length)
slow_ma = sma(close, slow_length)
vwap = sma(close * volume, vwap_length) / sma(volume, vwap_length)

// Buy and sell conditions
buy_condition = crossover(fast_ma, vwap) and crossover(fast_ma, slow_ma)
sell_condition = crossunder(fast_ma, vwap) and crossunder(fast_ma, slow_ma)

// Plot the moving averages
plot(fast_ma, title="Fast MA", color=color.blue)
plot(slow_ma, title="Slow MA", color=color.red)
plot(vwap, title="VWAP", color=color.purple)

// Plot buy and sell signals
plotshape(buy_condition, style=shape.triangleup, location=location.belowbar, color=color.green, title="Buy Signal")
plotshape(sell_condition, style=shape.triangledown, location=location.abovebar, color=color.red, title="Sell Signal")

// Define stop loss and take profit levels
var float stop_loss_price = na
var float take_profit_price = na

if (buy_condition)
    stop_loss_price := close * (1 - stop_loss_percent / 100)
    take_profit_price := close * (1 + take_profit_percent / 100)

// Strategy entry and exit with flexible SL/TP
strategy.entry("Buy", strategy.long, when = buy_condition)

if (sell_condition)
    strategy.exit("SL/TP", from_entry = "Buy", stop = stop_loss_price, limit = take_profit_price)