실제 변동성을 기반으로 한 가중 이동 평균 시간 간 전략


생성 날짜: 2024-01-17 15:09:28 마지막으로 수정됨: 2024-01-17 15:09:28
복사: 1 클릭수: 572
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

실제 변동성을 기반으로 한 가중 이동 평균 시간 간 전략

개요

이 전략은 실제 파장 (True Range) 과 중도 이동 평균 (WMA) 을 사용하여 트렌드 판단을 위해 기간 간 지표를 구축합니다. 동시에, 여러 포지션의 축적된 피라미드 포지션 메커니즘과 안정적인 수익을 추구하기 위한 여러 손실 메커니즘을 갖추고 있습니다.

전략 원칙

이 전략은 먼저 상위 파동량 ((sube) 과 하위 파동량 ((baja) 을 계산하고, 그 다음에는 빠른 라인 ((corto) 주기 및 느린 라인 ((largo) 주기의 WMA를 계산한다. 빠른 라인 및 느린 라인 차이는 WMA를 통해 다시 지표 ((ind) 를 계산한다. 지표가 0을 통과하면 구매 신호가 발생하고, 0을 통과하면 판매 신호가 발생한다.

상장 후, 전략은 5개의 포지션을 미리 설정하여, 동등하게 (((배) 축적 방식으로 피라미드 포지션을 실현한다. 동시에, 손실 메커니즘을 설정하고, 이후 포지션을 열 때, 현재 파동이 손실선 이하인지 판단하여 위험을 제어한다.

우위 분석

이 전략은 장기간 판단, 피라미드 상장, 여러 손실을 막는 등의 메커니즘을 통합하여 위험을 효과적으로 통제하고 안정적인 수익을 추구할 수 있습니다.

기간 간 판단 빠른 느린 라인 조합을 통해 트렌드 판단 시스템을 구축하여 시장 소음을 효과적으로 필터링하고 트렌드 전환점을 식별 할 수 있습니다. 피라미드 상장하면 트렌드 초기 단계에서 더 많은 수익을 얻을 수 있으며, 다중 중단 메커니즘은 단일 손실을 효과적으로 제어 할 수 있습니다.

위험 분석

이 전략의 주요 위험은 갑작스러운 사건이 발생하여 급격한 시장 반향으로 인해 손실이 발생할 수 있다는 것입니다. 또한, 매개 변수 설정이 적절하지 않으면 전략의 안정성에 영향을 줄 수 있습니다.

적절히 느슨한 스톱 라인을 통해 시장상황의 역전 위험에 대응할 수 있다. 최적화 파라미터 설정, 조정 사이클 파라미터, 포지션 수 등이 전략 안정성을 향상시킬 수 있다.

최적화 방향

이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.

  1. 통계적 지표 판단을 추가하고, 변동률, 거래량과 같은 지표 수정 파라미터를 결합하여 전략을 더 적합하게 만듭니다.

  2. 기계 학습 모델 판단을 증가시키고, LSTM와 같은 딥 러닝 모델 보조 판단을 사용하여, 전략의 정확성을 향상시킨다.

  3. 포지션 관리 메커니즘을 최적화하고, 포지션 성장을 합리적으로 만들기 위해 부양률을 유동률에 따라 조정하는 것을 고려할 수 있습니다.

  4. 미래에셋대우의 모형과 결합하여, 시한부대출을 활용하여 위험을 더욱 제어한다.

요약하다

이 전략은 전반적으로 실제 파도 지표에 기반한 교기간의 트렌드 전략으로, 피라미드 가장금고와 다중 중지 메커니즘을 갖추고, 위험을 효과적으로 제어하고, 안정적인 수익을 추구할 수 있으며, 매우 실용적인 수치화 거래 전략이다. 그러나 여전히 시세 역전과 변수 최적화 문제에 주의를 기울여야 하며, 통계학, 기계학습 등의 측면에서 추가적으로 최적화 할 수 있다.

전략 소스 코드
/*backtest
start: 2023-01-10 00:00:00
end: 2024-01-16 00:00:00
period: 1d
basePeriod: 1h
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/
// © MaclenMtz

//@version=5
strategy("[MACLEN] Rangos", shorttitle="Rangos [https://t.me/Bitcoin_Maclen]", overlay=false )

//------WINDOW----------

i_startTime = input(defval = timestamp("01 Jan 2022 00:00 -0700"), title = "Start Time", group = "Backtest Window")
i_endTime = input(defval = timestamp("31 Dec 2025 00:00 -0700"), title = "End Time")
window = true

//-----------------------------

sube = close>close[1] ? ta.tr : 0
baja = close<close[1] ? ta.tr : 0

corto = input(10)
largo = input(30)
suavizado = input(10)

fastDiff = ta.wma(sube, corto) - ta.wma(baja,corto)
slowDiff = ta.wma(sube, largo) - ta.wma(baja, largo)
ind = ta.wma(fastDiff - slowDiff, suavizado)

iColor = ind>0 ? color.green : ind<0 ? color.red : color.black
plot(ind, color=iColor)
plot(0, color=color.white)

long = ind[1]<ind and ind[2]<ind[1] and ind<0
short = ind[1]>ind and ind[2]>ind[1] and ind>0

plotshape(long and not long[1], style = shape.xcross, color=color.green, location=location.bottom, size=size.tiny)
plotshape(short and not short[1], style = shape.xcross, color=color.red, location=location.top, size=size.tiny)

//Contratos
contrato1 = input(50000)/(16*close)
c1 = contrato1
c2 = contrato1
c3 = contrato1*2
c4 = contrato1*4
c5 = contrato1*8

//cap_enopentrade = strategy.opentrades == 1 ? c1: strategy.opentrades == 2 ? c1+c2: strategy.opentrades == 3 ? c1+c2+c3: strategy.opentrades == 4 ? c1+c2+c3+c4: strategy.opentrades == 5 ? c1+c2+c3+c4+c5 : 0
openprofit_porc = math.round((close-strategy.position_avg_price)/strategy.position_avg_price * 100,2)

porc_tp = input.float(6.5)
safe = input(-6)

//----------------Strategy---------------------------

if strategy.opentrades == 0
    strategy.entry('BUY1', strategy.long, qty=c1, when = long and not long[1] and window)

if strategy.opentrades == 1
    strategy.entry('BUY2', strategy.long, qty=c2, when = long and not long[1] and window and openprofit_porc<safe)

if strategy.opentrades == 2
    strategy.entry('BUY3', strategy.long, qty=c3, when = long and not long[1] and window and openprofit_porc<safe)

if strategy.opentrades == 3
    strategy.entry('BUY4', strategy.long, qty=c4, when = long and not long[1] and window and openprofit_porc<safe)

if strategy.opentrades == 4
    strategy.entry('BUY5', strategy.long, qty=c5, when = long and not long[1] and window and openprofit_porc<safe)

min_prof = strategy.openprofit>0

strategy.close_all(when=short and min_prof)

plot(openprofit_porc)