
이 전략은 VWAP (대량 가중 평균 가격) 지표와 가격의 교차 관계를 기반으로 거래한다. 가격이 VWAP를 상향으로 통과할 때 상위 포지션을 열고, VWAP를 하향으로 통과할 때 빈 포지션을 열는다. 동시에 ATR (평균 실제 변동의 폭) 지표를 사용하여 역동적인 중지 손실과 중지 수준을 계산하여 위험을 제어하고 수익을 잠금합니다.
이 전략은 VWAP를 중심으로 가격과 교차하여 거래 신호를 생성하고 ATR과 결합하여 동적 스톱로스를 구현하여 추세를 파악하는 동시에 회수 위험을 제어합니다. 전체적인 아이디어는 간단하고 이해하기 쉽습니다. 그러나 전략에는 보조 지표를 도입하고 스톱로스 로직을 최적화하고 자금 관리를 추가함으로써 전략의 안정성과 수익성을 향상시킬 수 있습니다.
/*backtest
start: 2023-03-26 00:00:00
end: 2024-03-31 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Hannah Strategy Stop Loss and Take Profit", overlay=true)
// Inputs
cumulativePeriod = input(40, "VWAP Period")
atrPeriod = input(14, "ATR Period")
multiplier = input(1.5, "ATR Multiplier for Stop Loss")
targetMultiplier = input(3, "ATR Multiplier for Take Profit")
// Calculations for VWAP
typicalPrice = (high + low + close) / 3
typicalPriceVolume = typicalPrice * volume
cumulativeTypicalPriceVolume = sum(typicalPriceVolume, cumulativePeriod)
cumulativeVolume = sum(volume, cumulativePeriod)
vwapValue = cumulativeTypicalPriceVolume / cumulativeVolume
// Plot VWAP on the chart
plot(vwapValue, color=color.blue, title="VWAP")
// Entry Conditions based on price crossing over/under VWAP
longCondition = crossover(close, vwapValue)
shortCondition = crossunder(close, vwapValue)
// ATR Calculation for setting dynamic stop loss and take profit
atr = atr(atrPeriod)
// Execute Trades with Dynamic Stop Loss and Take Profit based on ATR
if (longCondition)
strategy.entry("Long", strategy.long)
// Setting stop loss and take profit for long positions
strategy.exit("Long Exit", "Long", stop=close - atr * multiplier, limit=close + atr * targetMultiplier)
if (shortCondition)
strategy.entry("Short", strategy.short)
// Setting stop loss and take profit for short positions
strategy.exit("Short Exit", "Short", stop=close + atr * multiplier, limit=close - atr * targetMultiplier)