
Chiến lược này là một hệ thống giao dịch tự động kết hợp theo dõi xu hướng nhiều chu kỳ và quản lý rủi ro. Nó chủ yếu xác định cơ hội giao dịch thông qua chỉ số di chuyển trung bình ((EMA) cho hai chu kỳ thời gian 5 phút và 1 phút, đồng thời áp dụng các thiết lập dừng lỗ và lợi nhuận ở tỷ lệ phần trăm cố định để kiểm soát rủi ro. Chiến lược này đặc biệt phù hợp với các nhà giao dịch ngắn hạn, đặc biệt là những nhà giao dịch chuyên theo dõi xu hướng.
Lập luận cốt lõi của chiến lược dựa trên sự phán đoán xu hướng trong hai chu kỳ thời gian:
Đây là một chiến lược theo dõi xu hướng có cấu trúc, logic rõ ràng. Bằng cách kết hợp phân tích đa chu kỳ và quản lý rủi ro nghiêm ngặt, chiến lược có thể nắm bắt được xu hướng thị trường một cách hiệu quả trong khi bảo vệ vốn. Mặc dù có một số không gian tối ưu hóa, nhưng khung cơ bản của chiến lược là vững chắc, phù hợp để cải tiến và tùy chỉnh thêm cho một chiến lược cơ bản.
/*backtest
start: 2025-01-21 00:00:00
end: 2025-02-20 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"DOGE_USDT"}]
*/
//@version=5
strategy("Scalping Strategy: 1-min Entries with 5-min 200 EMA Filter", overlay=true, initial_capital=10000, currency=currency.USD, default_qty_type=strategy.percent_of_equity, default_qty_value=5, calc_on_every_tick=true)
// --- Higher Timeframe Trend Filter ---
// Get the 200-period EMA on a 5-minute timeframe
ema200_5 = request.security(syminfo.tickerid, "5", ta.ema(close, 200), lookahead=barmerge.lookahead_on)
plot(ema200_5, color=color.purple, title="5-min 200 EMA")
// --- Local (1-Minute) Indicators ---
// On a 1-minute chart, calculate a 20-period EMA for entry triggers
ema20_1 = ta.ema(close, 20)
plot(ema20_1, color=color.yellow, title="1-min 20 EMA")
// --- Entry Conditions ---
// For long entries:
// - The overall trend is bullish: current close > 5-min 200 EMA
// - The 1-min candle closes and crosses above its 20 EMA
longCondition = (close > ema200_5) and ta.crossover(close, ema20_1)
// For short entries:
// - Overall bearish trend: current close < 5-min 200 EMA
// - 1-min candle crosses below its 20 EMA
shortCondition = (close < ema200_5) and ta.crossunder(close, ema20_1)
// --- Risk Management Settings ---
// For scalping, use a tight stop loss. Here we set risk at 0.5% of the entry price.
var float riskPerc = 0.005 // 0.5% risk per trade
// Declare global variables for stop loss and take profit so they can be used outside the if-blocks
var float longStop = na
var float longTP = na
var float shortStop = na
var float shortTP = na
// --- Trade Execution ---
if (longCondition)
entryPrice = close
// Stop loss for long: 0.5% below entry
longStop := entryPrice * (1 - riskPerc)
// Take profit: twice the risk distance (1:2 risk-reward)
longTP := entryPrice + 2 * (entryPrice - longStop)
strategy.entry("Long", strategy.long)
strategy.exit("Long Exit", from_entry="Long", stop=longStop, limit=longTP)
if (shortCondition)
entryPrice = close
// Stop loss for short: 0.5% above entry
shortStop := entryPrice * (1 + riskPerc)
// Take profit: twice the risk distance
shortTP := entryPrice - 2 * (shortStop - entryPrice)
strategy.entry("Short", strategy.short)
strategy.exit("Short Exit", from_entry="Short", stop=shortStop, limit=shortTP)
// --- Visual Debug Markers ---
// Plot a green triangle below bars when a long signal is generated
plotshape(longCondition, title="Long Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.tiny)
// Plot a red triangle above bars when a short signal is generated
plotshape(shortCondition, title="Short Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.tiny)