
Chiến lược này dựa trên phương pháp Wyckoff, kết hợp chỉ số tương đối mạnh (RSI) và trung bình di chuyển khối lượng giao dịch (Volume MA) để xác định giai đoạn tích lũy và phân bổ của thị trường, tạo ra tín hiệu mua và bán. Đồng thời, chiến lược này sử dụng cơ chế dừng lỗ động, kiểm soát rủi ro bằng cách thiết lập giá trị tháo gỡ tối đa.
Chiến lược dừng lỗ rút động RSI bằng cách kết hợp RSI và chỉ số khối lượng giao dịch, xác định giai đoạn tích lũy và phân bổ của thị trường, đồng thời sử dụng cơ chế dừng lỗ rút động để kiểm soát rủi ro. Chiến lược này có một số tính thực tế trong việc nắm bắt xu hướng thị trường đồng thời quản lý rủi ro. Tuy nhiên, hiệu suất của chiến lược phụ thuộc vào lựa chọn tham số chỉ số và đặc điểm của thị trường, cần phải cải thiện tính ổn định và khả năng sinh lợi của nó thông qua việc tối ưu hóa và điều chỉnh liên tục.
/*backtest
start: 2024-05-07 00:00:00
end: 2024-06-06 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Wyckoff Methodology Strategy with Max Drawdown", overlay=true)
// Define input parameters
length = input(14, title="RSI Length")
overbought = input(70, title="RSI Overbought Level")
oversold = input(30, title="RSI Oversold Level")
volume_length = input(20, title="Volume MA Length")
initial_capital = input(10000, title="Initial Capital")
max_drawdown = input(500, title="Max Drawdown")
// Calculate RSI
rsi = ta.rsi(close, length)
// Calculate Volume Moving Average
vol_ma = ta.sma(volume, volume_length)
// Identify Accumulation Phase
accumulation = ta.crossover(rsi, oversold) and volume > vol_ma
// Identify Distribution Phase
distribution = ta.crossunder(rsi, overbought) and volume > vol_ma
// Plot RSI
hline(overbought, "Overbought", color=color.red)
hline(oversold, "Oversold", color=color.green)
plot(rsi, title="RSI", color=color.blue)
// Plot Volume and Volume Moving Average
plot(volume, title="Volume", color=color.orange, style=plot.style_histogram)
plot(vol_ma, title="Volume MA", color=color.purple)
// Variables to track drawdown
var float max_equity = initial_capital
var float drawdown = 0.0
// Update max equity and drawdown
current_equity = strategy.equity
if (current_equity > max_equity)
max_equity := current_equity
drawdown := max_equity - current_equity
// Generate Buy and Sell Signals
if (accumulation and drawdown < max_drawdown)
strategy.entry("Buy", strategy.long)
if (distribution and drawdown < max_drawdown)
strategy.entry("Sell", strategy.short)
// Plot Buy and Sell signals on chart
plotshape(series=accumulation, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")
plotshape(series=distribution, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL")
// Close positions if drawdown exceeds max drawdown
if (drawdown >= max_drawdown)
strategy.close_all("Max Drawdown Exceeded")
// Set strategy exit conditions
strategy.close("Buy", when=distribution or drawdown >= max_drawdown)
strategy.close("Sell", when=accumulation or drawdown >= max_drawdown)
// Display drawdown on chart
plot(drawdown, title="Drawdown", color=color.red, linewidth=2, style=plot.style_stepline)