
La stratégie est un système de suivi de tendance basé sur une croisée de Heikin-Ashi et de moyenne mobile simple (SMA). La stratégie identifie les changements de tendance par une croisée de Heikin-Ashi et d’un SMA de 44 cycles, après une élimination par l’EMA, afin de capturer les principales opportunités de tendance sur le marché. La stratégie a conçu un mécanisme de gestion de position dynamique qui se stabilise automatiquement lorsque les prix sont proches de la moyenne à long terme, pour éviter les risques de choc sur l’ensemble du marché.
La logique centrale de la stratégie comprend trois éléments clés: la conversion de la ligne K traditionnelle en un graphique Heikin-Ashi, pour filtrer le bruit du marché en calculant la moyenne arithmétique des quatre prix à la hausse et à la baisse; le traitement en douceur de Heikin-Ashi avec un EMA à 6 cycles, pour améliorer encore la fiabilité du signal; et enfin la combinaison d’un prix de clôture Heikin-Ashi après l’aplatissement avec un SMA à 44 cycles, pour générer un signal de surenchère et un signal de vide en traversant. Le concept de “marge de position sans position” a également été introduit.
La stratégie, combinée au graphique Heikin-Ashi et au système de courbes SMA, a permis de construire un système de trading robuste de suivi des tendances. Le mécanisme de génération de signaux de la stratégie est parfait, le contrôle des risques est rationnel et convient particulièrement à une utilisation sur des marchés présentant des caractéristiques de tendance évidentes.
/*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)