
Đây là một chiến lược giao dịch định lượng dựa trên ba chỉ số kỹ thuật VWAP, MACD và RSI. Chiến lược này xác định các cơ hội mua và bán trên thị trường bằng cách kết hợp các tín hiệu đa dạng của giá trung bình trọng lượng giao dịch (VWAP), chỉ số phân tán xu hướng trung bình di chuyển (MACD) và chỉ số tương đối mạnh (RSI). Chiến lược này sử dụng cơ chế dừng lỗ phần trăm để quản lý rủi ro và sử dụng quản lý vị trí chiến lược để tối ưu hóa sử dụng vốn.
Lập luận cốt lõi của chiến lược dựa trên phân tích tổng hợp ba chỉ số chính:
Điều kiện mua hàng là:
Các điều kiện bán hàng phải được đáp ứng:
Chiến lược này xây dựng một hệ thống giao dịch tương đối hoàn chỉnh bằng cách sử dụng tổng hợp ba chỉ số kỹ thuật cổ điển VWAP, MACD và RSI. Chiến lược được thiết kế để tập trung vào độ tin cậy và quản lý rủi ro của tín hiệu, cải thiện chất lượng giao dịch thông qua xác minh chéo đa chỉ số. Mặc dù có một số khía cạnh cần được tối ưu hóa, nhưng khung tổng thể hợp lý và có khả năng mở rộng tốt.
/*backtest
start: 2024-10-27 00:00:00
end: 2024-11-26 00:00:00
period: 4h
basePeriod: 4h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("pbs", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Input for take-profit and stop-loss
takeProfitPercent = input.float(0.5, title="Take Profit (%)", step=0.1) / 100
stopLossPercent = input.float(0.25, title="Stop Loss (%)", step=0.1) / 100
macdFastLength = input.int(12, title="MACD Fast Length")
macdSlowLength = input.int(26, title="MACD Slow Length")
macdSignalLength = input.int(9, title="MACD Signal Length")
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level", step=1)
rsiOversold = input.int(30, title="RSI Oversold Level", step=1)
vwap = ta.vwap(close)
[macdLine, signalLine, _] = ta.macd(close, macdFastLength, macdSlowLength, macdSignalLength)
macdHistogram = macdLine - signalLine
rsi = ta.rsi(close, rsiLength)
plot(vwap, color=color.purple, linewidth=2, title="VWAP")
hline(rsiOverbought, "Overbought", color=color.red, linestyle=hline.style_dotted)
hline(rsiOversold, "Oversold", color=color.green, linestyle=hline.style_dotted)
plot(macdLine, color=color.blue, title="MACD Line")
plot(signalLine, color=color.orange, title="Signal Line")
// Buy Condition
longCondition = ta.crossover(close, vwap) and macdHistogram > 0 and rsi < rsiOverbought
// Sell Condition
shortCondition = ta.crossunder(close, vwap) and macdHistogram < 0 and rsi > rsiOversold
// Execute trades based on conditions
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit/Stop Loss", "Long", limit=close * (1 + takeProfitPercent), stop=close * (1 - stopLossPercent))
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("Take Profit/Stop Loss", "Short", limit=close * (1 - takeProfitPercent), stop=close * (1 + stopLossPercent))
// Plot Buy/Sell Signals
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")