
Il s’agit d’une stratégie de trading quantitative basée sur le modèle englobant, qui se négocie en identifiant le modèle englobant linéaire de tendance multi-période qui apparaît sur le marché. Le cœur de la stratégie consiste à capturer les signaux de renversement de prix, à combiner la période de détention et le contrôle des risques et à obtenir des résultats de trading solides. La stratégie est applicable à tous les marchés et à toutes les périodes et présente une forte universalité.
La stratégie est basée sur le trading du modèle englobant dans le modèle de chandelier. Lorsqu’un modèle d’engloutissement haussier se produit (un chandelier noir plus petit suivi d’un chandelier blanc plus grand engloutissant complètement le chandelier noir plus petit), il génère un signal d’achat dans une tendance à la baisse ; lorsqu’un modèle d’engloutissement baissier se produit (un chandelier noir plus petit suivi d’un chandelier blanc plus grand (un chandelier engloutissant complètement le plus petit chandelier noir), il génère un signal d’achat dans une tendance haussière. Un signal de vente est généré. La stratégie définit la période de détention par paramétrage et ferme automatiquement la position après la période spécifiée pour éviter les risques liés à une détention excessive.
Cette stratégie utilise une approche systématique pour saisir les opportunités de modèles englobants sur le marché et la combine avec une gestion de position paramétrée pour obtenir un trading à risque contrôlé. La stratégie est très pratique et adaptable, mais les traders doivent encore l’optimiser et l’ajuster en fonction des caractéristiques spécifiques du marché. Il est recommandé de combiner d’autres indicateurs techniques et mesures de contrôle des risques pour améliorer la stabilité et la fiabilité de la stratégie.
/*backtest
start: 2024-12-06 00:00:00
end: 2025-01-04 08:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("Engulfing Candlestick Strategy", overlay=true)
// Input parameters
bull_color = input.color(color.new(color.green, 0), title="Bullish Engulfing Highlight")
bear_color = input.color(color.new(color.red, 0), title="Bearish Engulfing Highlight")
hold_periods = input.int(17, title="Hold Periods", minval=1) // How many bars to hold the position
// Input for selecting the pattern (Bullish or Bearish Engulfing)
pattern_type = input.string("Bullish Engulfing", title="Engulfing Pattern", options=["Bullish Engulfing", "Bearish Engulfing"])
// Input for selecting the trade type (Long or Short)
trade_type = input.string("Long", title="Trade Type", options=["Long", "Short"])
// Conditions for Bullish Engulfing
bullish_engulfing = close > open and open < close[1] and close > open[1] and open[1] > close[1]
// Conditions for Bearish Engulfing
bearish_engulfing = close < open and open > close[1] and close < open[1] and open[1] < close[1]
// Declare the entry condition variable
var bool entry_condition = false // Set initial value to 'false'
// Entry logic based on selected pattern and trade type
if pattern_type == "Bullish Engulfing"
entry_condition := bullish_engulfing
else
entry_condition := bearish_engulfing
// Execute the entry based on the selected trade type
if entry_condition
if trade_type == "Long"
strategy.entry("Long", strategy.long)
else
strategy.entry("Short", strategy.short)
// Close position after specified number of bars
if strategy.position_size != 0 and bar_index - strategy.opentrades.entry_bar_index(0) >= hold_periods
strategy.close("Long")
strategy.close("Short")
// Highlight Bullish Engulfing Candles (Background Color)
bgcolor(bullish_engulfing and pattern_type == "Bullish Engulfing" ? color.new(bull_color, 80) : na, title="Bullish Engulfing Background")
// Highlight Bearish Engulfing Candles (Background Color)
bgcolor(bearish_engulfing and pattern_type == "Bearish Engulfing" ? color.new(bear_color, 80) : na, title="Bearish Engulfing Background")