
Chiến lược này sử dụng hai đường trung bình di chuyển (trung bình di chuyển nhanh và trung bình di chuyển chậm) và chỉ số tương đối mạnh (RSI) để xác định xu hướng ngắn hạn và tình trạng mua bán quá mức của thị trường. Chiến lược mở vị trí đầu nhiều khi đường trung bình di chuyển nhanh đi từ dưới lên xuyên qua đường trung bình di chuyển chậm và RSI thấp hơn mức mua bán quá mức; và vị trí đầu trống khi đường trung bình di chuyển nhanh đi từ trên xuống xuyên qua đường trung bình di chuyển chậm và RSI cao hơn mức mua quá mức.
Chiến lược này được sử dụng để nắm bắt xu hướng giá trong ngắn hạn bằng cách kết hợp các chỉ số đường trung bình và RSI. Chiến lược này có logic rõ ràng, các tham số linh hoạt, dễ thực hiện và tối ưu hóa. Tuy nhiên, có thể tạo ra quá nhiều tín hiệu giao dịch trong thị trường bất ổn và khả năng nắm bắt xu hướng dài hạn yếu hơn. Do đó, trong ứng dụng thực tế, có thể xem xét việc giới thiệu các chỉ số khác, lựa chọn tham số tối ưu hóa và thêm các biện pháp quản lý rủi ro để tăng cường sự ổn định và lợi nhuận của chiến lược.
/*backtest
start: 2024-03-24 00:00:00
end: 2024-03-25 05:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Short-Term Scalp Trading Strategy", overlay=true)
// Define strategy parameters
fastMA_length = input(5, title="Fast MA Length")
slowMA_length = input(10, title="Slow MA Length")
rsi_length = input(7, title="RSI Length")
rsi_oversold = input(20, title="RSI Oversold Level")
rsi_overbought = input(80, title="RSI Overbought Level")
// Calculate Moving Averages
fastMA = ta.sma(close, fastMA_length)
slowMA = ta.sma(close, slowMA_length)
// Calculate RSI
rsi = ta.rsi(close, rsi_length)
// Define entry conditions
longCondition = ta.crossunder(fastMA, slowMA) and rsi < rsi_oversold
shortCondition = ta.crossover(fastMA, slowMA) and rsi > rsi_overbought
// Enter long position
strategy.entry("Long", strategy.long, when=longCondition)
// Enter short position
strategy.entry("Short", strategy.short, when=shortCondition)
// Define exit conditions
longExitCondition = ta.crossunder(fastMA, slowMA) or ta.crossover(rsi, rsi_overbought)
shortExitCondition = ta.crossover(fastMA, slowMA) or ta.crossunder(rsi, rsi_oversold)
// Exit long position
if (longExitCondition)
strategy.close("Exit Long", "Long")
// Exit short position
if (shortExitCondition)
strategy.close("Exit Short", "Short")
// Plot buy and sell signals
plotshape(series=longCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(series=shortCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)