
Strategi ini adalah sistem pelacakan tren yang didasarkan pada Heikin-Ashi chart yang diluruskan dan crossover SMA. Strategi ini mengidentifikasi perubahan tren melalui Heikin-Ashi chart setelah EMA diluruskan dan crossover SMA periode 44, sehingga menangkap peluang tren utama di pasar. Strategi ini merancang mekanisme manajemen posisi yang dinamis, yang secara otomatis melangsungkan posisi ketika harga dekat dengan garis rata-rata jangka panjang, untuk menghindari risiko gejolak di seluruh pasar.
Logika inti dari strategi ini terdiri dari tiga elemen kunci: pertama adalah mengubah garis K tradisional ke dalam grafik Heikin-Ashi, untuk menyaring kebisingan pasar dengan menghitung rata-rata aritmatika dari empat harga harga tinggi dan rendah; kedua, menggunakan 6 siklus EMA untuk pengolahan halus Heikin-Ashi, untuk meningkatkan keandalan sinyal lebih lanjut; dan terakhir, menggabungkan harga penutupan Heikin-Ashi setelah perataan dengan 44 siklus SMA, untuk menghasilkan sinyal melakukan lebih banyak melalui atas, untuk menghasilkan sinyal kosong melalui bawah.
Strategi ini, dengan menggabungkan grafik Heikin-Ashi dan sistem garis rata SMA, membangun sistem perdagangan pelacakan tren yang solid. Mekanisme pembuatan sinyal strategi ini sempurna, kontrol risiko masuk akal, dan sangat cocok untuk digunakan di pasar dengan karakteristik tren yang jelas.
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Smoothed Heikin Ashi with SMA Strategy", overlay=true)
// Input parameters for SMAs
s1 = input.int(11, title="Short SMA Period")
s2 = input.int(44, title="Long SMA Period")
noPositionThreshold = input.float(0.001, title="No Position Threshold", step=0.0001)
// Calculate the original Heikin-Ashi values
haClose = (open + high + low + close) / 4
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
haHigh = math.max(high, math.max(haOpen, haClose))
haLow = math.min(low, math.min(haOpen, haClose))
// Smoothing using exponential moving averages
smoothLength = input.int(6, title="Smoothing Length")
smoothedHaClose = ta.ema(haClose, smoothLength)
smoothedHaOpen = ta.ema(haOpen, smoothLength)
smoothedHaHigh = ta.ema(haHigh, smoothLength)
smoothedHaLow = ta.ema(haLow, smoothLength)
// Calculate SMAs
smaShort = ta.sma(close, s1)
smaLong = ta.sma(close, s2)
// Plotting the smoothed Heikin-Ashi values
plotcandle(smoothedHaOpen, smoothedHaHigh, smoothedHaLow, smoothedHaClose, color=(smoothedHaClose >= smoothedHaOpen ? color.green : color.red), title="Smoothed Heikin Ashi")
plot(smaShort, color=color.blue, title="SMA Short")
plot(smaLong, color=color.red, title="SMA Long")
// Generate buy/sell signals based on SHA crossing 44 SMA
longCondition = ta.crossover(smoothedHaClose, smaLong)
shortCondition = ta.crossunder(smoothedHaClose, smaLong)
noPositionCondition = math.abs(smoothedHaClose - smaLong) < noPositionThreshold
// Strategy logic
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
if (noPositionCondition and strategy.position_size != 0)
strategy.close_all("No Position")
// Plot buy/sell signals
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", size=size.small)
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", size=size.small)
plotshape(series=noPositionCondition and strategy.position_size != 0, location=location.belowbar, color=color.yellow, style=shape.labeldown, text="EXIT", size=size.small)