Chiến lược giao dịch kết hợp nhiều chỉ số

Tác giả:ChaoZhang, Ngày: 2023-09-13 12:18:05
Tags:

Chiến lược này kết hợp nhiều chỉ số kỹ thuật như đường trung bình động, RSI và Stochastics để đánh giá xu hướng giá và mức mua quá mức / bán quá mức cho các tín hiệu giao dịch.

Chiến lược logic:

  1. Sử dụng nhiều EMA để xác định xu hướng giá tổng thể.

  2. Tính toán RSI và Stochastics cho mức mua quá mức / bán quá mức.

  3. Nhập dài khi EMA đưa ra tín hiệu tăng, RSI không mua quá nhiều và Stoch không mua quá nhiều.

  4. Nhập ngắn khi EMA đưa ra tín hiệu giảm, RSI không bán quá mức và Stoch không bán quá mức.

  5. Ra khỏi khi bất kỳ chỉ báo nào cho tín hiệu ngược lại.

Ưu điểm:

  1. Xác minh nhiều chỉ số cải thiện độ chính xác.

  2. Các chỉ số bổ sung lẫn nhau để đánh giá thị trường tốt hơn.

  3. Các quy tắc giao dịch rõ ràng giúp dễ dàng kiểm tra và thực thi.

Rủi ro:

  1. Tránh sự dư thừa quá mức giữa các chỉ số.

  2. Nối ưu hóa đa chỉ số phức tạp.

  3. Nhiều chỉ số không nhất thiết phải cải thiện hiệu suất.

Tóm lại, phương pháp tiếp cận đa chỉ số có thể cải thiện các quyết định ở một mức độ nào đó nhưng đòi hỏi phải cân bằng khó khăn tối ưu hóa và dư thừa cho các chiến lược đơn giản, đáng tin cậy.


/*backtest
start: 2022-09-06 00:00:00
end: 2023-09-12 00:00:00
period: 3d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
// strategy(title='Combined Strategy', default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=.0020, pyramiding=0, slippage=3, overlay=true)

//----------//
// MOMENTUM //
//----------//
ema8 = ta.ema(close, 5)
ema13 = ta.ema(close, 9)
ema21 = ta.ema(close, 13)
ema34 = ta.ema(close, 21)
ema55 = ta.ema(close, 34)

plot(ema8, color=color.new(color.red, 0), style=plot.style_line, title='5', linewidth=1)
plot(ema13, color=color.new(color.orange, 0), style=plot.style_line, title='9', linewidth=1)
plot(ema21, color=color.new(color.yellow, 0), style=plot.style_line, title='13', linewidth=1)
plot(ema34, color=color.new(color.aqua, 0), style=plot.style_line, title='21', linewidth=1)
plot(ema55, color=color.new(color.lime, 0), style=plot.style_line, title='34', linewidth=1)

longEmaCondition = ema8 > ema13 and ema13 > ema21 and ema21 > ema34 and ema34 > ema55
exitLongEmaCondition = ema13 < ema55

shortEmaCondition = ema8 < ema13 and ema13 < ema21 and ema21 < ema34 and ema34 < ema55
exitShortEmaCondition = ema13 > ema55

// ----------  //
// OSCILLATORS //
// ----------- //
rsi = ta.rsi(close, 14)
longRsiCondition = rsi < 70 and rsi > 40
exitLongRsiCondition = rsi > 70

shortRsiCondition = rsi > 30 and rsi < 60
exitShortRsiCondition = rsi < 30

Stochastic
length = 14, smoothK = 3, smoothD = 3
kFast = ta.stoch(close, high, low, 14)
dSlow = ta.sma(kFast, smoothD)

longStochasticCondition = kFast < 80
exitLongStochasticCondition = kFast > 95

shortStochasticCondition = kFast > 20
exitShortStochasticCondition = kFast < 5

//----------//
// STRATEGY //
//----------//

longCondition = longEmaCondition and longRsiCondition and longStochasticCondition and strategy.position_size == 0
exitLongCondition = (exitLongEmaCondition or exitLongRsiCondition or exitLongStochasticCondition) and strategy.position_size > 0

if (longCondition)
  strategy.entry("LONG", strategy.long)
if (exitLongCondition)
  strategy.close("LONG")

shortCondition = shortEmaCondition and shortRsiCondition and shortStochasticCondition and strategy.position_size == 0
exitShortCondition = (exitShortEmaCondition or exitShortRsiCondition or exitShortStochasticCondition) and strategy.position_size < 0

if (shortCondition)
  strategy.entry("SHORT", strategy.short)
if (exitShortCondition)
  strategy.close("SHORT")



Thêm nữa