小さなトレンドを捉えるための高低移動平均クロスオーバー戦略


作成日: 2023-09-28 11:44:04 最終変更日: 2023-09-28 11:44:04
コピー: 1 クリック数: 780
1
フォロー
1617
フォロワー

概要

この戦略は,短期外為トレンドを捕捉し,取引信号としてEMAとRSIの交差を適用し,ADXフィルターと組み合わせて,トレンドフォローのストップを導入して利益をロックします.この戦略は,すべての通貨ペアに適用されますが,主に主要な通貨ペアの1時間チャートに適用されます.

戦略原則

この戦略は,以下の指標と条件に基づいて取引シグナルを作成します.

  • 5周期速 EMA:ブルーライン
  • 10周期遅いEMA:赤線
  • 閉盤価格の中間価格 ((最高価格+最低価格/2) に適用される10周期RSI
  • 14周期ADX

取引開始のシグナル:

  • 多頭: 急速EMAが下から遅いEMAを突破し,RSIラインが低点から50を超えると多頭
  • 空頭: 速いEMAが上から下を通過し,RSIラインが高点から下まで50を突破すると空頭
  • ADX >25で余分な空き時間しか取れない

終了信号:

  • モバイルストップ,トラッキングストップは150ポイント,ストップは400ポイント
  • 新信号が出たとき,平仓した.
  • 金曜の夜に全部クリアする

この戦略は,均線交差,RSI超買い超売,ADXトレンド判断指標を集約して,より厳格な入場機構を形成し,トレンド生成後に順位を付け,ストップロスを追跡して利益をロックし,短期トレンドを効果的に捕捉します.

優位分析

この戦略の利点は以下の通りです.

  1. EMAの快慢線交差をベースとしてトレンド判断する.快速線を上方交差した慢線は,看板のトレンドに入ることを示す.下方交差は,下方交差を,トレンドの変化を識別することができます.

  2. RSI指標の判断は,偽の突破信号の一部をフィルターすることができます. RSIは,超買い超売り領域を短期的な調整信号として見,震動市場での無意味な入場を避ける.

  3. ADX指標は,真のトレンドの存在を判断するために使用され,一部のノイズを効果的にフィルターします.ADX値が25以上である場合にのみ取引信号が考慮され,明確なトレンドが存在することを保証します.

  4. モバイルストップとストップの方法により,利潤を最大化し,ストップ保証のリスクを制御し,ストップ距離を150点,ストップ距離を400点で追跡し,トレンドを継続的に追跡することができます.

  5. 毎週金曜日,市場が閉まる前に,すべてのポジションをクリアし,週末のあらゆるリスクを回避し,取引の規則性を維持します.

リスク分析

この戦略には以下のリスクもあります.

  1. EMA均線交差策は偽の突破信号を生じやすく,仮想化は損失をもたらす可能性がある.均線パラメータを適切に調整したり,他の指標にフィルターを加えたりすることができる.

  2. RSI指標は,超買超売り状態を判断するだけで,トレンドの逆転を確認することはできません.ビジュアライゼーションはトレンドを逃すか,逆入場する可能性があります.他の指標との組み合わせで使用するか,パラメータを調整することを考慮することができます.

  3. ADX指標は,トレンドが存在するかどうかを判断するだけで,入場時刻は正確ではない可能性があり,他の判定を加えるか,ADXのフィルタリング条件を下げるかを考慮することができる.

  4. 止損止めの設定は,市場の変化に適応できないほど固定され,異なるパラメータをテストしたり,時間通りに人工介入で調整することができる.

  5. 毎週強制的に平仓を設けるのは,良いトレンド走行機会を逃した可能性があるため,毎日の閉市に調整するか,後期に条件平仓に修正することを考えることができる.

最適化の方向

この戦略は以下の方向から最適化できます.

  1. 異なる均線パラメータの組み合わせをテストして,最適な均線長さを探す.均線傾度判定を導入することができる.

  2. 異なるRSIパラメータを試すか,KDJ指数と組み合わせて,超買超売の判断をさらに最適化します.

  3. ADXパラメータを最適化し,より適切なADXフィルタリング条件を見つけ,入場品質を向上させる.

  4. モバイルストップストップの固定点数とATRダイナミックトラッキングストップの組み合わせを使用するテスト.

  5. 1日間のブレイク・リコール戦略を導入し,トレンドが確認された後に入場し,5分または15分チャートを考慮することができます.

  6. 波動率に基づくポジション管理モジュールを追加し,市場の変動に応じてポジションを動的に調整する.

  7. マシン・ラーニング技術でパラメータを自動的に最適化し,戦略の自主性を実現する.

要約する

この戦略は,全体として非常にシンプルで直接的なトレンド追跡戦略であり,均線交差判断トレンド方向,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)