
Chiến lược này là một hệ thống giao dịch tổng hợp dựa trên nhiều chỉ số kỹ thuật, kết hợp các chỉ số động lực, chỉ số xu hướng và chỉ số biến động để nắm bắt các cơ hội biến động ngắn hạn của thị trường. Chiến lược này xác định các cơ hội giao dịch thông qua tín hiệu giao chéo MACD, xác nhận xu hướng EMA, RSI vượt quá điều kiện bán tháo và lọc cường độ xu hướng ADX và sử dụng lệnh dừng động dựa trên ATR để quản lý rủi ro.
Logic cốt lõi của chiến lược này dựa trên các thành phần chính sau:
Chiến lược này xây dựng một hệ thống giao dịch hoàn chỉnh bằng cách sử dụng nhiều chỉ số kỹ thuật tổng hợp. Mặc dù có một số thách thức về sự chậm trễ và tối ưu hóa tham số, nhưng thông qua quản lý rủi ro hợp lý và tối ưu hóa liên tục, chiến lược thể hiện khả năng thích ứng và độ tin cậy tốt.
/*backtest
start: 2024-02-18 00:00:00
end: 2025-02-16 08:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Optimized Impulse Wave Strategy", overlay=true)
// === INPUT PARAMETERS ===
fast_length = input(12, title="MACD Fast Length")
slow_length = input(26, title="MACD Slow Length")
signal_smoothing = input(9, title="MACD Signal Smoothing")
ema_length = input(200, title="EMA Length")
rsi_length = input(14, title="RSI Length")
adx_length = input(14, title="ADX Length")
adx_smoothing = input(14, title="ADX Smoothing")
atr_length = input(14, title="ATR Length")
risk_reward_ratio = input(2, title="Risk-Reward Ratio")
adx_threshold = input(20, title="ADX Threshold")
// === INDICATORS ===
[macdLine, signalLine, _] = ta.macd(close, fast_length, slow_length, signal_smoothing)
ema = ta.ema(close, ema_length)
rsi = ta.rsi(close, rsi_length)
[dmiPlus, dmiMinus, adx] = ta.dmi(adx_length, adx_smoothing)
// === ENTRY CONDITIONS ===
bullishTrend = ta.crossover(macdLine, signalLine) and close > ema and adx > adx_threshold and rsi > 50
bearishTrend = ta.crossunder(macdLine, signalLine) and close < ema and adx > adx_threshold and rsi < 50
// === STOP-LOSS & TAKE-PROFIT CALCULATION ===
longStopLoss = close - ta.atr(atr_length) * 1.5
longTakeProfit = close + (ta.atr(atr_length) * 1.5 * risk_reward_ratio)
shortStopLoss = close + ta.atr(atr_length) * 1.5
shortTakeProfit = close - (ta.atr(atr_length) * 1.5 * risk_reward_ratio)
// === STRATEGY EXECUTION ===
// Enter Long
if bullishTrend
strategy.entry("Long", strategy.long)
strategy.exit("TakeProfitLong", from_entry="Long", limit=longTakeProfit, stop=longStopLoss)
// Enter Short
if bearishTrend
strategy.entry("Short", strategy.short)
strategy.exit("TakeProfitShort", from_entry="Short", limit=shortTakeProfit, stop=shortStopLoss)
// === PLOTTING ===
plot(ema, title="EMA 200", color=color.blue, linewidth=2)
plotshape(series=bullishTrend, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
plotshape(series=bearishTrend, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal")
// === ALERTS ===
alertcondition(bullishTrend, title="Bullish Entry", message="Buy Signal Triggered!")
alertcondition(bearishTrend, title="Bearish Entry", message="Sell Signal Triggered!")
// === DEBUGGING LOG ===
label.new(bar_index, high, "ADX: " + str.tostring(adx), color=color.white, textcolor=color.black)
label.new(bar_index, low, "MACD Cross: " + str.tostring(macdLine), color=color.white, textcolor=color.black)