Chiến lược giao dịch đường trung bình động tam giác ngược Super Goose


Ngày tạo: 2023-11-21 14:05:40 sửa đổi lần cuối: 2023-11-21 14:05:40
sao chép: 0 Số nhấp chuột: 1030
1
tập trung vào
1617
Người theo dõi

Chiến lược giao dịch đường trung bình động tam giác ngược Super Goose

Tổng quan

Ý tưởng chính của chiến lược này là sử dụng các đường trung bình di chuyển của nhiều chu kỳ khác nhau để xây dựng các tín hiệu giao dịch siêu chu kỳ để phát hiện xu hướng theo chiều hướng có chu kỳ tương đối dài. Chu kỳ siêu chu kỳ bao gồm hai nhóm đường trung bình di chuyển nhanh và đường trung bình di chuyển chậm, đường nhanh quyết định vị trí nhập cảnh cụ thể và đường chậm quyết định hướng giao dịch tổng thể.

Nguyên tắc

Chiến lược này sử dụng đường trung bình EMA của nhiều giai đoạn khác nhau, cụ thể là:

  • Dòng nhanh: 3 chu kỳ, 6 chu kỳ… 21 chu kỳ 7 đường
  • Dòng chậm: 24 chu kỳ, 27 chu kỳ… 200 chu kỳ

Đường nhanh được phân chia thành màu xanh (lên) và màu cam (xuống) khi giao nhau, đường chậm được phân chia thành màu xanh (lên) và màu đỏ (xuống) khi giao nhau. Đường nhanh tạo ra tín hiệu đa đầu khi đường xanh chuyển từ màu xám sang đường chậm màu xanh, ngược lại tạo ra tín hiệu đa đầu khi chuyển từ màu xanh lá cây sang màu xám; khi chuyển từ màu xám sang màu đỏ, tạo ra tín hiệu đầu trống.

Chiến lược này cung cấp hai chế độ đồng thời: chế độ ổn định chỉ giao dịch sau khi EMA nhanh hoặc chậm xác định hướng; chế độ tích cực, bất kỳ EMA nhanh nào thay đổi hướng sẽ tạo ra tín hiệu.

Ưu điểm

Chiến lược này kết hợp lợi thế của hệ thống đường trung bình kép, có thể bắt kịp các cơ hội giao dịch trong chu kỳ đường ngắn hơn và có thể sử dụng đường tốc độ chậm để lọc các tín hiệu giả quá nhiều. Các lợi thế cụ thể là:

  1. Các đường dây EMA nhanh và chậm có thể kiểm soát rủi ro hiệu quả.
  2. Mô hình chủ động có thể bắt kịp các cơ hội ngắn hạn.
  3. Mô hình ổn định có thể cung cấp cơ hội có tỷ lệ rủi ro cao và tỷ lệ thua lỗ cao.
  4. Có rất nhiều không gian để tối ưu các tham số thủ công.

Rủi ro

Chiến lược này cũng có một số rủi ro:

  1. Trong một thời gian chấn động lớn, có thể có nhiều thời gian tiếp xúc trong thị trường.
  2. Hệ thống đa nhóm đồng tuyến, tối ưu hóa tham số và thử nghiệm khó hơn.
  3. Trong chế độ ổn định, một phần lợi nhuận sẽ do tính chất chậm trễ của đường EMA nhanh.

Bạn có thể kiểm soát rủi ro bằng cách điều chỉnh phù hợp các tham số EMA tốc độ nhanh hoặc chậm hoặc thiết lập dừng lỗ.

Hướng tối ưu hóa

Chiến lược này có thể được tối ưu hóa theo các khía cạnh sau:

  1. Tăng mức dừng dựa trên tỷ lệ biến động. Như vậy có thể kiểm soát hiệu quả thiệt hại do động đất lớn.
  2. Cố gắng tối ưu hóa tham số EMA bằng thuật toán học máy. Điều này có thể cải thiện hiệu quả sử dụng tham số.
  3. Tăng bộ lọc danh mục giá cả. Điều này có thể làm tăng cơ hội giao dịch thực tế.
  4. Khám phá các chỉ số khác để kết hợp với EMA. Điều này có thể làm tăng thêm độ chính xác giao dịch.

Tóm tắt

Phương pháp tổng hợp siêu tròn này xem xét nhiều yếu tố chu kỳ thời gian, trong khi kiểm soát rủi ro, tăng cơ hội lợi nhuận. Nó có thể được tối ưu hóa bằng nhiều cách, đáng để các nhà giao dịch định lượng nghiên cứu sâu hơn.

Mã nguồn chiến lược
/*backtest
start: 2023-11-13 00:00:00
end: 2023-11-20 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/


// A strategized version Daryl Guppy Super EMA's with additional options
// by default "early signals" is enabled, which will trade any green/gray or red/gray transitions of the guppy.  Disable to only take longs while green, and shorts while red.
//@version=4

strategy(title="Super Guppy Strategy", shorttitle="Super Guppy Strat", overlay = true, 
  initial_capital=100000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type="percent", commission_value=0.0)

useShorts       = input(true, "Test w/Shorts?")
useEarlySignals = input(true, "Use Early Signals?")
show200Ema      = input(false, "Show 200 EMA?")
daysBackMax     = input(defval = 100000, title = "Max Days Back to Test", minval = 0)
daysBackMin     = input(defval = 0, title = "Min Days Back to Test", minval = 0)
msBackMax       = 1000 * 60 * 60 * 24 * daysBackMax
msBackMin       = 1000 * 60 * 60 * 24 * daysBackMin


src = close, 
len1 = input(3, minval=1, title="Fast EMA 1")
len2 = input(6, minval=1, title="Fast EMA 2")
len3 = input(9, minval=1, title="Fast EMA 3")
len4 = input(12, minval=1, title="Fast EMA 4")
len5 = input(15, minval=1, title="Fast EMA 5")
len6 = input(18, minval=1, title="Fast EMA 6")
len7 = input(21, minval=1, title="Fast EMA 7")
//Slow EMA
len8 = input(24, minval=1, title="Slow EMA 8")
len9 = input(27, minval=1, title="Slow EMA 9")
len10 = input(30, minval=1, title="Slow EMA 10")
len11 = input(33, minval=1, title="Slow EMA 11")
len12 = input(36, minval=1, title="Slow EMA 12")
len13 = input(39, minval=1, title="Slow EMA 13")
len14 = input(42, minval=1, title="Slow EMA 14")
len15 = input(45, minval=1, title="Slow EMA 15")
len16 = input(48, minval=1, title="Slow EMA 16")
len17 = input(51, minval=1, title="Slow EMA 17")
len18 = input(54, minval=1, title="Slow EMA 18")
len19 = input(57, minval=1, title="Slow EMA 19")
len20 = input(60, minval=1, title="Slow EMA 20")
len21 = input(63, minval=1, title="Slow EMA 21")
len22 = input(66, minval=1, title="Slow EMA 22")
len23 = input(200, minval=1, title="EMA 200")

//Fast EMA
ema1 = ema(src, len1)
ema2 = ema(src, len2)
ema3 = ema(src, len3)
ema4 = ema(src, len4)
ema5 = ema(src, len5)
ema6 = ema(src, len6)
ema7 = ema(src, len7)

//Slow EMA
ema8 = ema(src, len8)
ema9 = ema(src, len9)
ema10 = ema(src, len10)
ema11 = ema(src, len11)
ema12 = ema(src, len12)
ema13 = ema(src, len13)
ema14 = ema(src, len14)
ema15 = ema(src, len15)
ema16 = ema(src, len16)
ema17 = ema(src, len17)
ema18 = ema(src, len18)
ema19 = ema(src, len19)
ema20 = ema(src, len20)
ema21 = ema(src, len21)
ema22 = ema(src, len22)

//EMA 200
ema23 = ema(src, len23)

//Fast EMA Color Rules
colfastL = (ema1 > ema2 and ema2 > ema3 and ema3 > ema4 and ema4 > ema5 and ema5 > ema6 and ema6 > ema7)
colfastS = (ema1 < ema2 and ema2 < ema3 and ema3 < ema4 and ema4 < ema5 and ema5 < ema6 and ema6 < ema7)
//Slow EMA Color Rules
colslowL = ema8 > ema9 and ema9 > ema10 and ema10 > ema11 and ema11 > ema12 and ema12 > ema13 and ema13 > ema14 and ema14 > ema15 and ema15 > ema16 and ema16 > ema17 and ema17 > ema18 and ema18 > ema19 and ema19 > ema20 and ema20 > ema21 and ema21 > ema22
colslowS = ema8 < ema9 and ema9 < ema10 and ema10 < ema11 and ema11 < ema12 and ema12 < ema13 and ema13 < ema14 and ema14 < ema15 and ema15 < ema16 and ema16 < ema17 and ema17 < ema18 and ema18 < ema19 and ema19 < ema20 and ema20 < ema21 and ema21 < ema22 
//Fast EMA Final Color Rules
colFinal = colfastL and colslowL? color.aqua : colfastS and colslowS? color.orange : color.gray
//Slow EMA Final Color Rules
colFinal2 = colslowL  ? color.lime : colslowS ? color.red : color.gray 
// iff colSlowL then lime, otherwise is colSlowS, then red, otherwise gray

// open long:  grey to green
// close long:  green to grey
// open short: grey to red
// close short: red to grey


//Fast EMA Plots
p1=plot(ema1, linewidth=2, color=colFinal)
plot(ema2, linewidth=1, color=colFinal)
plot(ema3, linewidth=1, color=colFinal)
plot(ema4, linewidth=1, color=colFinal)
plot(ema5, linewidth=1, color=colFinal)
plot(ema6, linewidth=1, color=colFinal)
p2=plot(ema7, linewidth=2, color=colFinal)

//Slow EMA Plots
p3=plot(ema8, linewidth=1, color=colFinal2)
plot(ema9, linewidth=1, color=colFinal2)
plot(ema10,linewidth=1, color=colFinal2)
plot(ema11,linewidth=1, color=colFinal2)
plot(ema12,linewidth=1, color=colFinal2)
plot(ema13,linewidth=1, color=colFinal2)
plot(ema14,linewidth=1, color=colFinal2)
plot(ema15,linewidth=1, color=colFinal2)
plot(ema16,linewidth=1, color=colFinal2)
plot(ema17,linewidth=1, color=colFinal2)
plot(ema18,linewidth=1, color=colFinal2)
plot(ema19,linewidth=1, color=colFinal2)
plot(ema20,linewidth=1, color=colFinal2)
plot(ema21,linewidth=1, color=colFinal2)
plot(ema22,linewidth=2, color=colFinal2)
p4=plot(show200Ema==true ? ema23 : na, linewidth=2)

var isLong = false
var isShort = false

long = not isLong and ((colFinal2 == color.lime and colFinal2[1] == color.gray) or (colFinal2 == color.gray and colFinal2[1] == color.red))
short = not isShort and ((colFinal2 == color.gray and colFinal2[1] == color.lime) or (colFinal2 == color.red and colFinal2[1] == color.gray))

if long
    isLong := true
    isShort := false

if short
    isLong := false
    isShort := true

openLong = colFinal2 == color.lime and colFinal2[1] == color.gray
closeLong = colFinal2 == color.gray and colFinal2[1] == color.lime
openShort = colFinal2 == color.red and colFinal2[1] == color.gray
closeShort = colFinal2 == color.gray and colFinal2[1] == color.red


// default - no early signals
plotshape(openLong and not useEarlySignals, title="open long", text="open long", style=shape.labelup, location=location.belowbar, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
plotshape(closeLong and not useEarlySignals, title="close long", text="close long", style=shape.labeldown, location=location.abovebar, size=size.tiny, color=color.gray, textcolor=color.white, transp=0)
plotshape(openShort and useShorts and not useEarlySignals, title="open short", text="open short", style=shape.labelup, location=location.belowbar, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
plotshape(closeShort and useShorts and not useEarlySignals, title="close short", text="close short", style=shape.labeldown, location=location.abovebar, size=size.tiny, color=color.black, textcolor=color.white, transp=0)

// with early signals
plotshape(long and useEarlySignals, title="long", text="long", style=shape.labelup, location=location.belowbar, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
plotshape(short and useEarlySignals and useShorts, title="short", text="short", style=shape.labeldown, location=location.abovebar, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
plotshape(short and useEarlySignals and not useShorts, title="close long", text="close long", style=shape.labeldown, location=location.abovebar, size=size.tiny, color=color.red, textcolor=color.white, transp=0)




isWithinTimeBounds = (msBackMax == 0 or (time > (timenow - msBackMax))) and (msBackMin == 0 or (time < (timenow - msBackMin)))
strategy.entry("LONG", long=true, when=openLong and isWithinTimeBounds and not useEarlySignals)
strategy.close("LONG", when=closeLong and isWithinTimeBounds and not useEarlySignals)
strategy.entry("short", long=false, when=openShort and useShorts and isWithinTimeBounds and not useEarlySignals)
strategy.close("short", when=closeShort and useShorts and isWithinTimeBounds and not useEarlySignals)

strategy.entry("LONG", long=true, when=long and isWithinTimeBounds and useEarlySignals)
strategy.close("LONG", when=short and isWithinTimeBounds and useEarlySignals)
strategy.entry("short", long=false, when=short and useShorts and isWithinTimeBounds and useEarlySignals)
strategy.close("short", when=long and useShorts and isWithinTimeBounds and not useEarlySignals)