이 전략은 EMA, MACD, VWAP 및 RSI와 같은 여러 지표를 결합하여 높은 확률의 거래 기회를 잡습니다. 전략은 EMA를 사용하여 트렌드 방향을 판단하고, MACD는 동력을 판단하고, VWAP는 거래량을 판단하고, RSI는 초과 판매 상황을 판단합니다. 전략은 이러한 지표의 조합에 따라 구매 및 판매 신호를 생성하고, 동시에 이동 스톱을 사용하여 이익을 보호합니다.
이 전략은 여러 지표를 결합하여 시장 상태를 판단하고 거래 신호를 생성하며 이동 상쇄를 사용하여 수익을 보호합니다. 전략의 매개 변수는 사용자의 선호도에 따라 조정되어 전략의 유연성을 향상시킬 수 있습니다. 그러나 전략은 흔들리는 시장에서 좋지 않은 성능을 발휘할 수 있으며, 추세가 변하면 큰 회수와 마주할 수 있으므로 다양한 시장과 품종에 따라 최적화 및 개선이 필요합니다. 전략의 안정성과 수익성을 높이기 위해 향후에는 더 많은 필터링 조건, 동적 상쇄 방식, 매개 변수 최적화 및 포지션 관리 등의 최적화를 추가하는 것이 고려 될 수 있습니다.
/*backtest
start: 2024-04-01 00:00:00
end: 2024-04-30 23:59:59
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Intraday Strategy", overlay=true)
// Input parameters
emaLength = input.int(50, title="EMA Length")
macdShort = input.int(12, title="MACD Short Period")
macdLong = input.int(26, title="MACD Long Period")
macdSignal = input.int(9, title="MACD Signal Period")
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
risk = input.float(1, title="Risk Percentage", minval=0.1, step=0.1)
trailOffset = input.float(0.5, title="Trailing Stop Offset", minval=0.1, step=0.1)
// Calculating indicators
ema = ta.ema(close, emaLength)
[macdLine, signalLine, _] = ta.macd(close, macdShort, macdLong, macdSignal)
rsi = ta.rsi(close, rsiLength)
vwap = ta.vwap(close)
// Entry conditions
longCondition = ta.crossover(macdLine, signalLine) and close > ema and rsi < rsiOverbought and close > vwap
shortCondition = ta.crossunder(macdLine, signalLine) and close < ema and rsi > rsiOversold and close < vwap
// Exit conditions
longExitCondition = ta.crossunder(macdLine, signalLine) or close < ema
shortExitCondition = ta.crossover(macdLine, signalLine) or close > ema
// Position sizing based on risk percentage
capital = strategy.equity
positionSize = (capital * (risk / 100)) / close
// Executing trades
if (longCondition)
strategy.entry("Long", strategy.long, qty=1)
if (shortCondition)
strategy.entry("Short", strategy.short, qty=1)
if (longExitCondition)
strategy.close("Long")
if (shortExitCondition)
strategy.close("Short")
// Trailing stop loss
if (strategy.position_size > 0)
strategy.exit("Trailing Stop Long", from_entry="Long", trail_price=close, trail_offset=trailOffset)
if (strategy.position_size < 0)
strategy.exit("Trailing Stop Short", from_entry="Short", trail_price=close, trail_offset=trailOffset)
// Plotting indicators
plot(ema, title="EMA", color=color.blue)
hline(rsiOverbought, "Overbought", color=color.red)
hline(rsiOversold, "Oversold", color=color.green)
plot(rsi, title="RSI", color=color.purple)
plot(vwap, title="VWAP", color=color.orange)