이중 요인 복합 역전 및 질량 지수 전략

저자:차오장, 날짜: 2023-12-26 12:20:57
태그:

img

전반적인 설명

이 전략은 이중 요인 모델에 기반한 콤보 역전 거래 전략이다. 123 역전 패턴과 질량 지수 요인을 통합하여 전략 신호에 대한 누적 효과를 달성합니다. 두 요소가 동시에 구매 또는 판매 신호를 발산 할 때만 길거나 짧을 것입니다.

전략 논리

123 반전 요인

이 요인은 123 가격 패턴에 기반하여 작동합니다. 지난 2 일 동안의 종료 가격 관계는 하-고등이고 스톡 지표가 50 이하일 때, 그것은 바닥 반전을 신호하고 길게 간다. 종료 가격 관계는 고등-하하고 스톡이 50 이상일 때, 그것은 최고 반전을 신호하고 짧게 간다.

질량 지수 인수

이 요인은 가격 변동 범위의 팽창 또는 수축에 따라 트렌드 반전을 판단합니다. 범위가 확장됨에 따라 지수는 상승하고 범위가 좁아짐에 따라 지수는 떨어집니다. 지수가 한 임계값을 넘어서면 판매 신호를 생성하고 임계값을 넘어서면 구매 신호를 생성합니다.

이 전략은 두 요소가 같은 방향으로 신호를 발산할 때만 포지션을 열고, 하나의 요소에서 잘못된 신호를 피하면서 수익성있는 거래를 달성합니다.

이점 분석

  • 더 나은 신호 정확성을 위해 가격 패턴과 변동성 지표를 결합 한 이중 요인 모델
  • 123 패턴은 지역 극한점을 포착합니다. 질량 지수는 글로벌 트렌드 반전 지점을 포착합니다.
  • 두 가지 요소가 동의할 때만 신호를 받는 것은 잘못된 신호를 피하고 안정성을 향상시킵니다.

위험 분석

  • 두 가지 요인이 동시에 잘못된 신호를 발산하여 손실을 초래할 가능성이 있습니다.
  • 역전 실패 비율이 존재, 하향을 제어하기 위해 손실을 중지 설정해야합니다
  • 부적절한 매개 변수 조정은 과장 조정으로 이어질 수 있습니다.

위험은 훈련 세트를 확장하고 엄격한 스톱 로스, 멀티 팩터 필터링 등을 통해 줄일 수 있습니다.

최적화 방향

  • 더 많은 가격 및 변동성 지표 조합을 테스트합니다.
  • 신호 품질과 동적으로 크기 위치를 판단하는 ML 모델을 추가
  • 더 많은 알파를 발견하기 위해 부피, 볼링거 밴드 등을 포함합니다.
  • 탄력성을 위해 앞으로 걷는 최적화를 사용

결론

이 전략은 가격 패턴과 변동성 지표라는 두 가지 요소를 결합하여 단일 요인으로부터의 잘못된 신호를 피하고 안정성을 향상시키면서 동의할 때만 신호를 받아들이는 것입니다. 그러나 동시에 잘못된 신호에 대한 위험이 남아 있습니다. 우리는 데이터 세트를 확장하고 스톱 로스를 설정하고 요소 조합을 최적화하여 성능과 위험 조정 수익을 더욱 향상시킬 수 있습니다.


/*backtest
start: 2023-11-25 00:00:00
end: 2023-12-25 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 22/02/2021
// This is combo strategies for get a cumulative signal. 
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The 
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close 
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50. 
// The strategy sells at market, if close price is lower than the previous close price 
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// The Mass Index was designed to identify trend reversals by measuring 
// the narrowing and widening of the range between the high and low prices. 
// As this range widens, the Mass Index increases; as the range narrows 
// the Mass Index decreases.
// The Mass Index was developed by Donald Dorsey. 
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
    vFast = sma(stoch(close, high, low, Length), KSmoothing) 
    vSlow = sma(vFast, DLength)
    pos = 0.0
    pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
	         iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0))) 
	pos


MASS(Length1,Length2,Trigger) =>
    pos = 0.0
    xPrice = high - low
    xEMA = ema(xPrice, Length1)
    xSmoothXAvg = ema(xEMA, Length1)
    nRes = sum(iff(xSmoothXAvg != 0, xEMA / xSmoothXAvg, 0), Length2)
    pos := iff(nRes > Trigger, -1,
	         iff(nRes < Trigger, 1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & MASS Index", shorttitle="Combo", overlay = true)
line1 = input(true, "---- 123 Reversal ----")
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
line2 = input(true, "---- MASS Index ----")
Length1 = input(9, minval=1)
Length2 = input(25, minval=1)
Trigger = input(26.5, step = 0.01)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posMASS = MASS(Length1,Length2,Trigger)
pos = iff(posReversal123 == 1 and posMASS == 1 , 1,
	   iff(posReversal123 == -1 and posMASS == -1, -1, 0)) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1 , 1, pos))	   
if (possig == 1 ) 
    strategy.entry("Long", strategy.long)
if (possig == -1 )
    strategy.entry("Short", strategy.short)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )

더 많은