
La stratégie est un système de trading quantitatif à quatre heures basé sur l’indicateur de la ceinture de Brin, combinant une philosophie de trading de rupture de tendance et de retour au cours moyen. La stratégie capture la dynamique du marché par une rupture de la ceinture de Brin sur la voie descendante, tout en exploitant les caractéristiques du retour au cours moyen pour réaliser des bénéfices et en contrôlant le risque par un arrêt de perte.
La logique fondamentale de la stratégie repose sur les éléments clés suivants :
Il s’agit d’une stratégie qui combine le suivi de la tendance et les caractéristiques de la régression des valeurs moyennes de l’indicateur Brin pour atteindre l’objectif d’obtenir des rendements stables dans les marchés en tendance et en turbulence grâce à des conditions d’ouverture de position strictes et à des mesures de contrôle du risque. Le principal avantage de la stratégie réside dans sa logique de négociation claire et son système de contrôle du risque parfait, mais il faut toujours prêter attention à l’optimisation de l’utilisation du levier et des jugements de l’environnement du marché pour améliorer encore la stabilité et la capacité de rendement de la stratégie.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Bollinger 4H Follow", overlay=true, initial_capital=300, commission_type=strategy.commission.percent, commission_value=0.04)
// StartYear = input(2022,"Backtest Start Year")
// StartMonth = input(1,"Backtest Start Month")
// StartDay = input(1,"Backtest Start Day")
// testStart = timestamp(StartYear,StartMonth,StartDay,0,0)
// EndYear = input(2023,"Backtest End Year")
// EndMonth = input(12,"Backtest End Month")
// EndDay = input(31,"Backtest End Day")
// testEnd = timestamp(EndYear,EndMonth,EndDay,0,0)
lev = 3
// Input parameters
length = input.int(20, title="Bollinger Band Length")
mult = input.float(2.0, title="Bollinger Band Multiplier")
// Bollinger Bands calculation
basis = ta.sma(close, length)
upperBand = basis + mult * ta.stdev(close, length)
lowerBand = basis - mult * ta.stdev(close, length)
// Conditions for Open Long
openLongCondition = strategy.position_size == 0 and close > open and (close + open) / 2 > upperBand
// Conditions for Open Short
openShortCondition = strategy.position_size == 0 and close < open and (close + open) / 2 < lowerBand
// Conditions for Close Long
closeLongCondition = strategy.position_size > 0 and strategy.position_size > 0 and (close < upperBand and open < upperBand and close < open)
// Conditions for Close Short
closeShortCondition = strategy.position_size < 0 and strategy.position_size < 0 and (close > lowerBand and open > lowerBand and close > open)
// Long entry
if openLongCondition
strategy.entry("Long", strategy.long, qty=strategy.equity * lev / close)
strategy.exit("Long SL", from_entry="Long", stop=low) // Set Stop-Loss
// Short entry
if openShortCondition
strategy.entry("Short", strategy.short, qty=strategy.equity * lev / close)
strategy.exit("Short SL", from_entry="Short", stop=high) // Set Stop-Loss
// Long exit
if closeLongCondition
strategy.close("Long", comment = "TP")
// Short exit
if closeShortCondition
strategy.close("Short", comment = "TP")
// Plot Bollinger Bands
plot(upperBand, color=color.yellow, title="Upper Band")
plot(lowerBand, color=color.yellow, title="Lower Band")