
La stratégie utilise une moyenne mobile indicielle (EMA) et un indice de relative faiblesse (RSI) de trois périodes différentes pour juger de la tendance du marché et des signaux de négociation. Elle génère un signal d’achat lorsque le prix franchit l’EMA de 200 jours et que le RSI est supérieur à 50, et un signal de vente lorsque le prix tombe sous l’EMA de 200 jours et que le RSI est inférieur à 50.
Cette stratégie permet de capturer des signaux de trading à moyen et long terme relativement clairs via des signaux de négociation entre les EMAs et les zones de force du RSI. Cependant, elle se comporte généralement au début d’un revirement de tendance et dans un marché instable et convient globalement aux marchés tendanciels.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Lexi Supreme", overlay=true)
// Calculate EMA 200
ema200 = ta.ema(close, 200)
// Calculate EMA 50
ema50 = ta.ema(close, 50)
// Calculate EMA 21
ema21 = ta.ema(close, 21)
// Calculate RSI
rsiValue = ta.rsi(close, 14)
// Buy condition: RSI above 50 and price crosses above EMA 200
buyCondition = ta.crossover(close, ema200) and rsiValue > 50
// Sell condition: RSI below 50 and price crosses below EMA 200
sellCondition = ta.crossunder(close, ema200) and rsiValue < 50
// Position Size (1% of account balance)
positionSize = 1
// Stop Loss and Take Profit values for buy trades
stopLossBuy = ema200 - 0.00050
takeProfitBuy = 0.00100
// Stop Loss and Take Profit values for sell trades
stopLossSell = ema200 + 0.00050
takeProfitSell = 0.00100
// Plot EMA 200 line in blue
plot(ema200, color=color.blue, title="EMA 200")
// Plot EMA 50 line in red
plot(ema50, color=color.red, title="EMA 50")
// Plot EMA 21 line in green
plot(ema21, color=color.green, title="EMA 21")
// Plot buy entry points in yellow
plotshape(series=buyCondition, title="Buy Signal", color=color.yellow, style=shape.triangleup, location=location.belowbar, size=size.small)
// Plot sell entry points in white
plotshape(series=sellCondition, title="Sell Signal", color=color.white, style=shape.triangledown, location=location.abovebar, size=size.small)
// Strategy entry and exit conditions with position size, stop loss, and take profit for buy trades
if (buyCondition)
strategy.entry("Buy", strategy.long, qty=positionSize)
strategy.exit("Take Profit/Stop Loss Buy", from_entry="Buy", stop=stopLossBuy, limit=close + takeProfitBuy)
// Strategy entry and exit conditions with position size, stop loss, and take profit for sell trades
if (sellCondition)
strategy.entry("Sell", strategy.short, qty=positionSize)
strategy.exit("Take Profit/Stop Loss Sell", from_entry="Sell", stop=stopLossSell, limit=close - takeProfitSell)