이중 이동 평균 크로스오버와 윌리엄스 지표 조합 전략

저자:차오장, 날짜: 2024-02-01 15:04:51
태그:

img

전반적인 설명

이 전략은 두 가지 다른 전략을 결합한다. 첫 번째 전략은 주식 가격의 이중 이동 평균 크로스오버를 기반으로 신호를 생성한다. 두 번째 전략은 윌리엄스 지표의 멋진 오시레이터 (Awesome Oscillator) 를 기반으로 한다. 최종 신호는 최종 거래 신호를 형성하기 위해 두 전략 신호의 교차점을 취한다.

전략 논리

첫 번째 전략은 어제의 종료가 전날의 종료보다 높고 빠른 9일 스토카스틱 오시레이터가 느린 3일 스토카스틱 오시레이터 D-라인보다 낮을 때 구매 신호를 생성합니다. 어제의 종료가 전날의 종료보다 낮고 빠른 스토카스틱 오시레이터가 느린 스토카스틱 오시레이터 D-라인보다 높을 때 판매 신호를 생성합니다.

두 번째 전략은 5 일과 34 일 가격 변동 사이의 차이를 계산하고 그 차이의 이동 평균을 계산합니다. 현재 값이 이전 기간보다 높으면 구매 신호입니다. 현재 값이 이전 기간보다 낮으면 판매 신호입니다.

두 전략 신호는 그 교차점을 취함으로써 결합된다. 두 전략이 구매 신호를 할 때 긴 포지션을 취한다. 두 전략이 판매 신호를 할 때 짧은 포지션을 취한다.

이점 분석

이 전략은 이중 이동 평균 크로스오버 전략과 윌리엄스 지표 전략의 장점을 결합한다. 이중 이동 평균 크로스오버 전략은 중장기 트렌드를 파악할 수 있다. 윌리엄스 지표 전략은 단기 거래 기회를 포착할 수 있다. 두 전략을 결합하면 수익을 창출하고 가짜 브레이크오프를 예방할 수 있다.

또한, 여러 입력 매개 변수 사용은 다른 주식과 시장 조건에 최적화 할 수 있으며, 전략은 더 넓은 시장 환경에 적응 할 수 있습니다.

위험 분석

가장 큰 위험은 두 전략의 신호가 일관성이 없을 수 있다는 것입니다. 다른 전략이 판매 신호를 생성하는 동안 한 전략이 구매 신호를 생성하면 결합 전략은 의미있는 신호를 생성 할 수 없으며 잠재적으로 거래 기회를 놓칠 수 있습니다.

또한, 여러 매개 변수는 최적화를 위해 약간의 어려움을 초래합니다. 부적절한 매개 변수 조합은 나쁜 전략 성능으로 이어질 수 있습니다.

위험을 줄이기 위해 전략 신호 중 하나를 전적으로 사용할 수 있습니다. 또한 다른 시장 조건에 적합한 매개 변수 범위를 조사 할 수 있습니다.

더 나은 기회

이 전략은 몇 가지 측면에서 향상될 수 있습니다.

  1. 신호 일치에 최적의 매개 변수를 찾기 위해 서로 다른 매개 변수 조합에서 두 전략 사이의 신호 일관성을 평가합니다.

  2. 다양한 제품, 시간 프레임에서 최적의 적용 범위를 찾기 위해 성능을 테스트합니다.

  3. 이중 이동 평균 크로스오버를 KDJ와 같은 다른 기술 지표로 대체하여 전략 조합을 다양화하는 것을 고려하십시오.

  4. 리스크를 제어하기 위해 스톱 로스 메커니즘을 포함합니다. 예를 들어 최대 마감 스톱을 설정합니다.

결론

이 전략은 트렌드 추적 및 단기 신호를 모두 포착하기 위해 이중 이동 평균 크로스오버 전략과 윌리엄스 지표 전략을 결합합니다. 매개 변수 최적화를 통해 광범위한 시장 조건에 적응 할 수 있습니다. 그러나 불일치 신호 일치 및 복잡한 매개 변수 최적화는 여전히 도전입니다. 전반적으로 양적 거래에 효과적인 접근 방식을 제공하며 위험을 줄이고 안정성을 향상시키기 위해 추가 연구 및 최적화를 가치가 있습니다.


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 20/06/2019
// 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
//    This indicator plots the oscillator as a histogram where blue denotes 
//    periods suited for buying and red . for selling. If the current value 
//    of AO (Awesome Oscillator) is above previous, the period is considered 
//    suited for buying and the period is marked blue. If the AO value is not 
//    above previous, the period is considered suited for selling and the 
//    indicator marks it as red.
//  You can make changes in the property for set calculating strategy MA, EMA, WMA
//
// 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

BillWilliamsAC(nLengthSlow, nLengthFast,nLengthMA, nLengthEMA, nLengthWMA, bShowWMA, bShowMA, bShowEMA) =>
    pos = 0
    xSMA1_hl2 = sma(hl2, nLengthFast)
    xSMA2_hl2 = sma(hl2, nLengthSlow)
    xSMA1_SMA2 = xSMA1_hl2 - xSMA2_hl2
    xSMA_hl2 = sma(xSMA1_SMA2, nLengthFast)
    nRes =  xSMA1_SMA2 - xSMA_hl2
    xResWMA = wma(nRes, nLengthWMA)
    xResMA = sma(nRes, nLengthMA)
    xResEMA = ema(nRes, nLengthEMA)
    xSignalSeries = iff(bShowWMA, xResWMA,
                     iff(bShowMA, xResMA, 
                      iff(bShowEMA, xResEMA, na)))
    cClr = nRes > nRes[1] ? blue : red
    pos := iff(xSignalSeries[2] < 0 and xSignalSeries[1] > 0, 1,
	         iff(xSignalSeries[2] > 0 and xSignalSeries[1] < 0, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Bill Williams. Awesome Oscillator (AC) with Signal Line", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
nLengthSlow = input(34, minval=1, title="Length Slow")
nLengthFast = input(5, minval=1, title="Length Fast")
nLengthMA = input(15, minval=1, title="MA")
nLengthEMA = input(15, minval=1, title="EMA")
nLengthWMA = input(15, minval=1, title="WMA")
bShowWMA = input(type=bool, defval=true, title="Show and trading WMA")
bShowMA = input(type=bool, defval=false, title="Show and trading MA")
bShowEMA = input(type=bool, defval=false, title="Show and trading EMA")
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posBillWilliamsAC = BillWilliamsAC(nLengthSlow, nLengthFast,nLengthMA, nLengthEMA, nLengthWMA, bShowWMA, bShowMA, bShowEMA)
pos = iff(posReversal123 == 1 and posBillWilliamsAC == 1 , 1,
	   iff(posReversal123 == -1 and posBillWilliamsAC == -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 ? red: possig == 1 ? green : blue )

더 많은