Strategi mengikuti tren K-algo

ATR supertrend GANN HEIKIN-ASHI EMA
Tanggal Pembuatan: 2025-08-26 11:23:33 Akhirnya memodifikasi: 2025-08-26 11:23:33
menyalin: 0 Jumlah klik: 288
2
fokus pada
319
Pengikut

Strategi mengikuti tren K-algo Strategi mengikuti tren K-algo

Ini bukan SuperTrend biasa, tetapi pemburu tren untuk penggabungan multidimensi

Jangan tertipu oleh namanya, K-algo trail bukanlah strategi pelacakan ATR yang sederhana. Sistem ini menggabungkan tiga sistem teknologi SuperTrend, Gann Nine-Sided Graph, dan Heikin Ashi yang halus, membentuk kerangka identifikasi tren tiga dimensi.

Heikin Ashi, dengan EMA ganda yang halus, adalah filter sinyal yang sebenarnya.

Inovasi inti dari strategi ini adalah Heikin Ashi yang ditangani dengan EMA 11 siklus ganda. Heikin Ashi tradisional mudah menghasilkan sinyal palsu, tetapi setelah dua putaran EMA, kualitas sinyal meningkat secara signifikan.

1.7:2.5:3.0 Keuntungan dan Kerugian dari Desain yang Menunjukkan Tingkat Profesional

Stop loss diatur langsung menggunakan garis SuperTrend, yang merupakan solusi stop loss yang paling masuk akal. Lebih menarik lagi adalah desain stop loss tiga tingkat: 1,7 kali, 2,5 kali, dan 3,0 kali jarak risiko. Stop loss bertahap ini menjamin keuntungan dasar, tetapi meninggalkan ruang yang cukup untuk situasi tren.

Penambahan Gann Nine-Side Graph Bukan Dekorasi, Tapi Dukungan Penting

Perhitungan Gann Square of 9 dalam kode tampaknya sederhana, tetapi sangat berguna. Dengan menghitung akar kuadrat dari harga saat ini, titik-titik resistensi dukungan atas dan bawah memberikan titik-titik harga tambahan untuk strategi. Meskipun logika master strategi tidak menggunakan posisi ini secara langsung, mereka memberikan referensi penting untuk penyesuaian manual dan penilaian risiko.

Berlaku untuk tren jangka menengah dan panjang, kinerja pasar yang bergejolak

Strategi ini bekerja dengan baik di pasar tren sepihak, terutama varietas yang lebih berfluktuasi seperti cryptocurrency dan futures indeks saham. Namun, harus jelas: Dalam situasi yang berfluktuasi horizontal, sering terjadi false breakout dapat menyebabkan kerugian kecil berturut-turut.

Petunjuk Risiko: Pemantauan Sejarah Tidak Menunjukkan Hasil Masa Depan

Setiap strategi kuantitatif memiliki risiko kerugian, dan strategi ini tidak terkecuali. Meskipun data retrospektif menunjukkan kinerja yang baik setelah pengembalian yang disesuaikan dengan risiko, kerugian berturut-turut masih mungkin terjadi dalam perdagangan aktual. Disarankan untuk secara ketat mengendalikan posisi tunggal tidak lebih dari 2% dari total modal, dan setelah 3 kali kerugian berturut-turut, trading ditangguhkan, dan situasi pasar dievaluasi ulang.

Kode Sumber Strategi
/*backtest
start: 2025-06-11 00:00:00
end: 2025-08-25 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/

//@version=5
strategy('K-algo trail', overlay=true)
// ===== INPUTS =====
Periods = input(title='ATR Period', defval=10)
src = input(hl2, title='Source')
Multiplier = input.float(title='ATR Multiplier', step=0.1, defval=3)
changeATR = input(title='Change ATR Calculation Method ?', defval=true)
showsignals = input(title='Show Buy/Sell Signals ?', defval=true)
// ===== ATR & SUPER TREND (K-TREND) CALCULATION =====
atr2 = ta.sma(ta.tr, Periods)
atr = changeATR ? ta.atr(Periods) : atr2
up = src - Multiplier * atr
up1 = nz(up[1], up)
up := close[1] > up1 ? math.max(up, up1) : up
dn = src + Multiplier * atr
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? math.min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
// Plot SuperTrend
upPlot = plot(trend == 1 ? up : na, title='Up Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0))
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title='UpTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 0))
dnPlot = plot(trend == 1 ? na : dn, title='Down Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.red, 0))
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title='DownTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.red, 0))
// ===== GANN SQUARE OF 9 =====
normalise_squareRootCurrentClose = math.floor(math.sqrt(close))
upperGannLevel_1 = (normalise_squareRootCurrentClose + 1) * (normalise_squareRootCurrentClose + 1)
upperGannLevel_2 = (normalise_squareRootCurrentClose + 2) * (normalise_squareRootCurrentClose + 2)
zeroGannLevel = normalise_squareRootCurrentClose * normalise_squareRootCurrentClose
lowerGannLevel_1 = (normalise_squareRootCurrentClose - 1) * (normalise_squareRootCurrentClose - 1)
lowerGannLevel_2 = (normalise_squareRootCurrentClose - 2) * (normalise_squareRootCurrentClose - 2)
// ===== SMOOTHED HEIKIN ASHI CALCULATION =====
ma1_len = input.int(title='MA1', defval=11, minval=1, maxval=100, step=1)
ma2_len = input.int(title='MA2', defval=11, minval=1, maxval=100, step=1)
// First Smoothing (11,11)
o = ta.ema(open, ma1_len)
c = ta.ema(close, ma1_len)
h = ta.ema(high, ma1_len)
l = ta.ema(low, ma1_len)
ha_t = ticker.heikinashi(syminfo.tickerid)
ha_o = request.security(ha_t, timeframe.period, o)
ha_c = request.security(ha_t, timeframe.period, c)
ha_h = request.security(ha_t, timeframe.period, h)
ha_l = request.security(ha_t, timeframe.period, l)
o2 = ta.ema(ha_o, ma2_len)
c2 = ta.ema(ha_c, ma2_len)
h2 = ta.ema(ha_h, ma2_len)
l2 = ta.ema(ha_l, ma2_len)
ha_col = o2 > c2 ? color.orange : color.blue
plotcandle(o2, h2, l2, c2, title='Heikin Ashi Smoothed', color=ha_col, wickcolor=#00000000)
// ===== STRATEGY LOGIC =====
// Final Combined Long Condition
longCondition = (o2 < c2 and trend == 1) and barstate.isconfirmed
// Final Combined Short Condition
shortCondition = (o2 > c2 and trend == -1) and barstate.isconfirmed
// ===== STRATEGY EXECUTION =====
if longCondition
    SL = math.round(up, 2)
    range_1 = math.abs(close - SL)
    TARGET1 = close + range_1 * 1.7
    TARGET2 = close + range_1 * 2.5
    TARGET3 = close + range_1 * 3.0
    strategy.entry('BUY', strategy.long)
    strategy.exit('BUY T1', 'BUY', qty=1, limit=TARGET1)
    strategy.exit('BUY T2', 'BUY', qty=1, limit=TARGET2)
    strategy.exit('BUY T3', 'BUY', qty=1, limit=TARGET3)
    strategy.exit('BUY SL', 'BUY', stop=SL)
if shortCondition
    SL = math.round(dn, 2)
    range_2 = math.abs(close - SL)
    TARGET1 = close - range_2 * 1.7
    TARGET2 = close - range_2 * 2.5
    TARGET3 = close - range_2 * 3.0
    strategy.entry('SELL', strategy.short)
    strategy.exit('SELL T1', 'SELL', qty=1, limit=TARGET1)
    strategy.exit('SELL T2', 'SELL', qty=1, limit=TARGET2)
    strategy.exit('SELL T3', 'SELL', qty=1, limit=TARGET3)
    strategy.exit('SELL SL', 'SELL', stop=SL)
// Plot entry signals
plotshape(longCondition ? close : na, title='Buy', text='BUY', location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0))
plotshape(shortCondition ? close : na, title='Sell', text='SELL', location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0))