
Chiến lược này là một hệ thống giao dịch theo dõi xu hướng dựa trên nhiều chỉ số kỹ thuật, tích hợp nhiều chỉ số kỹ thuật như đường trung bình di chuyển (MA), đường trung bình tương đối mạnh (RSI), đường Brin (BB), đường trung bình di chuyển (MACD) và đường ngẫu nhiên (Stochastic) để xác định xu hướng thị trường và cơ hội giao dịch thông qua xác nhận chéo giữa các chỉ số. Chiến lược này sử dụng phương pháp quản lý vị trí phần trăm, sử dụng tiền mặc định 1% cho mỗi giao dịch.
Các chiến lược xác định tín hiệu giao dịch thông qua các chiều sau:
Một số điều kiện cần được đáp ứng:
Điều kiện làm không cần phải đáp ứng:
Chiến lược này tạo ra một hệ thống giao dịch theo dõi xu hướng tương đối hoàn chỉnh thông qua việc sử dụng tổng hợp nhiều chỉ số kỹ thuật. Chiến lược có tín hiệu đáng tin cậy, rủi ro có thể kiểm soát được, nhưng vẫn cần phải tối ưu hóa các tham số và logic liên tục theo tình hình thị trường trong môi trường thực. Bằng cách cải tiến và hoàn thiện liên tục, chiến lược này có thể đạt được lợi nhuận ổn định trong các môi trường thị trường khác nhau.
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"TRB_USDT"}]
*/
//@version=5
strategy("TradingBot Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=1)
// Input parameters
lotSize = input.float(0.1, title="Lot Size")
maPeriod = input.int(14, title="MA Period")
rsiPeriod = input.int(14, title="RSI Period")
bbPeriod = input.int(20, title="Bollinger Bands Period")
macdFast = input.int(12, title="MACD Fast EMA")
macdSlow = input.int(26, title="MACD Slow EMA")
macdSignal = input.int(9, title="MACD Signal SMA")
stochK = input.int(14, title="Stochastic %K")
stochD = input.int(3, title="Stochastic %D")
// Indicators
ma = ta.sma(close, maPeriod)
rsi = ta.rsi(close, rsiPeriod)
[bbUpper, bbMiddle, bbLower] = ta.bb(close, bbPeriod, 2)
[macdLine, signalLine, _] = ta.macd(close, macdFast, macdSlow, macdSignal)
k = ta.stoch(close, high, low, stochK)
d = ta.sma(k, stochD)
// Plot indicators
plot(ma, color=color.blue, title="MA", linewidth=1)
hline(70, "RSI Overbought", color=color.red)
hline(30, "RSI Oversold", color=color.green)
plot(rsi, color=color.purple, title="RSI", linewidth=1)
plot(bbUpper, color=color.orange, title="Bollinger Bands Upper", linewidth=1)
plot(bbMiddle, color=color.gray, title="Bollinger Bands Middle", linewidth=1)
plot(bbLower, color=color.orange, title="Bollinger Bands Lower", linewidth=1)
hline(0, "MACD Zero", color=color.gray)
plot(macdLine, color=color.blue, title="MACD Line", linewidth=1)
plot(signalLine, color=color.red, title="MACD Signal Line", linewidth=1)
hline(80, "Stochastic Overbought", color=color.red)
hline(20, "Stochastic Oversold", color=color.green)
plot(k, color=color.blue, title="Stochastic %K", linewidth=1)
plot(d, color=color.red, title="Stochastic %D", linewidth=1)
// Trading logic
longCondition = rsi < 30 and macdLine > signalLine and k < 20 and close > bbMiddle and close[1] < bbLower
shortCondition = rsi > 70 and macdLine < signalLine and k > 80 and close < bbMiddle and close[1] > bbUpper
if (longCondition)
strategy.entry("Buy", strategy.long, qty=lotSize)
label.new(bar_index, low, text="BUY", style=label.style_label_up, color=color.green, textcolor=color.white, size=size.small, yloc=yloc.belowbar)
if (shortCondition)
strategy.entry("Sell", strategy.short, qty=lotSize)
label.new(bar_index, high, text="SELL", style=label.style_label_down, color=color.red, textcolor=color.white, size=size.small, yloc=yloc.abovebar)