HLHBのトレンドキャッチャー戦略

作者: リン・ハーンチャオチャン, 日付: 2023-09-28 11:44:04
タグ:

概要

この戦略は,EMAクロスオーバーとRSIを取引信号として使用し,ADXフィルタを使用して取引を入力し,利益をロックするためにストップロスを追跡することで短期間のフォックストレンドを捉えることを目的としています.この戦略はすべての通貨ペアに適用できますが,主に主要なペアの1時間のチャートで使用されています.

戦略の論理

戦略は,以下の指標と条件に基づいて取引信号を生成する.

  • 5 期間の急速EMA:青い線
  • 10期間のスローEMA:赤線
  • 平均価格 (H+L) に適用される10期RSI/2
  • 14 期間の ADX

入口信号:

  • 長: 低速EMAが低速EMAを下から越え,RSIが下から50を越えるとき
  • 短:上から速いEMAが緩いEMAを下回り,上からRSIが50を下回る.
  • ADX > 25 のときのみ信号を受け取ります

出口信号:

  • ストップ・ロスを使って 150ピップの距離を移動し 400ピップの利益を得る
  • 新しい信号が発生すると取引を閉じる.
  • 週末までにすべての取引を閉じる

この戦略は,EMAクロスオーバー,RSIオーバーバイト/オーバーセール,ADXトレンド強さを組み合わせて,堅牢なエントリールールを創出する.トレンド形成後のトレンドに乗って,利益を最大化しリスクをコントロールするためにトレーリングストップを使用する.全体的に,短期トレンドを効果的に捉えることを目的としている.

利点分析

この戦略には以下の利点があります.

  1. EMAクロスオーバーはトレンド指向を表す.上向きクロスで上昇傾向を示し,下向きクロスで下向き傾向を示します.トレンドの変化を特定することができます.

  2. RSI を追加すると,いくつかの誤ったブレイクシグナルがフィルタリングされます. 過売り/過買いゾーンは短期的な引き下げを示し,範囲市場への不必要なエントリーを回避します.

  3. 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)

もっと