
Chiến lược này là hệ thống giao dịch đảo ngược xu hướng dựa trên sự phối hợp của nhiều chỉ báo kỹ thuật, chủ yếu được sử dụng cho giao dịch ngắn hạn trong khoảng thời gian 5 phút. Chiến lược này tích hợp các phương pháp phân tích đa chiều như theo dõi xu hướng trung bình động, xác nhận khối lượng, lọc biến động ATR, v.v. và sàng lọc các cơ hội giao dịch đảo chiều có xác suất cao thông qua các điều kiện tham gia nghiêm ngặt. Chiến lược này đặc biệt phù hợp để hoạt động trong giờ giao dịch có tính thanh khoản tốt và có thể nắm bắt hiệu quả các cơ hội đảo chiều ngắn hạn trên thị trường.
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 là một hệ thống giao dịch ngắn hạn được thiết kế tốt, giúp xác định tín hiệu đảo chiều và kiểm soát rủi ro đáng tin cậy hơn thông qua việc phối hợp nhiều chỉ báo. Ưu điểm của chiến lược này nằm ở các tùy chọn cấu hình linh hoạt và cơ chế quản lý rủi ro hoàn hảo, nhưng nó cũng đòi hỏi các nhà giao dịch phải tối ưu hóa hoàn toàn các cài đặt tham số và sử dụng nó trong môi trường thị trường phù hợp. Thông qua quá trình tối ưu hóa và cải tiến liên tục, chiến lược này có tiềm năng trở thành một công cụ giao dịch ổn định trong ngắn hạn.
/*backtest
start: 2024-01-17 00:00:00
end: 2025-01-15 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=5
strategy("Reversal Signals Strategy [AlgoAlpha]", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Inputs
group_strategy = "Strategy Settings"
riskRewardRatio = input.float(2.0, "Risk-Reward Ratio", tooltip="Take Profit is Risk-Reward times Stop Loss", group=group_strategy)
stopLossATRMultiplier = input.float(1.5, "Stop Loss ATR Multiplier", tooltip="Multiplier for ATR-based stop loss", group=group_strategy)
// Reversal Signal Detection (from previous script)
group_reversal = "Reversal Detection Settings"
lookbackPeriod = input.int(12, "Candle Lookback", group=group_reversal)
confirmationPeriod = input.int(3, "Confirm Within", group=group_reversal)
enableVolumeConfirmation = input.bool(true, "Use Volume Confirmation", group=group_reversal)
group_trend = "Trend Settings"
trendMAPeriod = input.int(50, "Trend MA Period", group=group_trend)
trendMAType = input.string("EMA", "MA Type", options=["SMA", "EMA", "WMA", "VWMA"], group=group_trend)
group_appearance = "Appearance"
bullColor = input.color(#00ffbb, "Bullish Color", group=group_appearance)
bearColor = input.color(#ff1100, "Bearish Color", group=group_appearance)
// Moving Average Selection
ma_current = switch trendMAType
"SMA" => ta.sma(close, trendMAPeriod)
"EMA" => ta.ema(close, trendMAPeriod)
"WMA" => ta.wma(close, trendMAPeriod)
"VWMA" => ta.vwma(close, trendMAPeriod)
// Volume Confirmation
volumeIsHigh = volume > ta.sma(volume, 20)
// Calculate Reversal Scores
bullCandleScore = 0
bearCandleScore = 0
for i = 0 to (lookbackPeriod - 1)
bullCandleScore += close < low[i] ? 1 : 0
bearCandleScore += close > high[i] ? 1 : 0
// Reversal Signals
bullSignal = bullCandleScore == (lookbackPeriod - 1) and (not enableVolumeConfirmation or volumeIsHigh)
bearSignal = bearCandleScore == (lookbackPeriod - 1) and (not enableVolumeConfirmation or volumeIsHigh)
// ATR-based Stop Loss and Take Profit
atrValue = ta.atr(14)
stopLossLevel = stopLossATRMultiplier * atrValue
takeProfitLevel = stopLossLevel * riskRewardRatio
// Strategy Orders
if bullSignal
strategy.entry("Long", strategy.long)
strategy.exit("Long TP/SL", from_entry="Long", stop=close - stopLossLevel, limit=close + takeProfitLevel)
if bearSignal
strategy.entry("Short", strategy.short)
strategy.exit("Short TP/SL", from_entry="Short", stop=close + stopLossLevel, limit=close - takeProfitLevel)
// Plot Reversal Signals
plotshape(bullSignal, title="Buy Signal", style=shape.labelup, location=location.belowbar, color=bullColor, size=size.small, text="B")
plotshape(bearSignal, title="Sell Signal", style=shape.labeldown, location=location.abovebar, color=bearColor, size=size.small, text="S")
// Alerts for trade signals
alertcondition(bullSignal, "Bullish Reversal", "Bullish Reversal Signal Detected")
alertcondition(bearSignal, "Bearish Reversal", "Bearish Reversal Signal Detected")