
이 전략은 일선의 VWAP (거래량 가중 평균 가격) 을 입점과 출구의 신호로 사용한다. VWAP를 종결 가격 위에 통과할 때 더 많이 촉발하고, 상쇄 손실은 VWAP 아래의 전 K선 낮은 지점으로 설정하고, 목표 가격은 개장 가격 위 3점으로 설정한다. VWAP를 종결 가격 아래로 통과할 때 공백을 촉발하고, 상쇄 손실은 VWAP 위의 전 K선 높은 지점으로 설정하고, 목표 가격은 개장 가격 아래 3점으로 설정한다. 이 전략은 출구 조건을 포함하지 않으며, 역전 신호가 나타날 때까지 거래가 계속된다.
동적 스톱 및 고정 점 스톱을 활용하면서 주기간의 VWAP 데이터를 통해 트렌드를 판단하여 트렌드 상황을 효과적으로 파악하고, 회수 위험을 제어하고, 적시에 수익을 잠금 할 수 있습니다.
이 전략은 트렌드 판단과 신호 트리거를 위해 주기간의 VWAP 데이터를 사용하며, 동적 스톱 및 고정 점 수 스톱을 사용하여 위험을 제어하고 수익을 잠금하는 간단한 효과적 인 양적 거래 전략입니다. 트렌드 필터링, 동적 스톱, 포지션 관리 및 거래 시간 선택과 같은 측면의 최적화를 통해 전략의 안정성과 수익 잠재력을 더욱 향상시킬 수 있습니다. 그러나 실제 응용에서는 여전히 시장 특성과 거래 비용 및 변수 최적화 요소에 주의를 기울여야합니다.
/*backtest
start: 2024-03-06 00:00:00
end: 2024-03-07 00:00:00
period: 45m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy('Pine Script Tutorial Example Strategy 1', overlay=true, initial_capital=1000, default_qty_value=100, default_qty_type=strategy.percent_of_equity)
// fastEMA = ta.ema(close, 24)
// slowEMA = ta.ema(close, 200)
// Higher Time Frame
float sl = na
float tgt = na
posSize = 1
vwap_1d = request.security(syminfo.tickerid, "1D", ta.vwap(close))
// plot(vwap_1d)
// To avoid differences on historical and realtime bars, you can use this technique, which only returns a value from the higher timeframe on the bar after it completes:
// indexHighTF = barstate.isrealtime ? 1 : 0
// indexCurrTF = barstate.isrealtime ? 0 : 1
// nonRepaintingVWAP = request.security(syminfo.tickerid, "1D", close[indexHighTF])[indexCurrTF]
// plot(nonRepaintingVWAP, "Non-repainting VWAP")
enterLong = ta.crossover(close, vwap_1d)
exitLong = ta.crossunder(close, vwap_1d)
enterShort = ta.crossunder(close, vwap_1d)
exitShort = ta.crossover(close, vwap_1d)
if enterLong
sl := low[1]>vwap_1d ?low[1]:vwap_1d
tgt:=close+3
strategy.entry("EL", strategy.long, qty=posSize)
strategy.exit('exitEL', 'EL', stop=sl, limit=tgt)
if enterShort
sl := high[1]<vwap_1d ?high[1]:vwap_1d
tgt := close-3
strategy.entry("ES", strategy.short, qty=posSize)
strategy.exit('exitES', 'ES', stop=sl, limit=tgt)
// if exitLong
// strategy.close("EL")
// if exitShort
// strategy.close("ES")
// goLongCondition1 = ta.crossover(close, vwap_1d)
// timePeriod = time >= timestamp(syminfo.timezone, 2021, 01, 01, 0, 0)
// notInTrade = strategy.position_size <= 0
// if goLongCondition1 and timePeriod and notInTrade
// stopLoss = low[1]
// takeProfit = close+3
// strategy.entry('long', strategy.long)
// strategy.exit('exit', 'long', stop=stopLoss, limit=takeProfit)
plot(close, color=color.new(#00c510, 0))
plot(vwap_1d, color=color.new(#f05619, 0))
plot(sl, color=color.new(#fbff00, 0))
plot(tgt, color=color.new(#00e1ff, 0))