슈퍼 구피 이동 평균 거래 전략

저자:차오장, 날짜: 2023-11-21 14:05:40
태그:

img

전반적인 설명

이 전략의 핵심 아이디어는 비교적 장기적인 방향 트렌드를 발견하기 위해 서로 다른 기간의 여러 이동 평균을 가진 슈퍼 구피 거래 신호를 구축하는 것입니다. 슈퍼 구피는 두 개의 라인 그룹으로 구성됩니다. 빠른 이동 평균과 느린 이동 평균. 빠른 라인은 특정 입구 지점을 결정하며 느린 라인은 전체 거래 방향을 결정합니다. 빠른 라인이 느린 라인을 넘을 때 긴 신호가 생성됩니다. 느린 라인을 넘을 때 짧은 신호가 생성됩니다.

원칙

이 전략은 다양한 기간에 여러 EMA를 사용합니다. 특히:

  • 빠른 라인: 3, 6... 21 회, 총 7 라인
  • 느린 라인: 24, 27...200 회

빠른 라인 크로스오버는 파란색 (상향) 과 오렌지 (하향) 의 색을 띠고 있다. 느린 라인 크로스오버는 녹색 (상향) 과 빨간색 (하향) 의 색을 띠고 있다. 빠른 파란색 라인이 회색에서 느린 녹색 라인으로 전환할 때 긴 신호가 생성되고, 반대로 녹색에서 회색으로 긴 신호가 닫히고, 회색에서 빨간색으로 전환하면 짧은 신호가 생성된다.

이 전략은 또한 두 가지 모드를 제공합니다: 안정적인 모드는 빠른 EMA와 느린 EMA가 방향을 결정 한 후에 거래합니다. 공격적인 모드는 빠른 EMA 방향 변화에 대한 신호를 생성합니다.

장점

이 전략은 더 짧은 시간 프레임에서 거래 기회를 적시에 포착 할 수있는 이중 이동 평균 시스템의 장점을 결합하며 과도한 잘못된 신호를 필터링하기 위해 느린 라인을 사용합니다. 주요 장점은 다음과 같습니다.

  1. 빠른 EMA와 느린 EMA는 협력하여 효과적으로 위험을 관리합니다.
  2. 공격적인 방식은 단기적인 기회를 적시에 잡을 수 있습니다.
  3. 안정적인 모드는 높은 확률과 높은 위험/이익 비율을 제공합니다.
  4. 커스터마이징을 위한 큰 매개 변수 조정 공간

위험성

또한 몇 가지 위험이 있습니다.

  1. 변동성 있는 시장에서는 장기적인 노출이 가능합니다.
  2. 여러 EMA 시스템은 매개 변수 최적화와 테스트에서 더 복잡한 것을 의미합니다.
  3. EMA 지연으로 인해 수익이 안정적으로 희생되었습니다.

위험은 빠른/슬로우 EMA 조합을 조정하거나 스톱 손실을 사용하여 제어 할 수 있습니다.

최적화 방향

이 전략은 몇 가지 측면에서 향상될 수 있습니다.

  1. 변동성 기반의 스톱을 추가하여 엄청난 스파이크 후 손실을 효과적으로 제한합니다.
  2. EMA 매개 변수 최적화를 위한 기계 학습 알고리즘을 테스트하여 매개 변수 효율을 크게 향상시킵니다.
  3. 가격-용량 필터를 추가하여 품질 거래 기회를 증가시킵니다.
  4. 다른 지표와 EMA 크로스를 결합하여 더 높은 정밀도를 탐구하십시오.

결론

슈퍼 구피 전략은 합성적으로 여러 시간 프레임에 걸쳐 요인을 고려하여 위험을 제어하면서 수익성을 향상시킵니다. 다양한 실행 가능한 최적화 경로로 인해 양 트레이더에 대한 추가 연구가 필요합니다.


/*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)



더 많은