이중 요인 양자 거래 전략

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

img

전반적인 설명

이 전략은 이중 요인에 의해 주도되는 양적 거래를 구현하기 위해 123 역전 및 소수 오시레이터 요인을 결합합니다. 단기 역전 기회를 포착하는 동시에 낮은 위험 과잉 수익을 달성하기 위해 장기적인 경향을 식별합니다.

원칙

첫 번째 부분은 123 역전 전략이다. 2 일 동안 가격 역전 기능을 사용하여 입점과 출구 지점을 결정한다. 가격이 2 일 동안 지속적으로 상승하고 느린 스토카스틱이 50 이하인 경우, 그것은 매매 신호를 생성하는 과판으로 간주된다. 가격이 2 일 동안 지속적으로 떨어지고 빠른 스토카스틱이 50 이상인 경우, 그것은 매매 신호를 생성하는 과반된 반격으로 간주된다.

두 번째 부분은 소수 오시일레이터 전략이다. 이 지표는 지정된 범위에서 현재 가격의 위와 아래에서 가장 가까운 소수를 계산하고 현재 가격의 차이를 출력한다. 긍정적 값은 현재 가격이 소수 수 천장 근처에 있고, 부정적인 값은 소수 수 바닥 근처에 있다는 것을 의미합니다. 트렌드 방향은 차이 값에 의해 판단되며 최종 거래 신호를 생성하기 위해 123 회전 신호와 결합됩니다.

신호 합병 규칙은 두 하위 전략이 같은 방향으로 신호를 보낼 때만 실제 거래 신호가 생성됩니다. 그렇지 않으면 신호가 충돌할 때 새로운 지위가 열리지 않습니다.

장점

이 전략은 이중적 요인을 결합함으로써 단기적 역전 효과와 장기적 경향 특성을 모두 고려하여 다각적 시장 판단을 통해 전략의 위험 저항성을 향상시킵니다.

단일 모멘텀 전략과 비교할 때, 이 전략은 급격한 가격 하락 시 적시에 손실을 멈추거나 포지션을 역전시킬 수 있으며, 역전 요인을 사용하여 일내 위험을 효과적으로 제어합니다.

단일 반전 전략과 비교하면 트렌드 방향에 대한 소수 숫자 오시레이터를 도입하면 빈번한 반전 거래에서 과잉 거래가 피할 수 있습니다.

위험성

가장 큰 위험은 두 요소 사이의 신호 충돌입니다. 123 역전이 과도한 구매 / 과도한 판매 신호를 표시하고 역전 신호를 생성하는 반면 소수 오시레이터는 여전히 추세에 있음을 보여줍니다.

이 위험을 통제하기 위해 추가적인 논리가 추가됩니다. 두 신호가 방향에 맞춰질 때만 실제 거래가 생성됩니다. 그러나 이것은 또한 일부 거래 기회를 놓칠 수 있습니다.

개선

  1. 특정 제품에 대한 더 나은 반전 매개 변수 집합을 찾기 위해 스토카스틱 매개 변수를 최적화

  2. 소음 거래를 줄이기 위해 소수 오시레이터의 허용 비율을 최적화하십시오.

  3. 일방적 손실 확장을 제한하기 위해 스톱 로스 전략을 추가합니다.

  4. 다른 시장 환경에 대한 위치를 조정하기 위해 위치 크기를 추가하는 모듈

  5. 두 가지 요소 사이의 신호 신뢰성을 판단하기 위해 기계 학습 모델을 추가하여 갈등을 줄이십시오.

결론

이 전략은 단기 역전 요인과 장기 트렌드 요인을 성공적으로 결합하여 낮은 위험량 거래를 달성합니다. 소음을 필터하기 위해 이중 요인을 효과적으로 사용하여 위험을 제어하기 위해 추가 논리를 설정함으로써 안정적인 수익 실용적인 전략입니다. 매개 변수와 기능은 실제 시장 특성에 맞게 지속적으로 최적화됩니다.


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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 28/04/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
// Determining market trends has become a science even though a high number or people 
// still believe it’s a gambling game. Mathematicians, technicians, brokers and investors 
// have worked together in developing quite several indicators to help them better understand 
// and forecast market movements.
//
// Developed by Modulus Financial Engineering Inc., the prime number oscillator indicates the 
// nearest prime number, be it at the top or the bottom of the series, and outlines the 
// difference between that prime number and the respective series.
//
// 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

PrimeNumberOscillator(price, percent) =>
    res = 0.0
    res1 = 0.0
    res2 = 0.0
    for j = price to price + (price * percent / 100)
        res1 := j
	    for i = 2 to sqrt(price)
        	res1 := iff(j % i == 0 , 0, j)
            if res1 == 0 
                break
		if res1 > 0 
		    break
    for j = price to price - (price * percent / 100)
        res2 := j
	    for i = 2 to sqrt(price)
        	res2 := iff(j % i == 0 , 0, j)
            if res2 == 0 
                break
		if res2 > 0 
		    break
    res := iff(res1 - price < price - res2,  res1 - price, res2 - price)
    res := iff(res == 0, res[1], res)
    res
    
PNO(percent) =>
    pos = 0.0
    xPNO = PrimeNumberOscillator(close, percent)
    pos:= iff(xPNO > 0, 1,
           iff(xPNO < 0, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Prime Number Oscillator", 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, "---- Prime Number Oscillator ----")
percent = input(5, minval=0.01, step = 0.01, title="Tolerance Percentage")
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posPNO = PNO(percent)
pos = iff(posReversal123 == 1 and posPNO == 1 , 1,
	   iff(posReversal123 == -1 and posPNO == -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 )

더 많은