
이 전략은 VWAP (거래량 가중 평균 가격) 과 슈퍼 트렌드 지표를 결합한다. 가격과 VWAP의 상대적인 위치, 그리고 슈퍼 트렌드 지표의 방향을 비교하여 매매 신호를 판단한다. 가격이 VWAP를 넘어서서 슈퍼 트렌드가 긍정적일 때, 매매 신호를 생성한다. 가격이 VWAP를 넘어서서 슈퍼 트렌드가 부정적일 때, 매매 신호를 생성한다. 이 전략은 또한 지난 한 번의 신호 상태를 기록하여, 반대 방향으로의 신호가 나타날 때까지 반복되는 신호를 방지한다.
VWAP와 슈퍼 트렌드 매매 전략은 두 가지 다른 유형의 지표를 결합하여 시장의 추세와 잠재적 인 전환점을 포괄적으로 포착하려고 노력합니다. 전략 논리는 명확하고 구현 및 최적화하기 쉽습니다. 그러나 전략의 성과는 매개 변수 선택에 의존하며 위험 관리 조치가 부족합니다. 실제 응용에서는 다양한 시장 환경과 거래 요구에 맞게 추가 최적화 및 개선이 필요합니다.
/*backtest
start: 2023-05-28 00:00:00
end: 2024-06-02 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title="VWAP and Super Trend Buy/Sell Strategy", shorttitle="VWAPST", overlay=true)
//===== VWAP =====
showVWAP = input.bool(title="Show VWAP", defval=true, group="VWAP")
VWAPSource = input.source(title="VWAP Source", defval=hl2, group="VWAP")
VWAPrice = ta.vwap(VWAPSource)
plot(showVWAP ? VWAPrice : na, color=color.teal, title="VWAP", linewidth=2)
//===== Super Trend =====
showST = input.bool(true, "Show SuperTrend Indicator", group="Super Trend")
Period = input.int(title="ATR Period", defval=10, group="Super Trend")
Multiplier = input.float(title="ATR Multiplier", defval=2.0, group="Super Trend")
// Super Trend ATR
Up = hl2 - (Multiplier * ta.atr(Period))
Dn = hl2 + (Multiplier * ta.atr(Period))
var float TUp = na
var float TDown = na
TUp := na(TUp[1]) ? Up : close[1] > TUp[1] ? math.max(Up, TUp[1]) : Up
TDown := na(TDown[1]) ? Dn : close[1] < TDown[1] ? math.min(Dn, TDown[1]) : Dn
var int Trend = na
Trend := na(Trend[1]) ? 1 : close > TDown[1] ? 1 : close < TUp[1] ? -1 : Trend[1]
Tsl = Trend == 1 ? TUp : TDown
linecolor = Trend == 1 ? color.green : color.red
plot(showST ? Tsl : na, color=linecolor, style=plot.style_line, linewidth=2, title="SuperTrend")
// Buy/Sell Conditions
var bool previousBuysignal = false
var bool previousSellsignal = false
buysignal = not previousBuysignal and Trend == 1 and close > VWAPrice
sellsignal = not previousSellsignal and Trend == -1 and close < VWAPrice
// Ensure the signals are not repetitive
if (buysignal)
previousBuysignal := true
previousSellsignal := false
else if (sellsignal)
previousBuysignal := false
previousSellsignal := true
// Execute buy and sell orders
if (buysignal)
strategy.entry("Buy", strategy.long)
if (sellsignal)
strategy.entry("Sell", strategy.short)
// Plot Buy/Sell Labels
//plotshape(buysignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", textcolor=color.white, size=size.normal)
//plotshape(sellsignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", textcolor=color.white, size=size.normal)