가격 변동성에 기반한 이중 이동 평균 돌파 전략


생성 날짜: 2023-12-08 16:44:22 마지막으로 수정됨: 2023-12-08 16:44:22
복사: 0 클릭수: 637
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

가격 변동성에 기반한 이중 이동 평균 돌파 전략

개요

이 전략의 핵심 아이디어는 가격의 변동율을 사용하여 시장의 추세를 판단하는 것입니다. 변동율이 상승하면 시장이 새로운 추세를 형성하고 있음을 나타냅니다. 변동율이 감소하면 현재 추세가 종료되고 있음을 나타냅니다. 전략은 가격의 퍼센트 변화를 계산하고, 그에 대한 양평등 선 필링을 수행하여 가격 변동율을 반영하는 지표를 얻습니다. 지표 위에 신호선을 통과하면 구매 신호를 생성하고, 신호선을 통과하면 판매 신호를 생성합니다.

전략 원칙

이 전략은 우선 가격의 변화율을 계산합니다.

i=(src/nz(src[1], src))*100

35의 평균선 필터링을 통해 1차 가격 변동률 지표pmol2를 얻는다. 20의 평균선 필터링을 통해 2차 필터링을 통해 최종 가격 변동률 지표pmol를 얻는다. 마지막으로, 10의 평균선 필터링을 통해 pmol의 신호선을 얻는다. pmol 위에 pmols를 통과하면 구매 신호가 발생하며, pmol 아래에 pmols를 통과하면 판매 신호가 발생한다.

우위 분석

  • 이중평등선 필터를 사용하여 가격 변동률을 더 잘 추출하고, 소음을 필터링한다.
  • 가격의 비율 변화를 계산하여 가격 변화를 확대하여 트렌드 변화를 더 명확하게 반영할 수 있다.
  • 트렌드가 시작되면 구매를 하고, 트렌드가 끝나면 판매를 합니다.

위험 분석

  • 이중 평선 필러링은 어느 정도의 지연을 가져오게 됩니다.
  • 이 비율은 가격에 민감합니다.
  • 소나 곰이 변신할 때, 적시에 상장해야 한다.

최적화 방향:

  • 평균선 변수를 최적화하여 트렌드를 파악하는 데 도움이 됩니다.
  • 다른 가격 변화를 계산하는 방법을 시도해보세요.
  • 필터링 조건을 추가하여 잘못된 신호를 피하십시오.

요약하다

이 전략은 비율 변화와 쌍평등선 필러브를 계산하여 가격 변동률을 추출하여 시장 추세 변화를 판단하는, 보다 성숙한 기술 지표 클래스 전략에 속한다. 이 전략은 추세를 포착하는 능력이 강하지만 전환점 능력을 식별하는 능력은 일반적이다. 매개 변수를 조정하고 보조 조건을 추가하여 최적화 할 수 있다.

전략 소스 코드
/*backtest
start: 2022-12-01 00:00:00
end: 2023-12-07 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Strategy for DPMO", overlay=true)

src=input(close, title="Source")
length1=input(35, title="First Smoothing")
length2=input(20, title="Second Smoothing")
siglength=input(10, title="Signal Smoothing")
ebc=input(false, title="Enable Bar Colors")

upSign = '↑' // indicates the indicator shows uptrend
downSign = '↓' // incicates the indicator showing downtrend
exitSign ='x' //indicates the indicator uptrend/downtrend ending

calc_csf(src, length) => 
	sm = 2.0/length
	csf=(src - nz(csf[1])) * sm + nz(csf[1])
	csf
i=(src/nz(src[1], src))*100
pmol2=calc_csf(i-100, length1)
pmol=calc_csf( 10 * pmol2, length2)
pmols=ema(pmol, siglength)
d=pmol-pmols
hc=d>0?d>d[1]?lime:green:d<d[1]?red:orange

buyDPMO = hc==lime and hc[1]!=lime
closeBuyDPMO = hc==green and hc[1]!=green
sellDPMO = hc==red and hc[1]!=red
closeSellDPMO = hc==orange and hc[1]!=orange

plotshape(buyDPMO, color=lime, style=shape.labelup, textcolor=#000000, text="DPMO", location=location.belowbar, transp=0)
plotshape(closeBuyDPMO, color=green, style=shape.labelup, textcolor=#ffffff,  text="X", location=location.belowbar, transp=0)
plotshape(sellDPMO, color=red, style=shape.labeldown, textcolor=#000000, text="DPMO", location=location.abovebar, transp=0)
plotshape(closeSellDPMO, color=orange, style=shape.labeldown, textcolor=#ffffff,  text="X", location=location.abovebar, transp=0)
barcolor(ebc?hc:na)


strategy.entry("Long", strategy.long, when=buyDPMO)
strategy.close("Long", when=closeBuyDPMO or sellDPMO)   
strategy.entry("Short", strategy.short, when=sellDPMO)
strategy.close("Short", when=closeSellDPMO or buyDPMO)