Chiến lược này kết hợp MACD (Moving Average Convergence deviation), RSI (Relative Strength Index) và SMA (Simple Moving Average) để tạo ra tín hiệu mua bán đáng tin cậy. MACD được sử dụng để nắm bắt sự thay đổi động lực của giá, RSI được sử dụng để xác định tình trạng quá mua và quá bán, và SMA được sử dụng để xác định hướng xu hướng. Chiến lược này được lọc qua nhiều điều kiện để giảm tín hiệu giả tạo, cung cấp điểm vào rõ ràng cho giao dịch trong ngày.
Các điều kiện nhập cảnh và xuất cảnh của chiến lược này như sau:
Chiến lược này kết hợp các chỉ số kỹ thuật như MACD, RSI và SMA để tạo thành một chiến lược giao dịch trong ngày được lọc nhiều lần. Nó sử dụng động lực và thay đổi xu hướng để nắm bắt cơ hội giao dịch, đồng thời kiểm soát rủi ro thông qua các quy tắc nhập cảnh và xuất cảnh rõ ràng. Mặc dù chiến lược này có thể gặp thách thức trong thị trường bất ổn, nhưng với việc tối ưu hóa và quản lý rủi ro hơn nữa, nó có khả năng trở thành một công cụ giao dịch trong ngày đáng tin cậy.
/*backtest
start: 2024-05-07 00:00:00
end: 2024-06-06 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Day Trading Strategy", overlay=true)
// Parametrii pentru MACD
macdLength = input.int(12, title="MACD Length")
signalSmoothing = input.int(9, title="MACD Signal Smoothing")
src = input(close, title="Source")
// Calculul MACD
[macdLine, signalLine, _] = ta.macd(src, macdLength, 26, signalSmoothing)
macdHist = macdLine - signalLine
// Parametrii pentru RSI
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
// Calculul RSI
rsi = ta.rsi(src, rsiLength)
// Filtru suplimentar pentru a reduce semnalele false
longFilter = ta.sma(close, 50) > ta.sma(close, 200)
shortFilter = ta.sma(close, 50) < ta.sma(close, 200)
// Conditii de intrare in pozitie long
enterLong = ta.crossover(macdLine, signalLine) and rsi < rsiOverbought and longFilter
// Conditii de iesire din pozitie long
exitLong = ta.crossunder(macdLine, signalLine) or rsi > rsiOverbought
// Conditii de intrare in pozitie short
enterShort = ta.crossunder(macdLine, signalLine) and rsi > rsiOversold and shortFilter
// Conditii de iesire din pozitie short
exitShort = ta.crossover(macdLine, signalLine) or rsi < rsiOversold
// Adaugarea strategiei pentru Strategy Tester
if (enterLong)
strategy.entry("BUY", strategy.long)
if (exitLong)
strategy.close("BUY")
if (enterShort)
strategy.entry("SELL", strategy.short)
if (exitShort)
strategy.close("SELL")
// Plotarea MACD si Signal Line
plot(macdLine, color=color.blue, title="MACD Line")
plot(signalLine, color=color.orange, title="Signal Line")
hline(0, "Zero Line", color=color.gray)
plot(macdHist, color=color.red, style=plot.style_histogram, title="MACD Histogram")