이중 반전 CMO 양자 전략

저자:차오장, 날짜: 2024-01-04 14:35:23
태그:

img

전반적인 설명

이 전략은 이중 반전 전략으로 123 반전 지표와 CMOWMA 양자 지표를 결합하여 빨간색과 녹색 K-라인 시각 효과로 가격 반전 신호의 이중 확인을 달성합니다.

전략 원칙

이 전략은 두 부분으로 구성됩니다.

  1. 123 반전 지표

    • 가격 상승 또는 하락을 결정하기 위해 종료 가격과 이전 종료 가격을 사용
    • 역전 신호를 확인하기 위해 스토카스틱 지표의 빠른 라인과 느린 라인 크로스오버를 사용하십시오.
    • 조건이 충족되면 긴 신호 또는 짧은 신호를 생성
  2. CMOWMA 양자 지표

    • 가격 동력을 측정하기 위해 CMO 지표를 사용
    • WMA 가중된 이동 평균을 CMO 지표에 적용합니다.
    • CMO가 WMA보다 높을 때 길게 (단기)

두 부분 모두 같은 방향으로 신호를 내릴 때 위치를 입력합니다.

전략 의 장점

  1. 이중 확인 메커니즘은 잘못된 브레이크를 필터하고 불필요한 위치를 줄일 수 있습니다.
  2. 빨간색과 녹색의 K-라인 컬러링은 시장 조건을 쉽게 판단하기 위해 시각 효과를 생성합니다.
  3. 역전 및 추진력 지표의 조합은 전반적인 안정성을 제공합니다.
  4. 간단한 매개 변수 설정은 다양한 제품에 적합하고 구현하기 쉽습니다

전략 의 위험

  1. 처음 반전된 후에도 가격이 다시 뒤집어질 수 있으며, 위프사 (Whipsaws) 의 위험이 있습니다.
  2. 빈번한 위치 전환은 과도한 거래 수수료를 발생
  3. 부적절한 매개 변수 설정은 신호가 너무 많거나 너무 적을 수 있습니다.
  4. CMO 매개 변수는 제품 특성에 따라 조정해야 합니다.

리스크는 반전 조건의 완화, 보유 기간의 연장, 매개 변수 조합의 최적화 등으로 줄일 수 있습니다.

최적화 방향

  1. 다른 스토카스틱 매개 변수의 테스트 영향
  2. MACD, KDJ 등과 같은 다른 지표로 확인을 대체/충분합니다.
  3. 다른 CMO 및 WMA 길이의 테스트 최적화
  4. 특정 수준에서 스톱 로스/프로프트 테킹을 추가해보세요
  5. 새로운 위치의 주파수를 제어하는 필터를 설정

요약

이 전략은 간단한 매개 변수와 구현하기 쉬운 전반적으로 견고하며, 잘못된 신호를 제거하기 위해 효과적인 이중 신호 필터링 메커니즘을 형성하기 위해 가격 반전 및 추진력 지표를 결합합니다. K-라인 컬러링은 직관적인 시각을 제공합니다. 매개 변수 최적화 및 위험 통제에서 추가 성능 향상이 발생할 수 있습니다.


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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 19/08/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 Chandre Momentum Oscillator and its WMA on the 
//    same chart. This indicator plots the absolute value of CMO.
//    The CMO is closely related to, yet unique from, other momentum oriented 
//    indicators such as Relative Strength Index, Stochastic, Rate-of-Change, 
//    etc. It is most closely related to Welles Wilder?s RSI, yet it differs 
//    in several ways:
//    - It uses data for both up days and down days in the numerator, thereby 
//        directly measuring momentum;
//    - The calculations are applied on unsmoothed data. Therefore, short-term 
//        extreme movements in price are not hidden. Once calculated, smoothing 
//        can be applied to the CMO, if desired;
//    - The scale is bounded between +100 and -100, thereby allowing you to clearly 
//        see changes in net momentum using the 0 level. The bounded scale also allows 
//        you to conveniently compare values across different securities.
//
// 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

CMOWMA(Length, LengthWMA) =>
    pos = 0
    xMom = abs(close - close[1])
    xSMA_mom = sma(xMom, Length)
    xMomLength = close - close[Length]
    nRes = 100 * (xMomLength / (xSMA_mom * Length))
    xWMACMO = wma(nRes, LengthWMA)
    pos := iff(nRes > xWMACMO, 1,
    	   iff(nRes <= xWMACMO, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & CMO & WMA", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
LengthCMO = input(14, minval=1)
LengthWMA = input(13, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posCMOWMA = CMOWMA(LengthCMO, LengthWMA)
pos = iff(posReversal123 == 1 and posCMOWMA == 1 , 1,
	   iff(posReversal123 == -1 and posCMOWMA == -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 )

더 많은