
Đây là một chiến lược giao dịch quay trở lại giá trị trung bình dựa trên giá trị trung bình cân bằng khối lượng giao dịch (VWAP) và kênh chênh lệch chuẩn. Chiến lược này tìm kiếm cơ hội giao dịch bằng cách xác định mức độ giá lệch khỏi VWAP, giao dịch ngược khi giá vượt qua biên giới kênh chênh lệch chuẩn và thanh toán khi giá quay trở lại VWAP. Phương pháp này tận dụng đầy đủ tính năng quay trở lại giá trị trung bình của thị trường, kết hợp các nguyên tắc phân tích kỹ thuật và thống kê.
Trung tâm của chiến lược là tạo ra các khu vực giao dịch bằng cách tính toán chênh lệch chuẩn của VWAP và biến động giá. Các thực hiện cụ thể bao gồm:
Đây là một chiến lược trung lập dựa trên nguyên tắc thống kê, nắm bắt sự lệch và hồi phục của giá thông qua VWAP và kênh chênh lệch chuẩn. Chiến lược có tính chất khách quan, có hệ thống, nhưng cần chú ý đến kiểm soát rủi ro và tối ưu hóa tham số trong ứng dụng thực tế.
/*backtest
start: 2024-12-03 00:00:00
end: 2024-12-10 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jklonoskitrader
//@version=5
strategy("ETHUSD VWAP Fade Strategy", overlay=true)
// Input for standard deviation multiplier
std_multiplier = input.float(2.0, title="Standard Deviation Multiplier")
// Calculate cumulative VWAP
cumulative_pv = ta.cum(close * volume) // Cumulative price * volume
cumulative_vol = ta.cum(volume) // Cumulative volume
vwap = cumulative_pv / cumulative_vol // VWAP calculation
// Calculate standard deviation of the closing price
length = input.int(20, title="Standard Deviation Length")
std_dev = ta.stdev(close, length)
upper_band = vwap + std_multiplier * std_dev
lower_band = vwap - std_multiplier * std_dev
// Plot VWAP and its bands
plot(vwap, color=color.blue, linewidth=2, title="VWAP")
plot(upper_band, color=color.red, linewidth=1, title="Upper Band")
plot(lower_band, color=color.green, linewidth=1, title="Lower Band")
// Strategy conditions
go_long = ta.crossunder(close, lower_band)
go_short = ta.crossover(close, upper_band)
// Execute trades
if (go_long)
strategy.entry("Long", strategy.long)
if (go_short)
strategy.entry("Short", strategy.short)
// Exit strategy
if (strategy.position_size > 0 and close > vwap)
strategy.close("Long")
if (strategy.position_size < 0 and close < vwap)
strategy.close("Short")