
Cette stratégie est un système de suivi de tendance dynamique basé sur des signaux de croisement de moyennes mobiles doubles. Il identifie les changements de tendance du marché grâce au croisement de la moyenne mobile exponentielle à court terme sur 20 jours (EMA) et de la moyenne mobile exponentielle à long terme sur 50 jours ( EMA) et exécute automatiquement les opérations d’achat et de vente. . La stratégie adopte une méthode d’analyse technique mature, combinant les caractéristiques de suivi des tendances et de gestion dynamique des positions, et convient aux environnements de marché avec une plus grande volatilité.
La logique fondamentale de la stratégie repose sur les éléments clés suivants :
Cette stratégie est une mise en œuvre moderne d’un système de suivi des tendances classique. Grâce au trading programmatique, la stratégie traditionnelle de croisement à double moyenne mobile est systématisée et standardisée. Bien qu’il existe certains risques inhérents, la stratégie a de bonnes perspectives d’application grâce à une optimisation et une amélioration continues. Il est recommandé d’effectuer une optimisation suffisante des paramètres et une vérification des backtests avant l’utilisation réelle.
/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-04 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Crossover Buy/Sell Signals", overlay=true)
// Input parameters for EMAs
emaShortLength = input.int(20, title="Short EMA Length")
emaLongLength = input.int(50, title="Long EMA Length")
// Calculating EMAs
emaShort = ta.ema(close, emaShortLength)
emaLong = ta.ema(close, emaLongLength)
// Plotting EMA crossover lines
plot(emaShort, color=color.green, title="20 EMA")
plot(emaLong, color=color.red, title="50 EMA")
// Buy and Sell signal logic
longCondition = ta.crossover(emaShort, emaLong)
exitLongCondition = ta.crossunder(emaShort, emaLong)
shortCondition = ta.crossunder(emaShort, emaLong)
exitShortCondition = ta.crossover(emaShort, emaLong)
// Plot buy and sell signals on the chart
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")
plotshape(series=exitLongCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Exit")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")
plotshape(series=exitShortCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Exit")
// Backtesting strategy logic
var float entryPrice = na
var int position = 0 // 1 for long, -1 for short, 0 for no position
if (longCondition and position == 0)
entryPrice := close
position := 1
if (shortCondition and position == 0)
entryPrice := close
position := -1
if (exitLongCondition and position == 1)
strategy.exit("Exit Long", from_entry="Long", limit=close)
position := 0
if (exitShortCondition and position == -1)
strategy.exit("Exit Short", from_entry="Short", limit=close)
position := 0
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)