Chiến lược giao dịch kết hợp ADX,RSI,SMA đa chỉ số

Tác giả:ChaoZhang, Ngày: 2023-09-14 16:19:46
Tags:

Chiến lược logic

Chiến lược này kết hợp các chỉ số kỹ thuật khác nhau để xác định hướng xu hướng và mức mua quá mức / bán quá mức cho tín hiệu giao dịch.

Các chỉ số chính được sử dụng là:

  1. Chỉ số hướng trung bình (ADX): Sức mạnh xu hướng

  2. Chỉ số sức mạnh tương đối (RSI): Mua quá mức / bán quá mức

  3. Trung bình di chuyển đơn giản (SMA): Xu hướng ngắn hạn

  4. SuperTrend: Xu hướng dài hạn/nhanh hạn

  5. Channel Breakout: Xu hướng đột phá vào

Logic giao dịch là:

  1. ADX cho thấy sự hiện diện và sức mạnh của xu hướng

  2. SuperTrend xác nhận sự liên kết giữa xu hướng dài hạn và ngắn hạn

  3. RSI xác định các khu vực mua quá mức / bán quá mức

  4. Nhập trên SMA crossover

  5. Nhập vào kênh breakout

Sự kết hợp nhiều chỉ số cải thiện độ chính xác tín hiệu. Các chiến lược khác nhau kết hợp thành một cách tiếp cận có hệ thống.

Ưu điểm

  • Nhiều chỉ số cải thiện chất lượng

  • Các chiến lược kết hợp để có sự tham gia có hệ thống

  • ADX xác định xu hướng, chỉ số RSI mua quá mức / bán quá mức

  • SuperTrend nắm bắt xu hướng, SMA & kênh đột phá nhập

Rủi ro

  • Điều chỉnh đa tham số đòi hỏi tối ưu hóa

  • Các tình trạng kết hợp xảy ra ít hơn

  • Các tín hiệu chỉ số mâu thuẫn khó giải quyết

Tóm lại

Chiến lược này sử dụng đầy đủ các điểm mạnh của các chỉ số khác nhau để xây dựng một hệ thống mạnh mẽ. Nhưng tối ưu hóa tham số là chìa khóa cho tần suất giao dịch lý tưởng. Nhìn chung, nó kết hợp nhận dạng xu hướng mạnh mẽ với các mục nhập hiệu quả.


/*backtest
start: 2023-09-12 00:00:00
end: 2023-09-13 00:00:00
period: 45m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
// strategy("Combined Strategy", overlay=true, default_qty_value=100, initial_capital=1000, margin_long=0.1)

adxlen = input(7, title="ADX Smoothing")
dilen = input(7, title="DI Length")
dirmov(len) =>
    up = ta.change(high)
    down = -ta.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 = ta.rma(ta.tr, len)
    plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
    minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
    [plus, minus]

adx(dilen, adxlen) =>
    [plus, minus] = dirmov(dilen)
    sum = plus + minus
    adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)

// The same on Pine Script™
pine_supertrend(factor, atrPeriod) =>
    src = hl2
    atr = ta.atr(atrPeriod)
    upperBand = src + factor * atr
    lowerBand = src - factor * atr
    prevLowerBand = nz(lowerBand[1])
    prevUpperBand = nz(upperBand[1])

    lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ? lowerBand : prevLowerBand
    upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ? upperBand : prevUpperBand
    int direction = na
    float superTrend = na
    prevSuperTrend = superTrend[1]
    if na(atr[1]) and ta.rsi(close, 21) < 66 and ta.rsi(close,3) > 80 and ta.rsi(close, 28) > 49 and sig > 20
        direction := 1
    else if prevSuperTrend == prevUpperBand
        direction := close > upperBand ? -1 : 1
    else
        direction := close < lowerBand ? 1 : -1
    superTrend := direction == -1 ? lowerBand : upperBand
    [superTrend, direction]

[pineSupertrend, pineDirection] = pine_supertrend(3, 10)
upTrend = pineDirection < 0
downTrend = pineDirection > 0

// Define the 20-period SMA
sma20 = ta.sma(close, 20)

a = ta.rsi(close,14)
OB = input(70)
OS = input(30)
os = a > OB
ob = a < OS

if upTrend and close > pineSupertrend and close > sma20 and os
    strategy.entry("Buy", strategy.long)

if ta.crossunder(close, sma20) or ob
    strategy.close_all()

//define when to breakout of channel 
//("ChannelBreakOutStrategy", overlay=true)
length = input.int(title="Length", minval=1, maxval=1000, defval=5)
upBound = ta.highest(high, length)
downBound = ta.lowest(low, length)
if (not na(close[length]))
	strategy.entry("ChBrkLE", strategy.long, stop=upBound + syminfo.mintick, comment="ChBrkLE")
strategy.entry("ChBrkSE", strategy.short, stop=downBound - syminfo.mintick, comment="ChBrkSE")


Thêm nữa