
이 전략은 EMA, VWAP 및 거래량에 기반한 거래 전략이다. 주요 아이디어는 특정 거래 시간 내에 종결 가격이 VWAP와 EMA를 돌파하고 거래량이 전 K 선의 거래량보다 큰 경우 포지션 개시 신호를 발생시키는 것이다. 동시에 중지 손실과 정지 을 설정하고, 특정 시간 동안 포지션을 평정하는 조건이다.
이 전략은 가격 추세, 시장의 공정 가치 및 거래량을 종합적으로 고려하여 특정 거래 시간 내에 거래합니다. 중지 손실을 설정하고 거래 시간을 제한하지만 실제 응용에서는 여전히 흔들림 시장 및 슬라이드 포인트와 같은 위험을 주의해야합니다. 향후에는 더 많은 필터링 조건, 최적화 매개 변수 및 포지션 관리와 같은 방법을 추가하여 전략의 안정성과 수익성을 향상시킬 수 있습니다.
/*backtest
start: 2024-04-27 00:00:00
end: 2024-04-28 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA, VWAP, Volume Strategy", overlay=true, process_orders_on_close=true)
// Inputs
emaLength = input.int(21, title="EMA Length")
vwapSource = input.source(defval=hlc3, title='VWAP Source')
stopLossPoints = input.float(100, title="Stop Loss (points)")
targetPoints = input.float(200, title="Target (points)")
session = input("0950-1430", title='Only take entry during')
exit = input(defval='1515-1525', title='Exit Trade')
tradein = not na(time(timeframe.period, session))
exit_time = not na(time(timeframe.period, exit))
// Calculate indicators
ema = ta.ema(close, emaLength)
vwapValue = ta.vwap(vwapSource)
// Entry Conditions
longCondition = close > vwapValue and close > ema and volume > volume[1] and close > open and tradein
shortCondition = close < vwapValue and close < ema and volume > volume[1] and open > close and tradein
// Exit Conditions
longExitCondition = ta.crossunder(close, vwapValue) or ta.crossunder(close, ema) or close - strategy.position_avg_price >= targetPoints or close - strategy.position_avg_price <= -stopLossPoints or exit_time
shortExitCondition = ta.crossover(close, vwapValue) or ta.crossover(close, ema) or strategy.position_avg_price - close >= targetPoints or strategy.position_avg_price - close <= -stopLossPoints or exit_time
// Plotting
plot(vwapValue, color=color.blue, title="VWAP")
plot(ema, color=color.green, title="EMA")
// Strategy
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.entry("Short", strategy.short)
if longExitCondition
strategy.close('Long', immediately=true)
if shortExitCondition
strategy.close("Short", immediately=true)