Comb Reverse EMA 볼륨 가중량 최적화 거래 전략

저자:차오장, 날짜: 2023-12-07 16:39:50
태그:

img

전반적인 설명

이 전략은 이중 최적화된 복합 역 EMA 가중화 거래 전략이다. 이 전략은 역 전략과 EMA 가중화 전략을 결합하여 두 가지 다른 유형의 전략이며 두 전략의 신호가 일관성 있는지 판단함으로써 더 신뢰할 수있는 거래 신호를 생성합니다.

전략 원칙

역전 부분에서는 123 역전 전략을 사용합니다. 이 전략은 전날 두 날의 폐쇄 가격과 스토카스틱 오시일레이터 사이의 관계를 결합하여 신호를 생성합니다. 구체적인 규칙은 다음과 같습니다.

  • 오늘의 종료 가격은 어제보다 높고 어제의 종료 가격은 전날보다 낮을 때, 동시에, 9일 스토카스틱 슬로우 라인이 50보다 낮으면, 긴
  • 오늘의 종료 가격은 어제보다 낮고 어제의 종료 가격은 전날보다 높을 때, 동시에 9일 스토카스틱 패스트 라인이 50보다 높을 때, 쇼트합니다.

가중된 EMA 부분은 지수적인 이동 평균과 부피 가중된 계산을 사용합니다. 계산 공식은 다음과 같습니다.

xMAVolPrice = ema(volume * close, Length)
xMAVol = ema(volume, Length)
nRes = xMAVolPrice / xMAVol

특정 거래 규칙은: nRes 지표가 어제의 종료 가격보다 낮거나 높을 때, 길고 짧습니다.

마지막으로, 전략은 실제 거래 신호를 생성하기 전에 두 부분의 신호가 일치하는지 여부를 판단합니다.

이점 분석

이 전략은 서로 확인하고 신호의 신뢰성을 향상시키고 잘못된 신호를 줄이기 위해 두 가지 다른 유형의 전략을 결합합니다. 동시에 반전 부분은 전환점을 포착 할 수 있으며 EMA 가중된 부분은 보완적인 이점을 달성하기 위해 트렌드를 추적 할 수 있습니다.

위험 분석

이 전략은 특정 시간 지연을 가지고 있으며 단기 거래 기회를 놓칠 수 있습니다. 또한 EMA 가중도는 오스실레이션 시장에 효과적이지 않습니다. 또한 반전 신호의 신뢰성도 확인해야합니다.

대응 속도를 높이기 위해 적절하게 매개 변수를 단축합니다. 위험을 제어하기 위해 스톱 손실을 추가합니다. 반전 신호를 확인하기 위해 더 많은 요소를 도입합니다.

최적화

  1. 최적의 매개 변수를 찾기 위해 더 많은 반전 요인 조합을 테스트합니다.
  2. 다른 종류의 EMA 가중 측정 방법을 시도해보세요.
  3. 스톱 로스를 추가하고, 후속 스톱 로스를 추가합니다.
  4. 더 빠른 반응을 위해 파라미터 최적화.

요약

이 전략은 두 가지 다른 유형의 전략의 장점을 통합하여 신호 품질을 향상시키고 하나의 전략의 단점을 어느 정도 극복 할 수 있습니다. 그러나 추가 최적화가 필요한 특정 지연도 있습니다. 전반적으로이 전략은 양적 거래에 대한 새로운 아이디어를 제공하며 시장 기회를 잡기 위해 추가 연구와 최적화를 가치가 있습니다.


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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 18/10/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
// The related article is copyrighted material from Stocks & Commodities 2009 Oct 
//
// 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

fFilter(xSeriesSum, xSeriesV, Filter) =>
    iff(xSeriesV > Filter, xSeriesSum, 0)

EMA_VW(Length) =>
    pos = 0.0
    xMAVolPrice = ema(volume * close, Length)
    xMAVol = ema(volume, Length)
    nRes = xMAVolPrice / xMAVol
    pos := iff(nRes < close[1], 1,
             iff(nRes > close[1], -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & EMA & Volume Weighting", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
LengthEMA_VM = input(22, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posEMA_VW = EMA_VW(LengthEMA_VM)
pos = iff(posReversal123 == 1 and posEMA_VW == 1 , 1,
	   iff(posReversal123 == -1 and posEMA_VW == -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 )

더 많은