123 역전 패턴 전략과 결합된 반복적인 이동 트렌드 평균

저자:차오장, 날짜: 2024-02-21 16:02:32
태그:

img

전반적인 설명

이 전략은 반복적인 이동 트렌드 평균과 123 역전 패턴을 결합하여 안정성과 수익성을 향상시키는 복합 신호로 만듭니다.

원칙

123 반전 패턴

이 부분은 울프 젠슨의 책 How I Tripled My Money in the Futures Market에서 영감을 얻었습니다. 닫기 가격이 2일 연속 상승하고 9일 STO SLOWK가 50보다 낮을 때 구매하고 닫기 가격이 2일 연속 하락하고 9일 STO FASTK가 50보다 높을 때 판매합니다.

반복적인 이동 트렌드 평균

이 기술은 재귀 복소분자 적정성이라고 불린다. 그것은 내일의 가격을 예측하기 위해 지난 며칠의 가격과 오늘의 가격을 사용합니다. 예측된 가격이 어제의 실제 가격보다 높을 때 짧고 그렇지 않으면 길게 간다.

장점

복합 전략은 단일 전략의 한계를 피하기 위해 두 전략의 강점을 활용합니다. 123 역전 패턴은 가격 역전이 발생했을 때 주요 트렌드를 잡을 수 있습니다. 반복적인 이동 트렌드 평균은 가격 움직임 방향을 더 정확하게 판단 할 수 있습니다. 함께 그들은 더 강한 복합 신호를 형성합니다.

위험 과 해결책

  • 123 반전 패턴은 단기 가격 변동으로 인해 잘못된 신호를 생성 할 수 있습니다. 매개 변수를 세밀하게 조정하면 소음을 필터링 할 수 있습니다.
  • 반복적인 이동 트렌드 평균은 갑작스러운 사건에 천천히 반응 할 수 있습니다. 지역 트렌드에 대한 다른 지표를 고려하는 것이 유용합니다.
  • 두 전략은 때때로 불일치한 신호를 줄 수 있습니다. 한 해결책은 이중 신호가 나타날 때만 포지션을 열거나 시장 상황에 따라 하나의 신호만을 따르는 것입니다.

개선 을 위한 지침

  • 최적의 쌍을 찾기 위해 기간 매개 변수의 다른 조합을 테스트합니다.
  • 자동 스톱 손실 메커니즘을 도입합니다.
  • 다른 제품과 시장 환경에 따라 매개 변수를 조정합니다.
  • 더 강력한 시스템을 형성하기 위해 다른 전략이나 지표와 결합하는 것을 고려하십시오.

결론

이 전략은 두 가지 다른 유형의 전략을 결합하고 안정성을 향상시키기 위해 복합 신호를 생성합니다. 가격 반전 지점을 파악하고 미래의 가격 추세를 판단하기 위해 두 가지의 장점을 활용합니다. 추가 최적화는 더 나은 성과를 가져올 수 있습니다.


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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 01/06/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
// Taken from an article "The Yen Recused" in the December 1998 issue of TASC, 
// written by Dennis Meyers. He describes the Recursive MA in mathematical terms 
// as "recursive polynomial fit, a technique that uses a small number of past values 
// of the estimated price and today's price to predict tomorrows price."
// Red bars color - short position. Green is long.
//
// 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


RMTA(Length) =>
    pos = 0.0
    Bot = 0.0
    nRes = 0.0
    Alpha = 2 / (Length+1)
    Bot := (1-Alpha) * nz(Bot[1],close) + close
    nRes := (1-Alpha) * nz(nRes[1],close) + (Alpha*(close + Bot - nz(Bot[1], 0)))
    pos:= iff(nRes > close[1], -1,
    	     iff(nRes < close[1], 1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Recursive Moving Trend Average", 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, "---- Recursive Moving Trend Average ----")
LengthRMTA = input(21, minval=3)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posRMTA = RMTA(LengthRMTA)
pos = iff(posReversal123 == 1 and posRMTA == 1 , 1,
	   iff(posReversal123 == -1 and posRMTA == -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 )

더 많은