HLHB Trend-Catcher Strategi

Penulis:ChaoZhang, Tanggal: 2023-09-28 11:44:04
Tag:

Gambaran umum

Strategi ini bertujuan untuk menangkap tren forex jangka pendek dengan menggunakan EMA crossover dan RSI sebagai sinyal perdagangan, dengan filter ADX untuk memasuki perdagangan, dan trailing stop loss untuk mengunci keuntungan.

Logika Strategi

Strategi ini didasarkan pada indikator dan kondisi berikut untuk menghasilkan sinyal perdagangan:

  • EMA cepat 5 periode: garis biru
  • EMA lambat 10 periode: garis merah
  • RSI 10 periode yang diterapkan pada harga median (H+L)/2
  • ADX periode 14

Sinyal masuk

  • Long: ketika EMA cepat melintasi di atas EMA lambat dari bawah dan RSI melintasi di atas 50 dari bawah
  • Pendek: ketika EMA cepat melintasi di bawah EMA lambat dari atas dan RSI melintasi di bawah 50 dari atas
  • Hanya menerima sinyal ketika ADX > 25

Sinyal keluar:

  • Gunakan stop loss trailing, 150 pips trail distance dan 400 pips take profit
  • Tutup perdagangan ketika sinyal baru terjadi
  • Tutup semua perdagangan sebelum akhir minggu

Strategi ini menggabungkan EMA crossover, RSI overbought/oversold dan kekuatan tren ADX untuk menciptakan aturan masuk yang solid.

Analisis Keuntungan

Strategi ini memiliki keuntungan berikut:

  1. EMA crossover untuk arah tren. upward cross menunjukkan uptrend sementara downward cross downtrend. dapat mengidentifikasi perubahan tren.

  2. Menambahkan RSI menyaring beberapa sinyal breakout palsu. zona oversold / overbought menunjukkan penurunan jangka pendek dan menghindari entri yang tidak perlu di pasar kisaran.

  3. ADX untuk memastikan keberadaan tren yang benar. Hanya mempertimbangkan sinyal perdagangan ketika ADX > 25, menjamin tren yang kuat.

  4. Menjaga stop loss dan mengambil keuntungan membiarkan keuntungan berjalan sementara mengendalikan risiko. 150 pip jarak jejak dan 400 pips target keuntungan terus naik tren.

  5. Penutupan semua posisi sebelum akhir pekan menghindari risiko akhir pekan dan memberlakukan regulasi perdagangan.

Analisis Risiko

Strategi ini juga memiliki risiko berikut:

  1. Sistem EMA crossover rentan terhadap sinyal pecah palsu, yang menyebabkan kerugian.

  2. RSI hanya mengidentifikasi tingkat overbought / oversold, bukan pembalikan tren.

  3. ADX hanya menilai keberadaan tren, waktu masuk mungkin tidak. tambahkan aturan lain atau menurunkan ambang ADX.

  4. Tingkat stop loss dan take profit yang tetap mungkin tidak beradaptasi dengan perubahan pasar.

  5. Penutupan mingguan yang dipaksa bisa kehilangan peluang tren yang baik.

Arahan Optimasi

Strategi dapat dioptimalkan dalam aspek berikut:

  1. Uji kombinasi EMA yang berbeda untuk menemukan panjang yang optimal. Pertimbangkan kemiringan untuk kekuatan tren tambahan.

  2. Cobalah parameter RSI yang berbeda atau gabungkan dengan KDJ untuk penilaian overbought/oversold yang lebih baik.

  3. Mengoptimalkan parameter ADX untuk penyaringan yang lebih cocok dan kualitas entri yang lebih tinggi.

  4. Kombinasi pengujian berhenti tetap dan trailing dinamis berbasis ATR.

  5. Tambahkan entri pullback intraday setelah konfirmasi tren, seperti jangka waktu yang lebih rendah.

  6. Memperkenalkan ukuran posisi berdasarkan volatilitas untuk penyesuaian dinamis berdasarkan volatilitas pasar.

  7. Jelajahi teknik pembelajaran mesin untuk mengoptimalkan parameter otomatis untuk kemampuan beradaptasi.

Ringkasan

Optimasi terutama melibatkan menemukan kombinasi indikator yang lebih baik untuk fleksibilitas, dan menambahkan ukuran posisi dinamis. Logika ini memiliki merit tetapi masih membutuhkan pengujian dan optimasi lebih lanjut untuk aplikasi praktis.


/*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)

Lebih banyak