
Chiến lược này là một chiến lược giao dịch định lượng kết hợp với giá trung bình cân bằng khối lượng giao dịch (VWAP) và phân tán xu hướng trung bình di chuyển (MACD). Chiến lược này tìm kiếm thời điểm vào và ra vào tốt nhất theo hướng xu hướng thị trường bằng cách kết hợp chỉ số động lực giá với trọng lượng giao dịch. Chiến lược sử dụng VWAP làm mức tham chiếu giá quan trọng, đồng thời sử dụng chỉ số MACD để nắm bắt sự thay đổi động lực thị trường, do đó có thể định vị điểm mua và bán chính xác hơn trong giao dịch.
Logic cốt lõi của chiến lược này dựa trên các yếu tố chính sau:
Chiến lược hai chỉ số VWAP-MACD cung cấp hỗ trợ kỹ thuật đáng tin cậy cho các quyết định giao dịch bằng cách kết hợp phân tích trọng lượng giao dịch và động lực. Chiến lược được thiết kế hợp lý, logic rõ ràng, có khả năng thực tiễn tốt và khả năng mở rộng.
/*backtest
start: 2025-01-08 00:00:00
end: 2025-02-06 08:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("VWAP + MACD Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=200)
// VWAP Calculation
vwapValue = ta.vwap(close)
// MACD Settings
fastLength = input.int(12, title="MACD Fast Length")
slowLength = input.int(26, title="MACD Slow Length")
signalSmoothing = input.int(9, title="MACD Signal Smoothing")
// MACD Calculation
[macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalSmoothing)
macdHistogram = macdLine - signalLine
// Plot VWAP
plot(vwapValue, color=color.orange, title="VWAP")
// Plot MACD
hline(0, "Zero Line", color=color.gray)
plot(macdLine, color=color.blue, title="MACD Line")
plot(signalLine, color=color.red, title="Signal Line")
plot(macdHistogram, color=(macdHistogram >= 0 ? color.green : color.red), style=plot.style_histogram, title="MACD Histogram")
// Long Condition: MACD crosses above Signal and price is above VWAP
longCondition = ta.crossover(macdLine, signalLine) and close > vwapValue
if (longCondition)
strategy.entry("Long", strategy.long)
// Short Condition: MACD crosses below Signal and price is below VWAP
shortCondition = ta.crossunder(macdLine, signalLine) and close < vwapValue
if (shortCondition)
strategy.entry("Short", strategy.short)
// Exit Long: MACD crosses below Signal or price crosses below VWAP
exitLong = ta.crossunder(macdLine, signalLine) or close < vwapValue
if (exitLong)
strategy.close("Long")
// Exit Short: MACD crosses above Signal or price crosses above VWAP
exitShort = ta.crossover(macdLine, signalLine) or close > vwapValue
if (exitShort)
strategy.close("Short")