Chiến lược này được gọi là chiến lược theo dõi xu hướng dựa trên sự tích hợp nhiều chỉ số. Chiến lược này tích hợp sử dụng ba chỉ số RSI, ADX và MACD, thực hiện thêm sau khi xác nhận xu hướng tăng và giữ vị trí bằng phẳng sau khi xác nhận xu hướng giảm.
Chỉ số RSI đánh giá tình trạng quá mua quá bán. Đặt 30 trên RSI là kết thúc quá bán, xem xét thêm; Đặt 70 dưới RSI là kết thúc quá mua, xem xét cân bằng.
Chỉ số ADX đánh giá cường độ của xu hướng. Đánh giá giá trị ADX trên 25 có nghĩa là bước vào trạng thái xu hướng, dưới 25 đại diện cho xu hướng kết thúc.
Chỉ số MACD xác định xu hướng ngắn hạn. DIFF trên DEA đại diện cho đường ngắn tăng lên, xem xét nhiều hơn.
Khi các chỉ số RSI, ADX và MACD cho thấy tín hiệu đa đầu cùng một lúc, hãy thực hiện giao dịch đa đầu. Khi ba chỉ số cho thấy xu hướng đa đầu kết thúc, hãy thực hiện giao dịch tháo lỗ.
Ưu điểm của chiến lược này là xác nhận nhiều chỉ số, có thể ngăn chặn hiệu quả các tín hiệu giả. Tuy nhiên, các tham số chỉ số cần được tối ưu hóa riêng lẻ và chiến lược dừng lỗ là không thể thiếu.
Nhìn chung, việc sử dụng các chỉ số tích hợp đã cải thiện hiệu quả phán đoán, nhưng các nhà giao dịch vẫn cần duy trì khả năng phân biệt, điều chỉnh và xác minh các tham số chiến lược theo tình huống thực tế.
/*backtest
start: 2023-09-05 00:00:00
end: 2023-09-08 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// RSI
//@version=3
// strategy("Femi Strategy", overlay=true)
strategy("Femi Strategy", overlay=false)
RSIlength = input( 14 )
overSold = input( 30 )
overBought = input( 70 )
price = close
vrsi = rsi(price, RSIlength)
//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)
// ADX
//@version=3
adxlen = input(14)
dilen = input(14)
adxThreshold = input( 25 )
dirmov(len) =>
up = change(high)
down = -change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = rma(tr, len)
plus = fixnan(100 * rma(plusDM, len) / truerange)
minus = fixnan(100 * rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)
// MACD
//@version=3
MACDZero = input(0)
fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)
MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD
source = close
length = input(20, minval=1)
mult = input(2.0, minval=0.001, maxval=50)
basis = sma(source, length)
dev = mult * stdev(source, length)
upper = basis + dev
lower = basis - dev
if (not na(vrsi))
if (crossover(delta, MACDZero))
strategy.entry("FEMIMACDLE", strategy.long, comment="FEMIMACDLE")
else
strategy.cancel(id="FEMIMACDLE")
if (crossunder(vrsi, overSold))
strategy.entry("FEMIRSILE", strategy.long, comment="FEMIRSILE")
else
strategy.cancel(id="FEMIRSILE")
// if(crossover(sig, adxThreshold)) // crossover(sig, adxThreshold) crossover(delta, MACDZero) crossunder(vrsi, overSold)
// strategy.entry("FEMIADXLE", strategy.long, comment="FEMIADXLE")
// else
// strategy.cancel(id="FEMIADXLE")
// if (crossover(source, lower))
// strategy.entry("FEMIBBLE", strategy.long, comment="FEMIBBLE")
// else
// strategy.cancel(id="FEMIBBLE")
// if(crossunder(sig, adxThreshold))
// strategy.cancel(id="FEMILE")
// strategy.exit(id="FEMILE")
// if (crossunder(delta, MACDZero))
// strategy.entry("FEMIMACDSE", strategy.short, comment="FEMIMACDSE")
if (crossover(vrsi, overBought))
// strategy.entry("FEMIRSISE", strategy.short, comment="FEMIRSISE")
strategy.close("FEMIRSILE")
strategy.close("FEMIMACDLE")
strategy.close("FEMIADXLE")
strategy.close("FEMIBBLE")
if (crossunder(sig, adxThreshold) and crossunder(delta, MACDZero) and crossunder(source, upper)) // crossover(delta, MACDZero) crossover(vrsi, overSold) crossover(sig, adxThreshold)
strategy.close("FEMIRSILE")
strategy.close("FEMIMACDLE")
strategy.close("FEMIADXLE")
strategy.close("FEMIBBLE")
// if(crossunder(source, upper))
// strategy.close("FEMIRSILE")
// strategy.close("FEMIMACDLE")
// strategy.close("FEMIADXLE")
// strategy.close("FEMIBBLE")
// strategy.entry("FEMIADXSE", strategy.short, comment="FEMIADXSE")
// else
// strategy.cancel(id="FEMISE")
// plot(sig, color=red, title="ADX", linewidth=2, style=areabr)
// plot(adxThreshold, color=blue, title="ADX")
// plot(vrsi, color=green, title="RSI", linewidth=2, style=areabr)
// plot(overSold, color=blue, title="RSI")
// plot(overBought, color=red, title="RSI")
// plot(delta, color=green, title="MACD", linewidth=2, style=areabr)
// plot(MACDZero, color=blue, title="MACD")
// plot(overBought, color=red, title="MACD")
//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)