
La stratégie est un système de trading de retour à la moyenne combinant les bandes de Bollinger et l’indicateur relativement faible RSI. La stratégie détermine le moment de la transaction en identifiant les situations extrêmes où le prix s’écarte de la moyenne et en combinant les signaux de survente et de survente RSI.
La logique centrale de la stratégie est basée sur les caractéristiques de la régression des moyennes des marchés financiers. Dans la mise en œuvre concrète, le moyen moyen moyen de 20 jours est utilisé comme référence, le multiple de la différence standard est de 2,0 pour calculer la bande passante de Brin. Le RSI de 14 jours est également introduit comme indicateur auxiliaire, avec 70 et 30 comme seuils de sur-achat et de survente. La stratégie déclenche un signal de transaction lorsque le prix franchit la bande Brin et que le RSI atteint la limite.
La stratégie a été conçue de manière rationnelle, avec une bonne extensibilité et une bonne adaptabilité. La stabilité et la rentabilité de la stratégie peuvent être encore améliorées grâce à une optimisation et une amélioration continues. Il est recommandé de faire une vérification de retour suffisante avant la négociation en direct et d’ajuster les paramètres en fonction des caractéristiques spécifiques du marché.
/*backtest
start: 2024-11-19 00:00:00
end: 2024-12-18 08:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Mean Reversion Strategy", overlay=true)
// User Inputs
length = input.int(20, title="SMA Length") // Moving Average length
stdDev = input.float(2.0, title="Standard Deviation Multiplier") // Bollinger Band deviation
rsiLength = input.int(14, title="RSI Length") // RSI calculation length
rsiOverbought = input.int(70, title="RSI Overbought Level") // RSI overbought threshold
rsiOversold = input.int(30, title="RSI Oversold Level") // RSI oversold threshold
// Bollinger Bands
sma = ta.sma(close, length) // Calculate the SMA
stdDevValue = ta.stdev(close, length) // Calculate Standard Deviation
upperBand = sma + stdDev * stdDevValue // Upper Bollinger Band
lowerBand = sma - stdDev * stdDevValue // Lower Bollinger Band
// RSI
rsi = ta.rsi(close, rsiLength) // Calculate RSI
// Plot Bollinger Bands
plot(sma, color=color.orange, title="SMA") // Plot SMA
plot(upperBand, color=color.red, title="Upper Bollinger Band") // Plot Upper Band
plot(lowerBand, color=color.green, title="Lower Bollinger Band") // Plot Lower Band
// Plot RSI Levels (Optional)
hline(rsiOverbought, "Overbought Level", color=color.red, linestyle=hline.style_dotted)
hline(rsiOversold, "Oversold Level", color=color.green, linestyle=hline.style_dotted)
// Buy and Sell Conditions
buyCondition = (close < lowerBand) and (rsi < rsiOversold) // Price below Lower Band and RSI Oversold
sellCondition = (close > upperBand) and (rsi > rsiOverbought) // Price above Upper Band and RSI Overbought
// Execute Strategy
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.entry("Sell", strategy.short)
// Optional: Plot Buy/Sell Signals
plotshape(series=buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")
plotshape(series=sellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")