
Chiến lược này kết hợp nhiều chỉ số như EMA, MACD, VWAP và RSI để nắm bắt các cơ hội giao dịch có xác suất cao. Chiến lược sử dụng EMA để đánh giá xu hướng, MACD để đánh giá động lượng, VWAP để đánh giá khối lượng giao dịch, RSI để đánh giá tình trạng quá mua quá bán. Chiến lược tạo ra tín hiệu mua và bán dựa trên sự kết hợp của các chỉ số này, đồng thời sử dụng lệnh dừng di chuyển để bảo vệ lợi nhuận.
Chiến lược này kết hợp nhiều chỉ số để đánh giá tình trạng thị trường, tạo ra tín hiệu giao dịch, đồng thời sử dụng dừng chân di động để bảo vệ lợi nhuận. Các tham số chiến lược có thể được điều chỉnh theo sở thích của người dùng, tăng tính linh hoạt của chiến lược. Tuy nhiên, chiến lược có thể hoạt động kém trong thị trường xung đột, có thể phải đối mặt với sự rút lui lớn khi xu hướng đảo ngược, do đó cần phải được tối ưu hóa và cải tiến theo các thị trường và giống khác nhau.
/*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)