
Стратегия представляет собой систему отслеживания трендов, основанную на сглаженном графике Heikin-Ashi и пересечении простой скользящей средней (SMA). Стратегия использует сглаженную графику Heikin-Ashi после обработки EMA, чтобы идентифицировать изменения в тренде и пересечение 44-х циклов SMA, чтобы захватить основные трендовые возможности рынка. Стратегия разработала динамический механизм управления позициями, который автоматически сглаживает позиции, когда цена находится на близком расстоянии от долгосрочной средней, чтобы избежать риска колебаний на рынке.
Основная логика стратегии включает в себя три ключевых элемента: первое - преобразование традиционной K-линии в график Heikin-Ashi, чтобы отфильтровать рыночный шум, рассчитывая средние значения четырех цен, которые открывают и закрывают; второе - использование 6-циклической EMA для плавной обработки Heikin-Ashi, что еще больше повышает надежность сигнала; и, наконец, объединение закрывающей цены Heikin-Ashi после плавления с 44-циклической SMA, чтобы создать сигнал плюса и пустоты через верхний проход.
Стратегия, объединенная с графиком Heikin-Ashi и системой SMA, создает прочную торговую систему для отслеживания тенденций. Механизм генерирования сигналов стратегии совершенен, контроль риска разумен и особенно подходит для использования на рынках с заметными тенденционными характеристиками.
/*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)