Strategy vault / Mean reversion
Bullish and Bearish Engulfing Strategy Based on Candlestick Patterns
The Bullish and Bearish Engulfing Strategy based on candlestick patterns is a quantitative trading strategy that utilizes specific candlestick formations to determine market trends and make trading decisions. By…

Strategy Overview
The Bullish and Bearish Engulfing Strategy based on candlestick patterns is a quantitative trading strategy that utilizes specific candlestick formations to determine market trends and make trading decisions. By identifying bullish and bearish engulfing patterns, the strategy initiates long or short positions accordingly, aiming to profit from potential trend reversals.
Strategy Principles
The core principle of this strategy lies in recognizing bullish and bearish engulfing patterns within candlestick charts to assess potential changes in market trends. Specifically:
Bullish Engulfing Pattern: This pattern occurs when the current candle's closing price is higher than the previous candle's high, and the current candle's opening price is lower than or equal to the previous candle's close, while the current candle's close is lower than or equal to the previous candle's open. The formation of a bullish engulfing pattern suggests a potential shift from a downtrend to an uptrend.
Bearish Engulfing Pattern: This pattern occurs when the current candle's closing price is lower than the previous candle's low, and the current candle's opening price is higher than or equal to the previous candle's close, while the current candle's close is higher than or equal to the previous candle's open. The formation of a bearish engulfing pattern suggests a potential shift from an uptrend to a downtrend.
When a bullish engulfing pattern is identified, the strategy generates a buy signal to initiate a long position. Conversely, when a bearish engulfing pattern is identified, the strategy generates a sell signal to initiate a short position. Additionally, the strategy incorporates stop-loss and take-profit conditions to manage risk while holding positions.
Strategy Advantages
Simplicity and clarity: The strategy is based on classic candlestick patterns, making it easy to understand and implement.
Wide applicability: Bullish and bearish engulfing patterns have relevance across various markets and asset classes, allowing the strategy to be applied to different trading instruments.
Capturing trend reversals: By identifying engulfing patterns, the strategy aims to effectively capture potential turning points in market trends, entering positions at the early stages of a trend reversal to maximize profit potential.
Strategy Risks
Frequent trading: Due to the relatively high occurrence of engulfing patterns, the strategy may generate frequent trading signals, leading to excessive trading activity and increased transaction costs.
False signals: Not all engulfing patterns reliably indicate trend reversals. Some patterns may produce false signals, causing the strategy to make inaccurate judgments and incur losses.
Trend continuation uncertainty: While engulfing patterns suggest the possibility of a trend reversal, they do not provide insight into the duration of the subsequent trend. Therefore, the strategy faces uncertainty regarding the sustainability of the new trend.
Optimization Directions
Combining with other indicators: Consider integrating engulfing patterns with other technical indicators (e.g., moving averages, RSI) to enhance signal reliability and accuracy.
Parameter optimization: Fine-tune the entry and exit conditions of the strategy, such as adjusting stop-loss and take-profit levels, to improve profitability and risk management capabilities.
Implementing filtering criteria: For specific market conditions (e.g., range-bound markets, significant events), introduce filtering criteria to avoid trading in unfavorable environments.
Summary
The Bullish and Bearish Engulfing Strategy based on candlestick patterns is a relatively straightforward and practical quantitative trading approach. By identifying specific candlestick formations, the strategy aims to capture potential turning points in market trends and enter positions at the early stages of a trend reversal to profit from the ensuing price movement. The strategy's strengths lie in its simplicity, wide applicability, and ability to capture trend reversals. However, it also carries risks such as frequent trading, false signals, and uncertainty regarding trend continuation. To enhance the strategy's performance, consider combining it with other indicators, optimizing parameters, and implementing filtering criteria. Overall, this strategy can serve as a complementary tool, to be used in conjunction with other strategies and analysis methods, providing valuable insights and decision support for traders.
Source Pine Script
/*backtest
start: 2024-02-26 00:00:00
end: 2024-03-27 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Engulfing Strategy", overlay=true)
// Calculate bullish engulfing
bullishEngulfing = close[1] < open[1] and close > open and open <= close[1] and close <= open[1]
// Calculate bearish engulfing
bearishEngulfing = close[1] > open[1] and close < open and open >= close[1] and close >= open[1]
// Entry conditions
if (bullishEngulfing)
strategy.entry("Buy", strategy.long)
if (bearishEngulfing)
strategy.entry("Sell", strategy.short)
// Exit conditions
if (strategy.position_size > 0)
if (close > strategy.position_avg_price)
strategy.close("Buy")
else
strategy.close("Buy")
if (strategy.position_size < 0)
if (close < strategy.position_avg_price)
strategy.close("Sell")
else
strategy.close("Sell")
Published by ChaoZhang on the FMZ strategy square · last modified 2024-03-28. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Bullish-and-Bearish-Engulfing-Strategy-Based-on-Candlestick-Patterns.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- 1 2 3 Pattern Quantitative Trading Strategy with EMAs MACD and 4th Candle ExtensionPine Script · Mean reversion · 1h
- 3 10 Oscillator Profile Flagging StrategyPine Script · Mean reversion · 1d
- A Trend Reversal Strategy Based on Moving Averages Price Patterns and VolumePine Script · Mean reversion · 1d
- ATR and EMA based Dynamic Take Profit and Stop Loss Adaptive StrategyPine Script · Mean reversion · 1h
- Adaptive Mean Reversion Trading Strategy Based on Chande Momentum OscillatorPine Script · Mean reversion · 1d
- Adaptive Moving Average Tracking StrategyPine Script · Mean reversion · 1d