느린 이동 평균 전략

저자:차오장, 날짜: 2023-12-07 15:21:45
태그:

img

전반적인 설명

이 전략은 주요 거래 신호로 24주기 돈치안 채널과 200주기 이동 평균을 결합하여 사용한다. 가격이 하향 변동할 때 단위 포지션과 상승할 때 긴 포지션이 열린다.

전략 논리

전략 논리는 주로 다음과 같은 점에 기초합니다.

  1. 돈치안 채널은 지난 24 기간 동안 가장 높은 최고와 가장 낮은 최저를 사용하여 구성됩니다. 가격이 이 채널을 벗어날 때 더 큰 상승 또는 하락의 가능성을 나타냅니다.

  2. 200주기 이동 평균은 긴/단편 편향을 필터로 작용합니다. 가격이 돈치 채널을 깨고 이동 평균의 반대편에 있다면 반전이 발생할 수 있습니다.

  3. 진입 신호는 다음과 같습니다.

  • 짧은: 이전 바의 폐쇄는 돈치안 채널의 상단단 위에 있으며 200주기 MA 아래에 있습니다. 현재 바의 개방은 이전 폐쇄 아래에 있으며 낮은 200-MA 아래에 있습니다.
  • 긴: 이전 바의 폐쇄는 돈치안 채널의 하위 밴드 아래에 있으며 200-주기 MA보다 높습니다. 현재 바의 개방은 이전 폐쇄보다 높으며 최고는 200-MA보다 높습니다.
  1. 짧은 포지션의 스톱 손실은 지난 3 바에서 가장 높은 수준으로 설정됩니다. 이윤을 취하는 것은 입상 가격 마이너스 3 배의 스톱 손실과 입상 가격의 차이로 설정됩니다. 긴 포지션의 스톱 손실과 이윤을 취하는 논리는 반대입니다.

  2. 이 전략의 장점은 돈치안 채널과 이동 평균 필터를 결합함으로써 하나의 지표에 의존하는 잘못된 신호를 방지하여 승률을 크게 향상시키는 것입니다.

이점 분석

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 높은 승률: 돈치안 채널과 이동 평균 필터를 결합함으로써 단일 지표의 잘못된 신호로 인한 불필요한 손실이 피됩니다.

  2. 통제 가능한 위험: 최근 최고 최고 / 최저 최저를 중지 손실 수준으로 사용하면 손실 거래의 하락을 효과적으로 관리합니다. 3: 1 이익 / 손실 비율은 매력적입니다.

  3. 간단하고 쉽게 구현: 논리는 이해하기 쉽고 실행하기 쉬운 간단하고 직관적인 지표를 사용합니다.

  4. 시장과 기간에 걸쳐 안정성: 상대적으로 적은 매개 변수로 전략은 다른 제품과 기간에 걸쳐 안정적입니다.

위험 분석

이 전략에 직면한 주요 위험은 다음과 같습니다.

  1. 극심한 시장 움직임: 매우 강한 일방적 추세는 손실을 증폭시키는 중지 손실을 유발할 수 있습니다. 이것은 중지 확장이거나 위치 크기를 줄임으로써 완화 될 수 있습니다.

  2. 조기 출구 신호 위험: 새로운 반대 신호에서 출구는 반복적인 출입과 출입으로 인해 불안정한 시장에서 과도한 거래를 유발할 수 있습니다. 출구 논리를 최적화하는 것이 이를 해결하는 데 도움이 될 수 있습니다.

  3. 매개 변수 최적화 위험: 돈치안 채널 룩백 기간 또는 이동 평균의 매개 변수 조정이 좋지 않으면 지연되거나 빈번한 신호가 발생할 수 있습니다. 엄격한 최적화와 조합 테스트를 통해 최소화 할 수 있습니다.

더 나은 기회

이 전략은 다음과 같은 방법으로 강화될 수 있습니다.

  1. Donchian 채널을 최적화하고 매개 변수를 가장 잘 조합할 수 있는 이동 평균 룩백 기간을 찾습니다.

  2. 다른 스톱 로스를 테스트하여 수익 비율을 취하여 이윤 비율과 보상/위험을 균형 잡습니다.

  3. 입시 신호에 MACD, RSI 등과 같은 지표를 사용하여 추가 필터를 통합하여 안정성을 향상시킵니다.

  4. 불안정한 시장에서 불필요한 출구를 피하기 위해 출구 논리를 최적화하십시오. 트렌드 메트릭도 출구에 고려 될 수 있습니다.

  5. 이 전략 프레임워크를 사용하여 새로운 조합을 개발하십시오. 예를 들어 다른 채널, 대역 지표 등과 함께.

결론

느린 이동 평균 전략은 신호 발생을 위해 돈치안 채널과 이동 평균의 조합을 사용하여 명확하고 이해하기 쉬운 논리를 가지고 있습니다. 이 하이브리드 접근 방식은 안정성과 승률을 크게 향상시킵니다. 3: 1 이익과 손실 비율은 또한 좋은 보상 잠재력을 제공합니다. 극단적인 움직임과 신호 오류의 측면에서 위험이 있지만 수많은 최적화 기회가 성능을 향상시키고 핵심 전략을 확장 할 수 있습니다.


/*backtest
start: 2023-11-06 00:00:00
end: 2023-12-06 00:00:00
period: 1h
basePeriod: 15m
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/
// © Mysteriown

//@version=4

strategy("Lagged Donchian Channel + EMA", overlay = true)

//tradePeriod = time(timeframe.period,"0000-0000:1234567")?true:false


// ------------------------------------------ //
// ----------------- Inputs ----------------- //
// ------------------------------------------ //

period = input(24, title="Channel's periods")
Pema = input(200, title="EMA's periods ?")
ratio = input(3, title="Ratio TP", type=input.float)
loss = input(20, title="Risk Loss ($)")
lev = input(5, title="Leverage *...")
chan = input(title="Plot channel ?", type=input.bool, defval=false)
Bpos = input(title="Plot Bull positions ?", type=input.bool, defval=false)
bpos = input(title="Plot Bear positions ?", type=input.bool, defval=false)
labels = input(title="Plot labels of bets ?", type=input.bool, defval=true)
supp = input(title="Delete last labels ?", type=input.bool, defval=true)


// ------------------------------------------ //
// ---------- Canal, EMA and arrow ---------- //
// ------------------------------------------ //

pema = ema(close,Pema)
plot(pema, title="EMA", color=color.blue)

canalhaut = highest(period)[1]
canalbas = lowest(period)[1]

bear = close[1] > canalhaut[1] and close < open and high > pema
bull = close[1] < canalbas[1] and open < close and low < pema

canalhautplot = plot(chan? canalhaut:na, color=color.yellow)
canalbasplot = plot(chan? canalbas:na, color=color.yellow)

plotshape(bear, title='Bear', style=shape.triangledown, location=location.abovebar, color=color.red, offset=0)
plotshape(bull, title='Bull', style=shape.triangleup, location=location.belowbar, color=color.green, offset=0)


// ------------------------------------------ //
// ------------- Position Short ------------- //
// ------------------------------------------ //

SlShort = highest(3)
BidShort = close[1]

TpShort = BidShort-((SlShort-BidShort)*ratio)
deltaShort = (SlShort-BidShort)/BidShort
betShort = round(loss/(lev*deltaShort)*100)/100
cryptShort = round(betShort*lev/BidShort*1000)/1000

// if bear[1] and labels //and low < low[1]
//     Lbear = label.new(bar_index, na, text="SHORT\n\nSL: " + tostring(SlShort) + "\n\nBid: " + tostring(BidShort) + "\n\nTP: " + tostring(TpShort) + "\n\nMise: " + tostring(betShort) + "\n\nCryptos: " + tostring(cryptShort), color=color.red, textcolor=color.white, style=label.style_labeldown, yloc=yloc.abovebar)
//     label.delete(supp ? Lbear[1] : na)

var bentry=0.0
var bsl=0.0
var btp=0.0

if bear[1] and low < low[1]
    bentry:=BidShort
    bsl:=SlShort
    btp:=TpShort
    
pbentry = plot(bpos? bentry:na, color=color.orange)
plot(bpos? (bentry+btp)/2:na, color=color.gray)
pbsl = plot(bpos? bsl:na, color=color.red)
pbtp = plot(bpos? btp:na, color=color.green)

fill(pbentry,pbsl, color.red, transp=70)
fill(pbentry,pbtp, color.green, transp=70)


// ------------------------------------------ //
// ------------- Position Long -------------- //
// ------------------------------------------ //

SlLong = lowest(3)
BidLong = close[1]

TpLong = BidLong + ((BidLong - SlLong) * ratio)
deltaBull = (BidLong - SlLong)/BidLong
betLong = round(loss/(lev*deltaBull)*100)/100
cryptLong = round(betLong*lev/BidLong*1000)/1000

// if bull[1] and labels //and high > high[1]
//     Lbull = label.new(bar_index, na, text="LONG\n\nSL: " + tostring(SlLong) + "\n\nBid: " + tostring(BidLong) + "\n\nTP: " + tostring(TpLong) + "\n\nMise: " + tostring(betLong) + "\n\nCryptos: " + tostring(cryptLong), color=color.green, textcolor=color.white, style=label.style_labelup, yloc=yloc.belowbar)
//     label.delete(supp ? Lbull[1] : na)

var Bentry=0.0
var Bsl=0.0
var Btp=0.0

if bull[1] and high > high[1]
    Bentry:=BidLong
    Bsl:=SlLong
    Btp:=TpLong
    
pBentry = plot(Bpos?Bentry:na, color=color.orange)
plot(Bpos?(Bentry+Btp)/2:na, color=color.gray)
pBsl = plot(Bpos?Bsl:na, color=color.red)
pBtp = plot(Bpos?Btp:na, color=color.green)

fill(pBentry,pBsl, color.red, transp=70)
fill(pBentry,pBtp, color.green, transp=70)


// ------------------------------------------ //
// --------------- Strategie ---------------- //
// ------------------------------------------ //

Bear = bear[1] and low < low[1]
Bull = bull[1] and high > high[1]

if (Bear and strategy.opentrades==0)
    strategy.order("short", false, 1, limit=BidShort)
    strategy.exit("exit", "short", limit = TpShort, stop = SlShort)

strategy.cancel("short", when = high > SlShort or low < (BidShort+TpShort)/2)
strategy.close("short", when=bull)

if (Bull and strategy.opentrades==0)
    strategy.order("long", true, 1, limit=BidLong)
    strategy.exit("exit", "long", limit = TpLong, stop = SlLong)
    
strategy.cancel("long", when = low < SlLong or high > (BidLong+TpLong)/2)
strategy.close("long", when=bear)


더 많은