
Cette stratégie est basée sur l’identification de chandeliers à grande échelle et sur des indicateurs de divergence RSI comme principaux signaux, combinés à un stop loss fixe initial et à un stop loss suiveur dynamique pour former un système de trading complet de suivi des tendances. La stratégie identifie les conditions de marché à grande échelle en comparant la taille du corps du chandelier actuel avec les cinq chandeliers précédents, et utilise la divergence entre le RSI rapide et lent pour confirmer les changements de momentum. Enfin, un mécanisme de double stop-loss est utilisé pour gérer risques et sécuriser les profits.
La stratégie se compose de quatre éléments principaux : 1) Identification des grands chandeliers : déterminer la dynamique significative des prix en comparant les tailles actuelles et précédentes des corps des 5 chandeliers ; 2) Analyse de divergence RSI : utiliser le RSI rapide sur 5 périodes et le RSI lent sur 14 périodes. 3) Initial stop loss - définissez un stop loss fixe de 200 points au moment de l’entrée pour contrôler le risque initial ; 4) Trailing stop loss - activé après que le profit atteigne 200 points, gardez 150 points avec le prix La distance dynamique de suivi du point. La stratégie utilise également l’EMA sur 21 périodes comme filtre de tendance pour aider à déterminer la direction globale du marché.
La stratégie construit un système complet de suivi de tendance en combinant un grand nombre de chandeliers et de divergences RSI, et permet une gestion complète des risques grâce à un mécanisme de double stop-loss. La stratégie est adaptée pour opérer dans un environnement de marché avec des tendances claires et une volatilité élevée, mais les traders doivent ajuster les paramètres en fonction des caractéristiques spécifiques du marché. Grâce aux orientations d’optimisation recommandées, la stabilité et la rentabilité de la stratégie devraient être encore améliorées.
/*backtest
start: 2024-12-17 00:00:00
end: 2025-01-16 00:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=6
strategy('[F][IND] - Big Candle Identifier with RSI Divergence and Advanced Stops', shorttitle = '[F][IND] Big Candle RSI Trail', overlay = true)
// Inputs for the trailing stop and stop loss
trail_start_ticks = input.int(200, "Trailing Start Ticks", tooltip="The number of ticks the price must move in the profitable direction before the trailing stop starts.")
trail_distance_ticks = input.int(150, "Trailing Distance Ticks", tooltip="The distance in ticks between the trailing stop and the price once the trailing stop starts.")
initial_stop_loss_points = input.int(200, "Initial Stop Loss Points", tooltip="The fixed stop loss applied immediately after entering a trade.")
// Tick size based on instrument
tick_size = syminfo.mintick
// Calculate trailing start and distance in price
trail_start_price = trail_start_ticks * tick_size
trail_distance_price = trail_distance_ticks * tick_size
initial_stop_loss_price = initial_stop_loss_points * tick_size
// Identify big candles
body0 = math.abs(close[0] - open[0])
body1 = math.abs(close[1] - open[1])
body2 = math.abs(close[2] - open[2])
body3 = math.abs(close[3] - open[3])
body4 = math.abs(close[4] - open[4])
body5 = math.abs(close[5] - open[5])
bullishBigCandle = body0 > body1 and body0 > body2 and body0 > body3 and body0 > body4 and body0 > body5 and open < close
bearishBigCandle = body0 > body1 and body0 > body2 and body0 > body3 and body0 > body4 and body0 > body5 and open > close
// RSI Divergence
rsi_fast = ta.rsi(close, 5)
rsi_slow = ta.rsi(close, 14)
divergence = rsi_fast - rsi_slow
// Trade Entry Logic
if bullishBigCandle
strategy.entry('Long', strategy.long, stop=low - initial_stop_loss_price)
if bearishBigCandle
strategy.entry('Short', strategy.short, stop=high + initial_stop_loss_price)
// Trailing Stop Logic
var float trail_stop = na
if strategy.position_size > 0 // Long Position
entry_price = strategy.position_avg_price
current_profit = close - entry_price
if current_profit >= trail_start_price
trail_stop := math.max(trail_stop, close - trail_distance_price)
strategy.exit("Trailing Stop Long", "Long", stop=trail_stop)
if strategy.position_size < 0 // Short Position
entry_price = strategy.position_avg_price
current_profit = entry_price - close
if current_profit >= trail_start_price
trail_stop := math.min(trail_stop, close + trail_distance_price)
strategy.exit("Trailing Stop Short", "Short", stop=trail_stop)
// Plotting Trailing Stop
plot(strategy.position_size > 0 ? trail_stop : na, color=color.green, title="Trailing Stop (Long)")
plot(strategy.position_size < 0 ? trail_stop : na, color=color.red, title="Trailing Stop (Short)")
// Plotting RSI Divergence
plot(divergence, color=divergence > 0 ? color.lime : color.red, linewidth=2, title="RSI Divergence")
hline(0)
// Plotting EMA
ema21 = ta.ema(close, 21)
plot(ema21, color=color.blue, title="21 EMA")