Rata-rata Tren Bergerak Rekursif Dikombinasikan dengan 123 Strategi Pola Peralihan

Penulis:ChaoZhang, Tanggal: 2024-02-21 16:02:32
Tag:

img

Gambaran umum

Strategi ini menggabungkan Rata-rata Tren Gerak Rekursif dan Pola Reversi 123 menjadi sinyal komposit untuk meningkatkan stabilitas dan profitabilitas.

Prinsip

123 Pola Pembalikan

Bagian ini terinspirasi dari buku How I Tripped My Money in the Futures Market oleh Ulf Jensen. Ini membeli ketika harga penutupan naik selama dua hari berturut-turut dan STO SLOWK 9 hari berada di bawah 50.

Rata-rata Tren Bergerak Rekursif

Teknik ini disebut recursive polynomial fitting. Ini menggunakan harga beberapa hari terakhir dan harga hari ini untuk memprediksi harga besok.

Keuntungan

Strategi gabungan mengeksploitasi kekuatan kedua strategi untuk menghindari keterbatasan satu strategi. Pola 123 Reversal dapat menangkap tren utama ketika pembalikan harga terjadi. Rata-rata Tren Bergerak Rekursif dapat menilai arah pergerakan harga dengan lebih akurat.

Risiko dan Solusi

  • 123 Reversal Pattern dapat menghasilkan sinyal palsu karena fluktuasi harga jangka pendek.
  • Rata-rata Tren Bergerak Rekursif dapat merespons lambat terhadap peristiwa mendadak.
  • Salah satu solusi adalah membuka posisi hanya ketika sinyal ganda muncul, atau mengikuti hanya satu sinyal berdasarkan kondisi pasar.

Petunjuk untuk Peningkatan

  • Uji kombinasi parameter periode yang berbeda untuk menemukan pasangan yang optimal.
  • Memperkenalkan mekanisme stop-loss otomatis.
  • Sesuaikan parameter berdasarkan produk dan lingkungan pasar yang berbeda.
  • Pertimbangkan untuk menggabungkannya dengan strategi atau indikator lain untuk membentuk sistem yang lebih kuat.

Kesimpulan

Strategi ini menggabungkan dua jenis strategi yang berbeda dan menghasilkan sinyal komposit untuk meningkatkan stabilitas. Ini mengeksploitasi kedua keuntungan mereka untuk menangkap titik pembalikan harga dan menilai tren harga di masa depan. Optimasi lebih lanjut dapat menyebabkan kinerja yang lebih baik.


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

Lebih banyak