느리게 움직이는 평균 전략


생성 날짜: 2023-12-07 15:21:45 마지막으로 수정됨: 2023-12-07 15:21:45
복사: 0 클릭수: 636
avatar of ChaoZhang ChaoZhang
1
집중하다
1619
수행원

느리게 움직이는 평균 전략

개요

이 전략은 24주기 동치안 통로와 200주기 평균선을 결합하여 주요 거래 신호로 사용한다. 입시 지점은 빨간색-녹색 파동이 하향으로 하락하는 것을 선택하고, 파동이 상향으로 더 많은 것을 선택한다.

전략 원칙

이 전략은 다음과 같은 몇 가지 원칙에 기반합니다.

  1. 24주기 최고점과 최저치를 사용하여 동양 통로를 구성하고, 가격이 이 통로를 뚫을 때, 큰 폭락이 일어날 수 있음을 나타냅니다.

  2. 200 주기 평균선은 다공간 필터링 조건으로, 동치안 통로를 뚫고 가격이 평균선 반대편에 있을 때, 거래상황이 역전될 수 있다고 본다.

  3. 출입 신호는:

  • 공백: 이전 K선 폐쇄 가격이 도징안 통로 상차보다 높고 200 주기 평균선보다 낮습니다. 당일 개장 가격이 폐쇄 가격보다 낮고 최저 가격이 200 평균선보다 낮습니다. 공백 신호가 발생합니다.
  • 더하기: 이전 K선 종착 가격은 도징 통로 하철보다 낮고 200 주기 평균선보다 높으며, 당일 개장 가격은 종착 가격보다 높고 최고 가격은 200 평균선보다 높으면 더하기 신호가 발생
  1. 공백한 스톱로스 가격은 최근 3개의 K선에서 가장 높은 가격이며, 스톱 가격은 공백한 가격과 공백한 가격의 차이점보다 3배나 더 많은 스톱로스 및 스톱 가격을 계산하는 방식은 공백한 가격과 반대이다.

  2. 이 전략의 장점은 동치안 통로 + 일률적인 필터링을 혼합하여 단일 기술 지표의 오해를 피하고 전략의 승률을 크게 향상시킨다는 것입니다.

우위 분석

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

  1. 승률이 높다: 동치안 통로와 평선 지표의 혼합 사용으로 단일 기술 지표의 오류로 인한 불필요한 손실을 효과적으로 피할 수 있다.

  2. 위험 조절: 최근 최고 가격/최저 가격을 중지 지점으로 사용하여 단편 손실을 효과적으로 제어한다. 중지 시점은 중지 손실의 3배이며 수익 위험은 높다.

  3. 간단하고 쉽게 작동: 지표와 논리는 매우 간단하고 명확하며 이해하기 쉽고 실행하기 쉽습니다.

  4. 적용성이 강하다: 전략 변수가 적고, 다양한 품종과 주기에서 좋은 안정성이 있다.

위험 분석

이 전략의 주요 위험은 다음과 같습니다.

  1. 극한상황의 위험: 큰 일방적인 상황이 발생하면, 손해를 유발하거나 손해를 증가시킬 수 있다. 적절한 손해 중지 수준을 완화하거나 지위를 줄이는 등의 방법으로 대응할 수 있다.

  2. 탈락 신호 오판 위험: 새로운 역방향 신호를 탈락 신호로 채택하여, 흔들림 상황에서 자주 출전하여 불필요한 슬라이드 포인트 손실이 발생할 수 있다. 탈락 논리를 최적화하여 해결할 수 있다.

  3. 매개 변수 최적화 위험: 둥지안 통로 주기 및 평균선 매개 변수 설정이 잘못되면 신호가 빈번하거나 지연될 수 있으며 매개 변수 최적화 및 조합 테스트를 통해 이 위험을 줄일 수 있다.

최적화 방향

이 전략은 다음과 같은 방향으로 최적화될 수 있습니다.

  1. 동천 통로주기와 평균선주기를 최적화하여 최적의 변수조합을 찾는다.

  2. 다양한 스톱로스 스톱 비율, 균형 승률 및 수익률을 테스트할 수 있다.

  3. 다른 지표 수정 진출 신호, 예를 들어 MACD, KD 등과 결합하여 전략 안정성을 향상시킬 수 있다.

  4. 오프라인 신호를 최적화하여 흔들림 상황에서 불필요한 출전을 방지할 수 있다. 오프라인 신호는 또한 트렌드 지표 등을 고려할 수 있다.

  5. 이 정책 프레임워크를 기반으로 새로운 정책 포트폴리오를 개발할 수 있습니다.

요약하다

이 느린 평평선 전략의 전체적인 아이디어는 명확하고 이해하기 쉽으며, 전략 신호로 둥근 통로와 평평선을 혼합하여 전략의 안정성과 승률을 효과적으로 향상시킬 수 있다. 정지보다 더 큰 정지 설정은 수익률을 높이고, 파라미터 설정은 간단하고 쉽게 구현된다. 특정 극단적인 상황과 잘못된 판단의 위험이 있지만, 여러 가지 방법으로 전략을 최적화하고 개선할 수 있으며, 강력한 확장성과 발전 잠재력을 가지고 있다.

전략 소스 코드
/*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)