
Chiến lược này là một hệ thống giao dịch trong ngày kết hợp nhiều chỉ số kỹ thuật, chủ yếu dựa trên tín hiệu chéo của chỉ số chuyển động trung bình ((EMA) trong thời gian nhanh và chậm như cơ sở đầu vào chính, đồng thời kết hợp với chỉ số tương đối mạnh ((RSI) để lọc động lực và sử dụng chỉ số sóng thực ((ATR) để thiết lập vị trí dừng lỗ động để xây dựng một hệ thống giao dịch hoàn chỉnh. Chiến lược này thực hiện việc nắm bắt sự biến động của thị trường ngắn hạn thông qua kiểm soát rủi ro nghiêm ngặt và thiết lập dừng lỗ động.
Lập luận cốt lõi của chiến lược bao gồm:
Các quy tắc giao dịch cụ thể như sau:
Đề xuất kiểm soát rủi ro:
Chiến lược này xây dựng một hệ thống giao dịch hoàn chỉnh hơn bằng cách kết hợp theo dõi xu hướng EMA, lọc động lực RSI và kiểm soát rủi ro động lực ATR. Đặc điểm chính của chiến lược là sử dụng hiệu quả phối hợp của nhiều chỉ số kỹ thuật, đồng thời tập trung vào quản lý rủi ro. Mặc dù có một số không gian tối ưu hóa, nhưng khái niệm thiết kế tổng thể phù hợp với tư duy hệ thống hóa của giao dịch định lượng.
/*backtest
start: 2024-02-10 00:00:00
end: 2025-02-08 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Day Trading EMA/RSI Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=200)
// Ulazni parametri
fastEmaPeriod = input.int(9, "Fast EMA Period", minval=1)
slowEmaPeriod = input.int(21, "Slow EMA Period", minval=1)
rsiPeriod = input.int(14, "RSI Period", minval=1)
rsiOversold = input.int(30, "RSI Oversold Level")
rsiOverbought = input.int(70, "RSI Overbought Level")
atrPeriod = input.int(14, "ATR Period", minval=1)
atrMultiplier = input.float(1.5, "ATR Multiplier za Stop Loss", step=0.1)
takeProfitFactor= input.float(2.0, "Take Profit Factor", step=0.1)
// Izračun indikatora
fastEMA = ta.ema(close, fastEmaPeriod)
slowEMA = ta.ema(close, slowEmaPeriod)
rsiValue = ta.rsi(close, rsiPeriod)
atrValue = ta.atr(atrPeriod)
// Definicija trenda: ako je fastEMA iznad slowEMA, smatramo da je trend uzlazan, inače silazni.
trendUp = fastEMA > slowEMA
trendDown = fastEMA < slowEMA
// Uvjeti za ulaz:
// Ulaz u long poziciju: crossover fastEMA i slowEMA, uz filtriranje da RSI nije prekupovan (manje od rsiOverbought)
longCondition = ta.crossover(fastEMA, slowEMA) and (rsiValue < rsiOverbought)
// Ulaz u short poziciju: crossunder fastEMA i slowEMA, uz filtriranje da RSI nije preprodavan (više od rsiOversold)
shortCondition = ta.crossunder(fastEMA, slowEMA) and (rsiValue > rsiOversold)
// Definicija dinamičnih stop-loss razina (ATR-based)
stopLossLong = close - (atrMultiplier * atrValue)
stopLossShort = close + (atrMultiplier * atrValue)
// Izvršenje naloga
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("Exit Long", "Long", stop=stopLossLong, limit=close + (takeProfitFactor * atrValue))
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("Exit Short", "Short", stop=stopLossShort, limit=close - (takeProfitFactor * atrValue))
// Plotanje indikatora za preglednost
plot(fastEMA, title="Fast EMA", color=color.green)
plot(slowEMA, title="Slow EMA", color=color.red)