Skip to main content

using the engulfing candle algo

the engulfing candle algo trades bullish and bearish engulfing patterns automatically — entering on the candle close, with customizable take-profit, stop-loss, and size filters per day of week.

Written by Brad
Updated over a week ago

summary: the engulfing candle algo trades bullish and bearish engulfing patterns automatically — entering on the candle close, with customizable take-profit, stop-loss, and size filters per day of week.

how it works

TradingView fires alerts when an engulfing candle pattern completes. edgeful picks up those alerts and routes the trade to your broker. you can also use the indicator visually and manage entries yourself — automation isn't required.

the algo enters a trade as soon as the engulfing candle closes. a bullish engulfing (current candle's body fully engulfs the previous candle's body to the upside) triggers a long entry. a bearish engulfing (current candle's body fully engulfs the previous candle's body to the downside) triggers a short entry.

the engulfing candle algo executes 1 trade per signal — it acts on the engulfing pattern the moment that candle closes.

understanding engulfing candles

an engulfing candle is when the current candle's body completely wraps around the previous candle's body. it's one of the most well-known candlestick reversal patterns — and edgeful's reports show you exactly how often they lead to follow-through.

bullish engulfing: the current candle opens below and closes above the previous candle's body. this signals potential upside momentum.

bearish engulfing: the current candle opens above and closes below the previous candle's body. this signals potential downside momentum.

the size of the engulfing candle matters. a candle that barely engulfs the prior body is a weaker signal than one that engulfs it by a significant margin — and that's exactly what the size filters are for.

customizing the engulfing candle algo

the key parameters to dial in are the take-profit, stop-loss, size filters, and directional controls.

algo-wide settings:

  • maximum loss — caps your loss per trade. this is your risk control — set it based on your account size and risk tolerance.

  • session — which market session to monitor for engulfing patterns. for futures, this is typically the NY session.

day-of-week specific settings:

  • take-profit — where the algo closes the trade in profit. you can set different TP levels for each day of the week based on how your instrument behaves.

  • stop-loss — where the algo exits at a loss. customize per day of week to account for varying volatility patterns.

  • min engulfing size % — the minimum size of the engulfing candle relative to the previous candle. filters out weak, barely-engulfing patterns that don't have strong follow-through. inclusive — an engulfing candle equal to your min value will trigger.

  • max engulfing size % — the maximum size. filters out extremely large engulfing candles that may indicate overextension rather than a clean reversal. exclusive — an engulfing candle equal to your max value will NOT trigger. see filter thresholds — how min and max work in the troubleshooting section below.

  • take long — enable or disable long entries (bullish engulfing) for each day of the week.

  • take short — enable or disable short entries (bearish engulfing) for each day of the week.

the day-of-week controls are where the real customization lives. you might find that bullish engulfing patterns on NQ work well on Mondays and Tuesdays but not Fridays — the data will show you. turn off the days that don't perform.

algo templates

a great starting point is to use one of the edgeful algo templates — once you select a template, we recommend continuing to optimize from there.

using the engulfing candle reports to validate your settings

before locking in any settings, check them against the data.

the engulfing candles report on edgeful shows you historically how often engulfing patterns lead to follow-through — and how far price typically moves after the pattern completes. pull up the report for your instrument, set the session to NY, and use a 6-month lookback as your baseline.

the report has several variants that help you fine-tune:

  • standard — overall engulfing pattern performance. start here to see the baseline numbers.

  • by size — breaks down performance by the size of the engulfing candle. this is directly tied to your min/max engulfing size % settings — use it to find the sweet spot where the pattern has the strongest follow-through.

  • by daily candle — shows how engulfing patterns perform depending on the prior day's candle. useful for understanding context — does a bullish engulfing after a red day perform differently than after a green day?

  • by R:R — performance broken down by risk-to-reward ratio. helps you validate whether your TP and SL settings are realistic based on historical data.

the by-size report is especially important for this algo. if engulfing candles between 0.5% and 1.5% of the prior candle's range show strong follow-through but anything above 2% drops off — that tells you exactly where to set your min and max size filters.

setting up in TradingView

step 1: open your chart in TradingView with your preferred timeframe. the algo uses whatever chart timeframe you're on — so a 5-minute chart means the algo is looking for engulfing patterns on 5-minute candles.

step 2: add the edgeful engulfing candle strategy indicator to your chart. you'll see it under invite-only scripts if you've already connected your TradingView username in edgeful.

step 3: customize your parameters — session, max loss, TP, SL, and size filters. use the algo templates as a starting point if you're not sure where to begin.

step 4: run a backtest in TradingView's Strategy Tester. look at win rate, profit factor, and max drawdown over 6+ months. adjust your settings based on the results.

step 5: once you're satisfied with the backtest, set up a TradingView alert on the strategy to enable automated execution through edgeful — or use the visual signals to trade manually.

configuring contract symbols

for live trading: use the current front-month contract symbol. that's what your broker executes on, and it keeps your alerts in sync with what's actually tradable.

for backtesting and optimization: use continuous contract symbols (e.g. ES1!, NQ1!). they give you uninterrupted historical data — which is what you need for accurate testing.

when you switch contracts, you'll need to reapply the algo and update your TradingView alerts to match.

important: contract mismatch is the #1 reason algo trades fail to trigger. if you alert on one contract in TradingView but your broker has a different one set up, trades won't execute (the exception is ProjectX). always use the current front-month contract with the highest volume — check both TradingView and your broker to confirm they match exactly.

troubleshooting

no trade trigger? walk through these in order:

  1. verify visualization: can you see the entry, TP, and SL on your chart? if not, the algo didn't detect a valid engulfing pattern.

  2. check size filters: if your min engulfing size % is set too high or your max is too low, valid patterns get filtered out. widen the range and see if trades start appearing. if the size of your engulfing candle is exactly at the edge of your range, read filter thresholds — how min and max work below — the max is exclusive, not inclusive.

  3. check directional filters: make sure "take long" and "take short" are enabled for the current day of week. if both are off, no trades will fire.

  4. validate alerts: confirm the alert is actually configured to trigger automation — not just a notification.

  5. check the session: if the engulfing pattern formed outside your configured session window, the algo ignores it.

always test changes in simulation first before pushing them to live.

filter thresholds — how min and max work

this one trips people up — and it's the kind of thing you can stare at for an hour before you spot it. so here's the rule, clearly:

  • min engulfing size % is inclusive — an engulfing candle equal to your min value WILL trigger.

  • max engulfing size % is exclusive — an engulfing candle equal to your max value will NOT trigger.

in math terms: min ≤ engulfing size < max.

a concrete example. say you set min engulfing size % = 1% and max engulfing size % = 3%. here's what triggers and what doesn't:

engulfing size

triggers?

why

0.9%

no

below min

1.0%

yes

min is inclusive

2.0%

yes

inside the range

2.9%

yes

inside the range

3.0%

no

max is exclusive

3.1%

no

above max

why it works this way. if you stack filters — say, one algo for 1%-3% engulfings and another for 3%-5% engulfings — an exclusive max prevents the same candle from triggering both. no double-counting. clean buckets.

the fix if it's costing you trades. if the engulfing candle you want to catch is sitting right at your max value, bump the max up slightly. a max of 3.01% will catch a 3.0% engulfing. a max of 3% will not.

this same rule applies across all edgeful algos with min/max filters — gap fill, engulfing candle, ORB, and IB. min inclusive, max exclusive, every time.

regaining algo access

if you've lost access to the engulfing candle algo in TradingView, here's how to restore it:

  1. go to the algos section in edgeful

  2. click the TradingView logo or "algo access" button

  3. close TradingView completely before submitting

  4. reopen TradingView — the engulfing candle strategy should be visible and accessible

backtesting the engulfing candle algo

test your configuration in TradingView's Strategy Tester over 12+ months. pay attention to win rate, profit factor, and max drawdown.

a few things to look at specifically:

  • compare performance with different size filters. tighter filters (larger min %) typically improve win rate but reduce trade frequency.

  • compare long-only vs. short-only vs. both. some instruments show stronger engulfing follow-through in one direction.

  • compare day-of-week performance. disable the weakest days and see how overall numbers improve.

the goal is finding settings where the algo consistently profits on your instrument — not settings that look good on one specific month. if it works across 6-month and 12-month backtests, you've got something solid.

note that backtest results may reflect optimized settings — not default values. always validate that your live settings match what you tested.

related articles

Did this answer your question?