HLHB 트렌드 캐처 전략

저자:차오장, 날짜: 2023-09-28 11:44:04
태그:

전반적인 설명

이 전략은 EMA 크로스오버와 RSI를 거래 신호로 사용하여 단기 외환 트렌드를 파악하고 ADX 필터를 사용하여 거래를 입력하고 수익을 잠금하기 위해 손해를 멈추는 것을 목표로합니다. 이 전략은 모든 통화 쌍에 적용 될 수 있지만 주요 쌍의 1 시간 차트에 주로 사용됩니다.

전략 논리

이 전략은 거래 신호를 생성하기 위한 다음의 지표와 조건에 기초합니다.

  • 5주기 빠른 EMA: 파란색 선
  • 10주기 느린 EMA: 빨간 선
  • 중간에 적용된 10 기간 RSI (H+L) /2
  • 14주기 ADX

입구 신호:

  • 롱: 빠른 EMA가 밑에서 느린 EMA를 넘고 RSI가 밑에서 50을 넘으면
  • 짧은: 빠른 EMA가 상위에서 느린 EMA 아래로 넘어가고 RSI가 상위에서 50 아래로 넘어가면
  • ADX > 25일만 신호를 받습니다.

출구 신호:

  • 트레일링 스톱 로스를 사용 하 여, 150 피프 트레일 거리 및 400 피프 수익을
  • 새로운 신호가 발생하면 거래를 종료합니다.
  • 주말 전에 모든 거래를 종료

이 전략은 EMA 크로스오버, RSI 과잉 구매/ 과잉 판매 및 ADX 트렌드 강도를 결합하여 탄탄한 진입 규칙을 만듭니다. 형성 후 트렌드를 타고 수익을 극대화하고 위험을 제어하기 위해 트레일링 스톱을 사용합니다. 전반적으로 단기 트렌드를 효과적으로 잡는 것을 목표로합니다.

이점 분석

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 트렌드 방향에 대한 EMA 크로스오버. 상향 크로스는 상승 추세를 나타내고 하향 크로스는 하락 추세를 나타냅니다. 트렌드 변화를 식별 할 수 있습니다.

  2. RSI를 추가하면 일부 잘못된 브레이크오웃 신호를 필터링합니다. 과잉 판매/대량 구매 구역은 단기적 인 인기를 나타내고 범위 시장에 불필요한 입력을 피합니다.

  3. 진정한 트렌드 존재를 보장하기 위한 ADX. ADX > 25일만 거래 신호를 고려하여 탄탄한 트렌드를 보장합니다.

  4. 후속 스톱 로즈와 수익을 가져가면서 위험을 통제하면서 수익을 실행하십시오. 150 피프 후속 거리와 400 피프 수익 목표가 지속적으로 트렌드를 타고 있습니다.

  5. 모든 포지션을 주말 전에 폐쇄하면 주말 위험을 피하고 거래의 규칙성을 강화합니다.

위험 분석

이 전략은 또한 다음과 같은 위험을 가지고 있습니다.

  1. EMA 크로스오버 시스템은 잘못된 브레이크아웃 신호에 취약하여 손실을 초래합니다. EMA 길이를 정렬하거나 다른 필터를 추가하십시오.

  2. RSI는 과도한 구매/대판 수준만을 파악합니다. 트렌드 반전이 아닙니다. 트렌드를 놓칠 수도 있습니다. 다른 지표와 결합할 수도 있습니다.

  3. ADX는 트렌드 존재만 판단하고, 진입 시기는 틀릴 수도 있습니다. 다른 규칙을 추가하거나 ADX 문턱을 낮출 수도 있습니다.

  4. 고정 스톱 로스 및 수익을 취하는 수준은 시장 변화에 적응하지 않을 수 있습니다. 다른 매개 변수 또는 수동 개입을 테스트하십시오.

  5. 강제적인 주간 폐쇄는 좋은 트렌드 기회를 놓칠 수 있습니다.

최적화 방향

이 전략은 다음과 같은 측면에서 최적화 될 수 있습니다.

  1. 최적의 길이를 찾기 위해 다른 EMA 조합을 테스트하십시오. 추세 강도를 추가하기 위해 기울기를 고려하십시오.

  2. 다른 RSI 매개 변수를 시도하거나 KDJ와 결합하여 더 나은 과잉 구매 / 과잉 판매 판단을 시도하십시오.

  3. ADX 매개 변수를 최적화하여 더 적합한 필터링과 더 높은 입수 품질을 제공합니다.

  4. 고정 정지 및 ATR 기반 동적 후속의 시험 조합

  5. 트렌드 확인 후, 예를 들어 더 낮은 시간 프레임과 같은 내일 브레이크백 풀백 엔트리를 추가합니다.

  6. 시장의 변동성에 기반한 동적 조정을 위해 변동성 기반의 포지션 사이징을 도입합니다.

  7. 기계 학습 기술을 탐구하여 적응성을 위한 매개 변수를 자동으로 최적화합니다.

요약

요약하면 이것은 EMA 크로스오버로 트렌드 방향을 식별하고, RSI로 필터링하고, ADX로 트렌드를 요구하고, 수익을 위해 트레일링 스톱을 요구하는 간단한 트렌드 다음 전략이다. 최적화는 주로 유연성을 위해 더 나은 지표 조합을 찾고, 동적 위치 사이징을 추가하는 것을 포함합니다. 논리는 가치가 있지만 실용적인 응용을 위해 추가 테스트와 최적화가 필요합니다.


/*backtest
start: 2022-09-21 00:00:00
end: 2023-09-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("Hucklekiwi Pip - HLHB Trend-Catcher System", shorttitle="HLHB TCS", overlay=true,
  default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// -----------------------------------------------------------------------------
// HLHB Trend-Catcher System as described on BabyPips.com
//
// Strategy Author: Hucklekiwi Pip 
// Coded By: Backtest Rookies
// -----------------------------------------------------------------------------
//
// Refs:
//   - Original System: https://www.babypips.com/trading/forex-hlhb-system-explained
//   - Updated System: https://www.babypips.com/trading/forex-hlhb-system-20190311
//
//
// Description (From Hucklekiwi Pip)
// 
//   The HLHB System simply aims to catch short-term forex trends.
//   It is patterned after the Amazing Crossover System that Robopip once backtested.
//   In fact, it was one of his highest-scoring mechanical systems in 2014! 
//   The system can be applied to any pair, but since I’m into major pairs, 
//   I’m applying it to the 1-hour charts of EUR/USD and GBP/USD.
// -----------------------------------------------------------------------------
// STRATEGY REQUIREMENTS
// -----------------------------------------------------------------------------
//
// Setup
// -----
//  - EUR/USD 1-hour chart
//  - GBP/USD 1-hour chart
//  - 5 EMA: blue line
//  - 10 EMA: red line
//  - RSI (10) applied to the median price (HL/2)
//  - ADX (14)
//
// Entry
// -----
//  - BUY when the 5 EMA crosses above the 10 EMA from underneath and the RSI 
//    crosses above the 50.0 mark from the bottom.
//  - SELL when the 5 EMA crosses below the 10 EMA from the top and the RSI 
//    crosses below the 50.0 mark from the top.
//  - Make sure that the RSI did cross 50.0 from the top or bottom and not just 
//    ranging tightly around the level.
//  - ADX > 25 for Buy and Sells
//
// Exit
// ----
//  - Use a 50-pip trailing stop and a 200-pip profit target. This increases the 
//    chances of the system riding longer trends.
//  - Close the trade when a new signal materializes.
//  - Close all trades by the end of the week.
// 
// -----------------------------------------------------------------------------

// Strategy Varaibles
// -------------------
ema_fast_len = input(5, title='Fast EMA Length')
ema_slow_len = input(10 , title='Slow EMA Length')
rsi_len = input(10, title='Slow EMA Length')
session_end_hour = input(16, minval=0, maxval=23, title='Weekly Session End (Hour)')
session_end_minute = input(0, minval=0, maxval=59, title='Weekly Session End (Minute)')
// Targets taken from the update post which states 150 & 400 instead of 50 and 200.
profit_target = input(400, title='Profit Target (Pips/Points)')
trailing_stop_dist = input(150, title='Trailing Stop Distance (Pips/Points)')
adx_filt = input(true, title='User ADX Filter')
adx_min = input(25, minval=0, title='Minimum ADX Level')
adx_len = input(14, title="ADX Smoothing")
di_len = input(14, title="DI Length")

// Setup the Indicators
ema_fast = ema(close, ema_fast_len)
ema_slow = ema(close, ema_slow_len)
rsi_ind = rsi(close, rsi_len)

// ADX
adx_dirmov(len) =>
	up = change(high)
	down = -change(low)
	plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
    minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(plusDM, len) / truerange)
	minus = fixnan(100 * rma(minusDM, len) / truerange)
	[plus, minus]

adx_adx(dilen, adxlen) =>
	[plus, minus] = adx_dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
	[adx, plus, minus]

[adx_sig, adx_plus, adx_minus] = adx_adx(di_len, adx_len)


// Strategy Logic
ema_long_cross = crossover(ema_fast, ema_slow)
ema_short_cross = crossunder(ema_fast, ema_slow)
rsi_long_cross = crossover(rsi_ind, 50)
rsi_short_cross = crossunder(rsi_ind, 50)
adx_check = adx_filt ? adx_sig >= adx_min : true

longCondition = ema_long_cross and rsi_long_cross and adx_check
if (longCondition)
    strategy.entry("Long", strategy.long)

shortCondition = ema_short_cross and rsi_short_cross and adx_check
if (shortCondition)
    strategy.entry("Short", strategy.short)

strategy.exit("SL/TP", "Long", profit=profit_target,  loss=trailing_stop_dist, trail_points=trailing_stop_dist)  
strategy.exit("SL/TP", "Short", profit=profit_target, loss=trailing_stop_dist, trail_points=trailing_stop_dist)  

// Friday = 6
// If we miss the hour for some reason (due to strange timeframe), then close immediately
// Else if we are on the closing hour, then check to see if we are on or passed the close minute
close_time = dayofweek == 6 ? 
  hour[0] > session_end_hour ? true :
  hour[0] == session_end_hour ?
      minute[0] >= session_end_minute :
  false : false

strategy.close_all(when=close_time)

// Plotting
plot(ema_fast, color=blue, title="Fast EMA")
plot(ema_slow, color=red, title="Slow EMA")

plotshape(rsi_long_cross, style=shape.triangleup, size=size.tiny, location=location.belowbar, color=green, title='RSI Long Cross Marker')
plotshape(rsi_short_cross, style=shape.triangledown, size=size.tiny, location=location.abovebar, color=red, title='RSI Short Cross Marker')

// ADX Filter Highlight
bgcolor(adx_filt and adx_check ? orange : na, transp=90)

더 많은