
Chiến lược này là chiến lược giao dịch định lượng tần suất cao kết hợp hai phương pháp giao dịch cổ điển: giao dịch theo đà và hồi quy trung bình. Chiến lược này chạy trên khung thời gian 5 phút, sử dụng Đường trung bình động theo hàm mũ (EMA) để nắm bắt các cơ hội xu hướng trong khi sử dụng Dải Bollinger để xác định điều kiện giá quá mua và quá bán, đạt được lợi thế bổ sung của logic giao dịch kép. Chiến lược này được thiết kế với cấu hình tham số linh hoạt và bạn có thể chọn bật chế độ giao dịch đơn lẻ hoặc kết hợp tùy theo các điều kiện thị trường khác nhau.
Chiến lược này áp dụng thiết kế logic giao dịch hai lớp:
Chiến lược này kết hợp hai phương pháp giao dịch cổ điển, động lượng và hồi quy trung bình, để xây dựng một hệ thống giao dịch định lượng tần suất cao có khả năng thích ứng mạnh mẽ và rủi ro có thể kiểm soát được. Thiết kế mô-đun và tính linh hoạt của tham số của chiến lược mang lại giá trị thực tế tốt. Thông qua việc tối ưu hóa liên tục và cải thiện quản lý rủi ro, dự kiến sẽ đạt được lợi nhuận ổn định trong giao dịch thực tế.
/*backtest
start: 2024-12-06 00:00:00
end: 2025-01-04 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Momentum and Mean Reversion Strategy", shorttitle = "MMV_V1", overlay=true)
// --- Inputit ja parametrit ---
use_momentum = input.bool(true, title="Käytä Momentum-strategiaa")
use_mean_reversion = input.bool(true, title="Käytä Keskiarvoon Palautumista (BB)")
// Momentum-parametrit
short_ema_period = input.int(50, title="Lyhyt EMA")
long_ema_period = input.int(400, title="Pitkä EMA")
// Bollinger Band -parametrit
bb_length = input.int(20, title="BB Pituus")
bb_std = input.float(2.0, title="BB Standardipoikkeama")
// --- Momentum-strategia: EMA-risteämä ---
short_ema = ta.ema(close, short_ema_period)
long_ema = ta.ema(close, long_ema_period)
momentum_long_signal = ta.crossover(short_ema, long_ema)
momentum_short_signal = ta.crossunder(short_ema, long_ema)
// --- Keskiarvoon palautuminen: Bollinger Bands ---
[bb_upper, bb_middle, bb_lower] = ta.bb(close, bb_length, bb_std)
bb_long_signal = ta.crossover(close, bb_lower) // Osto, kun hinta nousee alemman BB:n yli
bb_short_signal = ta.crossunder(close, bb_upper) // Myynti, kun hinta laskee ylemmän BB:n ali
// --- Kaupankäyntilogiikka ---
if (use_momentum and momentum_long_signal)
strategy.entry("Momentum Long", strategy.long)
if (use_momentum and momentum_short_signal)
strategy.entry("Momentum Short", strategy.short)
if (use_mean_reversion and bb_long_signal)
strategy.entry("BB Long", strategy.long)
if (use_mean_reversion and bb_short_signal)
strategy.entry("BB Short", strategy.short)