Chiến lược đột phá động lực dựa trên phán đoán chu kỳ với đường trung bình động

Tác giả:ChaoZhang, Ngày: 2024-01-23 14:51:27
Tags:

img

Tổng quan

Chiến lược này tính toán các đường EMA của các giai đoạn khác nhau để xác định giai đoạn chu kỳ hiện tại của thị trường và sử dụng ATR để tạo ra các tín hiệu đột phá động lực cho các giao dịch theo xu hướng có khả năng cao.

Chiến lược logic

  1. Đánh giá các đường EMA 3 ngày, 20 ngày và 40 ngày
  2. So sánh các đường EMA để xác định thị trường hiện đang ở giai đoạn nào trong 6 giai đoạn chu kỳ
    • 5 ngày > 20 ngày > 40 ngày là chu kỳ 1
    • 20 ngày > 5 ngày > 40 ngày là chu kỳ 2 ...
  3. Sau khi xác định chu kỳ, tính toán chỉ số ATR và thiết lập số nhân ATR làm tiêu chí đột phá
  4. Một tín hiệu mua được tạo ra khi giá phá vỡ trên điểm dừng ATR của thanh trước
  5. Một tín hiệu bán được tạo ra khi giá giảm xuống dưới điểm dừng ATR của thanh trước
  6. Thông qua sự kết hợp các phán quyết này, có thể đạt được các giao dịch theo xu hướng có khả năng cao

Ưu điểm

  1. Phân tích chu kỳ làm tăng độ tin cậy tín hiệu

    Bằng cách đánh giá các vị trí tương đối của các đường EMA khác nhau, giai đoạn chu kỳ hiện tại của thị trường có thể được xác định hiệu quả, tránh các tín hiệu sai trong các chu kỳ không phù hợp.

  2. ATR breakout lọc tín hiệu sai

    ATR có thể thể hiện hiệu quả sự biến động của thị trường. Đặt số nhân ATR làm tiêu chí đột phá có thể lọc ra nhiều tín hiệu đột phá sai.

  3. Phán quyết kết hợp tạo ra cơ hội giao dịch có khả năng cao

    Sự kết hợp hữu cơ của phán đoán chu kỳ và sự phá vỡ ATR tạo ra các tín hiệu có xác suất cao hơn nhiều, do đó cũng làm tăng lợi nhuận của các giao dịch.

Rủi ro

  1. Tối ưu hóa tham số khó khăn

    Với nhiều tham số, khó khăn tối ưu hóa cao.

  2. Có sự chậm trễ.

    Trong các thị trường thay đổi nhanh chóng, cả EMA và ATR đều có một mức độ chậm trễ nhất định, có thể tạo ra các tín hiệu sai hoặc bỏ lỡ cơ hội.

  3. Cần dừng lỗ nghiêm ngặt

    Không có chỉ số kỹ thuật nào có thể hoàn toàn tránh các tín hiệu sai.

Hướng dẫn tối ưu hóa

  1. Tối ưu hóa tham số thêm

    Tìm kết hợp tham số tối ưu thông qua dữ liệu lịch sử rộng rãi hơn.

  2. Tăng khả năng thích nghi

    Xem xét điều chỉnh tự động các thông số ATR dựa trên sự biến động của thị trường để cải thiện khả năng thích nghi.

  3. Bao gồm các chỉ số khác

    Hãy thử kết hợp các chỉ số khác như biến động và khối lượng để hỗ trợ phán đoán và cải thiện chất lượng tín hiệu.

Kết luận

Chiến lược này xác định chu kỳ với EMA và thiết lập các tiêu chí đột phá đà với ATR để đạt được các giao dịch theo xu hướng có khả năng cao. Nó có những lợi thế như phán đoán chu kỳ, lọc tín hiệu sai và cải thiện chất lượng tín hiệu.


/*backtest
start: 2024-01-15 00:00:00
end: 2024-01-22 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kgynofomo

//@version=5
strategy(title="[Salavi] | Andy Advance Pro Strategy",overlay = true)

ema_short = ta.ema(close,5)
ema_middle = ta.ema(close,20)
ema_long = ta.ema(close,40)

cycle_1 = ema_short>ema_middle and ema_middle>ema_long
cycle_2 = ema_middle>ema_short and ema_short>ema_long
cycle_3 = ema_middle>ema_long and ema_long>ema_short
cycle_4 = ema_long>ema_middle and ema_middle>ema_short
cycle_5 = ema_long>ema_short and ema_short>ema_middle
cycle_6 = ema_short>ema_long and ema_long>ema_middle

bull_cycle = cycle_1 or cycle_2 or cycle_3
bear_cycle = cycle_4 or cycle_5 or cycle_6
// label.new("cycle_1")
// bgcolor(color=cycle_1?color.rgb(82, 255, 148, 60):na)
// bgcolor(color=cycle_2?color.rgb(82, 255, 148, 70):na)
// bgcolor(color=cycle_3?color.rgb(82, 255, 148, 80):na)
// bgcolor(color=cycle_4?color.rgb(255, 82, 82, 80):na)
// bgcolor(color=cycle_5?color.rgb(255, 82, 82, 70):na)
// bgcolor(color=cycle_6?color.rgb(255, 82, 82, 60):na)

// Inputs
a = input(2, title='Key Vaule. \'This changes the sensitivity\'')
c = input(7, title='ATR Period')
h = false

xATR = ta.atr(c)
nLoss = a * xATR

src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : close

xATRTrailingStop = 0.0
iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss
iff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1
xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2

pos = 0
iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3

xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue

ema = ta.ema(src, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)

buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below

barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop




atr = ta.atr(14)
atr_length = input.int(25)
atr_rsi = ta.rsi(atr,atr_length)
atr_valid = atr_rsi>50

long_condition =  buy and bull_cycle and atr_valid
short_condition =  sell and bear_cycle and atr_valid

Exit_long_condition = short_condition
Exit_short_condition = long_condition

if long_condition
    strategy.entry("Andy Buy",strategy.long, limit=close,comment="Andy Buy Here")

if Exit_long_condition
    strategy.close("Andy Buy",comment="Andy Buy Out")
    // strategy.entry("Andy fandan Short",strategy.short, limit=close,comment="Andy 翻單 short Here")
    // strategy.close("Andy fandan Buy",comment="Andy short Out")


if short_condition
    strategy.entry("Andy Short",strategy.short, limit=close,comment="Andy short Here")


// strategy.exit("STR","Long",stop=longstoploss)
if Exit_short_condition
    strategy.close("Andy Short",comment="Andy short Out")
    // strategy.entry("Andy fandan Buy",strategy.long, limit=close,comment="Andy 翻單 Buy Here")
    // strategy.close("Andy fandan Short",comment="Andy Buy Out")




inLongTrade = strategy.position_size > 0
inLongTradecolor = #58D68D
notInTrade = strategy.position_size == 0
inShortTrade = strategy.position_size < 0

// bgcolor(color = inLongTrade?color.rgb(76, 175, 79, 70):inShortTrade?color.rgb(255, 82, 82, 70):na)
plotshape(close!=0,location = location.bottom,color = inLongTrade?color.rgb(76, 175, 79, 70):inShortTrade?color.rgb(255, 82, 82, 70):na)


plotshape(long_condition, title='Buy', text='Andy Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
plotshape(short_condition, title='Sell', text='Andy Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)


//atr > close *0.01* parameter

Thêm nữa