앵커링 CVDVWAP 신호 전략

저자:차오장, 날짜: 2023-12-29 14:56:03
태그:

img

전반적인 설명

앵커링 롤링 CVDVWAP 신호 전략은 트레이딩뷰 플랫폼을 위해 설계된 복잡한 기술 분석 지표입니다. 트레이딩을 위해 입출 신호를 생성하기 위해 앵커링 볼륨 가중 평균 가격 (VWAP), 누적 볼륨 델타 (CVD) 및 표준 편차 분석의 개념을 통합합니다.

전략 논리

이 전략의 핵심은 VWAP를 앵커링하여 계산을 시작하여 사용자 정의 기간 동안 가장 높은 볼륨을 가진 특정 앵커 바에서 VWAP를 계산하는 것입니다. 그 다음 표준 편차를 통해 계산된 앵커 뱅드는 이 앵커링된 VWAP를 기반으로 과잉 구매/ 과잉 판매 영역을 반영하기 위해 그래프화됩니다. 한편, 변화율 (ROC) 지표는 CVD 필터 신호와 결합하여 diprip 패턴을 감지하여 구매 및 판매 신호를 생성합니다. 이 신호는 다음 신호를 전송하기 전에 현재 신호가 종료되는 것을 반복하거나 기다릴 수 있습니다.

장점

  1. 부피 가중된 평균 가격을 사용하여 가치 영역 및 지원/저항 수준을 식별합니다.
  2. 표준편차 밸브 밴드는 과도한 가격 움직임을 강조합니다.
  3. CVD 부피 지표는 기본 구매/판매 압력을 반영합니다.
  4. 명확한 출입 및 출입 신호
  5. 위험 관리에 대한 자동 중지 손실 및 수익

위험 분석

  1. 부적절한 매개 변수 설정으로 인해 놓친 거래 또는 유효하지 않은 신호가 발생할 수 있습니다.
  2. 단독으로 사용하는 대신 의사결정을 위한 더 많은 지표와 결합해야 합니다.
  3. 다양한 제품과 시간 프레임에 최적화를 요구합니다.
  4. 나쁜 스톱 로스 및 수익 포지셔닝은 더 큰 손실을 가져옵니다.

최적화 방향

  1. 이동 평균 등으로 앵커 바 선택 논리를 조정
  2. 봉투 띠를 위해 다른 표준 편차 곱셈을 시도
  3. 변동성 특성에 맞는 ROC 매개 변수를 최적화합니다.
  4. 변동성 시장을 위해 동적 미끄러짐 또는 적응적 중지 설정

결론

앵커링 롤링 CVDVWAP 신호 전략은 가격 행동과 구매/판매 동력을 평가하기 위해 다양한 지표를 합성하여 거래 기회를 발견하는 데 매우 유용합니다. 그러나 여전히 신중하게 사용해야하며 자신의 거래 전략에 맞게 지속적인 테스트와 최적화를 필요로합니다.


/*backtest
start: 2022-12-28 00:00:00
end: 2023-12-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('Anchored Rolling CVDVWAP Signal Strategy', overlay=true)

// User-defined settings
vwapAnchorPeriod = input.int(20, title="Rolling VWAP Anchor Period", group="Settings")
stdDevMult = input.float(2.0, title="Standard Deviation Multiplier for Envelope", group="Settings")
analysis_period = input.int(7, minval=1, maxval=100, title="Analysis Period", group="Settings")
useVwapFilter = input.bool(true, title="Use Anchored VWAP Filter", group="Filters")
useCvdFilter = input.bool(true, title="Use CVD Filter", group="Filters")
cvdLength = input.int(20, title="CVD Length", group="Filters")
tpPercent = input.float(200.0, title="Take Profit % of SL Distance", group="Trade Settings")
slPeriods = input.int(200, title="Stop Loss Lookback Period", group="Trade Settings")
toggleSignals = input.bool(false, title="Toggle Signals", group="Settings")

// Finding the anchor bar
highestVol = ta.highest(volume, vwapAnchorPeriod)
var int anchorBar = na
if volume == highestVol
    anchorBar := bar_index

// Initializing variables for anchored VWAP and envelope calculation
var float avwapNumerator = na
var float avwapDenominator = na
var float anchoredVwap = na
var float sum = 0.0
var int count = 0
var float sumDev = 0.0

// Calculating Anchored VWAP and envelope
if not na(anchorBar)
    if bar_index == anchorBar
        avwapNumerator := high * volume + low * volume + close * volume
        avwapDenominator := volume * 3
        sum := 0.0
        count := 0
        sumDev := 0.0
    else if bar_index > anchorBar
        avwapNumerator := avwapNumerator[1] + high * volume + low * volume + close * volume
        avwapDenominator := avwapDenominator[1] + volume * 3
        sum := sum[1] + close
        count := count[1] + 1
        sumDev := sumDev[1] + math.pow(close - (sum / count), 2)
    anchoredVwap := avwapNumerator / avwapDenominator

// Standard deviation envelope calculation
float mean = sum / math.max(count, 1)
float stDev = math.sqrt(sumDev / math.max(count, 1))
float upperBand = anchoredVwap + stdDevMult * stDev
float lowerBand = anchoredVwap - stdDevMult * stDev

// CVD calculation and filter application
cvd = ta.cum(volume - ta.sma(volume, cvdLength))
bool cvdCondition = useCvdFilter ? (cvd[1] < cvd and cvd > cvd[1]) : true

// Dip and Rip pattern detection
roc = ta.roc(close, analysis_period)
dip_move_value = input.float(-8, title="Down (%)", step=0.50, minval=-100, maxval=-0.01, group="Settings")
rip_move_value = input.float(8, title="Up (%)", step=0.50, minval=0.01, maxval=100.00, group="Settings")
dip = roc <= dip_move_value and cvdCondition and (not useVwapFilter or close < anchoredVwap)
rip = roc >= rip_move_value and cvdCondition and (not useVwapFilter or close > anchoredVwap)

// State variables for signals and TP/SL execution
var bool inTrade = false // If we are currently in a trade
var bool takeLong = false // If the last signal was a buy
var bool takeShort = false // If the last signal was a sell
var float tradeEntryPrice = na // The trade entry price
var float tradeSL = na // The current trade's Stop Loss level
var float tradeTP = na // The current trade's Take Profit level

// Setting SL and TP levels for the trade
tradeSL := dip ? ta.highest(high, slPeriods) : (rip ? ta.lowest(low, slPeriods) : tradeSL)
tradeTP := dip ? tradeEntryPrice - (tradeSL - tradeEntryPrice) * tpPercent / 100 : (rip ? tradeEntryPrice + (tradeEntryPrice - tradeSL) * tpPercent / 100 : tradeTP)

// Trade entry logic
if (dip or rip) and not inTrade
    tradeEntryPrice := close
    inTrade := true
    takeLong := rip
    takeShort := dip

// Trade exit logic at TP or SL
if inTrade and ((takeLong and (low < tradeSL or high > tradeTP)) or (takeShort and (high > tradeSL or low < tradeTP)))
    inTrade := false // Exit the trade

// Display logic for signals based on the toggle
bool showLongSignal = rip and (not toggleSignals or not takeLong)
bool showShortSignal = dip and (not toggleSignals or not takeShort)

// Reset signals if toggle is active and trade is exited
if toggleSignals and not inTrade
    takeLong := true
    takeShort := true

// Strategy entry and exit logic
if showLongSignal
    strategy.entry("Long", strategy.long)

if showShortSignal
    strategy.close("Long")

if showShortSignal
    strategy.entry("Short", strategy.short)

if showLongSignal
    strategy.close("Short")

// Plotting of entry signals, anchored VWAP, and envelope
plot(upperBand, title="Upper Envelope", color=color.green)
plot(lowerBand, title="Lower Envelope", color=color.red)
plot(anchoredVwap, title="Anchored VWAP", color=color.blue)

// Coloring and shapes for Dip and Rip
barcolor(dip ? color.rgb(255, 0, 0) : na, title="Down Bar Color")
bgcolor(dip ? color.rgb(255, 0, 0, 80) : na, title="Down Background Color")
plotshape(dip, title="Dip - Down", location=location.top, color=color.rgb(255, 82, 82, 45), style=shape.square, size=size.tiny)
barcolor(rip ? color.rgb(0, 255, 0) : na, title="Up Bar Color")
bgcolor(rip ? color.rgb(0, 255, 0, 80) : na, title="Up Background Color")
plotshape(rip, title="Rip - Up", location=location.top, color=color.rgb(76, 175, 79, 55), style=shape.square, size=size.tiny)

// Strategy exit conditions for TP and SL
strategy.exit("Take Profit Long", from_entry = "Long", limit = tradeTP)
strategy.exit("Stop Loss Long", from_entry = "Long", stop = tradeSL)
strategy.exit("Take Profit Short", from_entry = "Short", limit = tradeTP)
strategy.exit("Stop Loss Short", from_entry = "Short", stop = tradeSL)

더 많은