Eliminate trading delays by automating TradingView candlestick recognition. Use Pine Script and webhooks to trigger instant, filtered trades from key patterns.

TradingView candlestick pattern recognition automation uses Pine Script indicators or built-in pattern detection to identify formations like engulfing bars, doji, and hammer patterns, then fires alerts through webhooks to execute trades automatically. This removes the need to watch charts manually and eliminates the delay between spotting a pattern and placing an order.
TradingView candlestick pattern recognition automation is the process of using Pine Script code or built-in indicators to detect specific candlestick formations on a chart and automatically trigger trading actions. Instead of staring at charts waiting for a hammer or engulfing pattern to form, the code watches for you and sends a webhook alert when conditions match.
Candlestick Pattern Recognition: The automated identification of specific price bar formations (like doji, engulfing, or morning star patterns) using programmatic rules based on open, high, low, and close price relationships. For futures traders, this means pattern-based entries can fire without manual chart monitoring.
Here's how the chain works. Your Pine Script indicator runs on a TradingView chart. It checks each new candle against your pattern definitions. When a match occurs, TradingView fires an alert. That alert sends a webhook payload to an automation platform like ClearEdge Trading, which converts it into a broker order. The whole process from pattern completion to order submission takes milliseconds.
The appeal is straightforward. Candlestick patterns are visual by nature, and humans are inconsistent at spotting them in real time, especially across multiple charts and timeframes. Automation doesn't get tired, doesn't miss patterns during bathroom breaks, and doesn't hesitate when a textbook engulfing bar shows up at a support level during the ES futures open at 9:30 AM ET.
Pine Script detects candlestick patterns by comparing mathematical relationships between open, high, low, and close values across one or more bars. Each pattern has specific rules: a bullish engulfing requires the current bar's close to be above the previous bar's open, the current open below the previous close, and the previous bar to be bearish. Pine Script translates these visual rules into conditional logic.
Pine Script: TradingView's proprietary scripting language used to create custom indicators, strategies, and alert conditions. Pine Script coding allows traders to define exact pattern recognition rules that run on TradingView's servers.
A basic bullish engulfing detection in Pine Script v5 looks something like this conceptually: you check if the previous candle closed lower than it opened (bearish), the current candle opened below the previous close, and the current candle closed above the previous open. When all three conditions are true, you have your pattern. You then plot a signal or trigger an alert condition.
TradingView also has a built-in "All Candlestick Patterns" indicator that detects around 30 formations without any Pine Script coding. It works, but you can't customize the detection rules, add filters, or connect it easily to webhook-based automation. For serious signal generation, writing your own indicator or modifying an open-source one gives you more control over what triggers an alert and what the alert message format includes.
The strategy tester in TradingView lets you backtest pattern-based entries before you automate them. Run your pattern detector as a strategy (using strategy.entry instead of just plotting), and TradingView will show you historical win rate, average trade, and drawdown. This step matters. A pattern that looks good on a few examples might have a 42% win rate over 500 trades, which changes how you'd size positions and set stops.
Single-bar patterns like hammer, shooting star, and doji are the easiest to automate but produce the most false signals. Multi-bar patterns like engulfing, morning star, and three white soldiers are harder to code but tend to be more reliable when combined with context filters like trend direction and volume.
Here's how common patterns break down for automated futures trading:
PatternBars RequiredCoding ComplexityFalse Signal RateBest Use CaseHammer / Hanging Man1LowHighReversal confirmation with trend filterBullish / Bearish Engulfing2LowMediumTrend reversal entries on ES, NQMorning Star / Evening Star3MediumLow-MediumSwing trade entries on daily chartsDoji1LowVery HighIndecision filter, not standalone signalThree White Soldiers3MediumLowMomentum confirmationPiercing Line / Dark Cloud2MediumMediumReversal at key levels
For futures markets like ES (tick value $12.50) and NQ (tick value $5.00), engulfing patterns on the 15-minute and 1-hour charts tend to produce more actionable signals than on the 1-minute chart. The shorter the timeframe, the more noise. A bullish engulfing on the ES 5-minute chart might fire 15 times in a single session. On the 1-hour chart, you might get 1-2 signals per day, which is more manageable for automation.
According to Thomas Bulkowski's research in the Encyclopedia of Candlestick Charts, engulfing patterns have a reversal rate of roughly 63-79% depending on market context and confirmation criteria [1]. That said, these numbers come from equity markets. Futures markets like ES and NQ often behave differently during high-volatility events like FOMC announcements (8 times per year, 2:00 PM ET) or NFP releases (first Friday monthly, 8:30 AM ET).
To automate candlestick pattern trades, you need three components: a Pine Script indicator that detects patterns, a TradingView alert configured with a webhook URL, and an automation platform that receives the webhook payload and sends orders to your broker.
Webhook Payload: The JSON-formatted message TradingView sends to an external URL when an alert fires. The payload contains trade instructions like symbol, direction, quantity, and order type that the automation platform interprets.
Your Pine Script indicator needs to use the alertcondition() function to create triggerable conditions. For each pattern you detect, create a separate alert condition or combine them with a message variable that identifies which pattern fired. The alert message format matters because your automation platform parses it to determine what order to place.
A typical TradingView webhook setup for pattern automation includes the symbol, action (buy or sell), quantity, and sometimes the pattern name for logging. The JSON payload might look like: {"symbol":"ES","action":"buy","qty":1,"pattern":"bullish_engulfing"}. Platforms like ClearEdge Trading parse these payloads and route orders to your connected broker.
One thing to watch: TradingView alerts fire at bar close by default. If you're on a 15-minute chart, your alert fires when the 15-minute candle completes. There's inherent latency between the pattern completing and the trade executing. On fast-moving instruments like NQ futures, that delay can mean 2-5 points of slippage during volatile sessions. Some traders use multi-timeframe alerts to confirm patterns before committing capital.
TradingView plan limits affect how many chart alerts you can run simultaneously. The free plan allows only 1 active alert. The Premium plan allows 400. If you're running pattern detection across ES, NQ, GC, and CL on multiple timeframes, you'll need at minimum a Plus or Premium plan. For details on plan-specific constraints, see our TradingView alert limits guide.
Raw candlestick pattern detection without filters produces too many signals, and most of them lose money. Adding trend, volume, and support/resistance context to your Pine Script indicator reduces false signals by 40-60% based on common backtesting results across equity index futures.
Here are the most effective filters for TradingView candlestick pattern recognition automation:
Trend direction filter. Only take bullish patterns when price is above the 20 or 50 EMA, and bearish patterns when below. This single filter eliminates most counter-trend signals that fail. In Pine Script, this is a simple comparison: close > ta.ema(close, 50).
Volume confirmation. Require the pattern candle's volume to exceed the 20-bar average volume by at least 1.2x. Engulfing patterns on above-average volume are more likely to follow through than those on thin volume. This matters especially during extended trading hours (ETH) on ES and NQ futures, where volume drops significantly compared to regular trading hours.
Support and resistance proximity. Bullish reversal patterns near a known support level carry more weight than the same pattern in the middle of a range. You can automate this by checking if the pattern's low is within a certain number of ticks of a prior swing low or a VWAP level.
Time-of-day filter. Not all hours are equal. ES futures see the highest volume and cleanest price action between 9:30 AM and 11:30 AM ET. Running pattern alerts during low-volume periods (like 12:00-2:00 PM ET) increases the chance of false signals. TradingView session-based alert conditions let you restrict when alerts fire.
Multi-timeframe confirmation. A bullish engulfing on the 15-minute chart that aligns with a bullish signal on the 1-hour chart has a higher probability of follow-through. Pine Script's request.security() function lets you check higher timeframe conditions within a lower timeframe indicator. This is one of the more powerful techniques for improving signal generation quality.
Indicator Alerts vs. Strategy Alerts: Indicator alerts use alertcondition() and fire based on conditions you define. Strategy alerts use strategy.entry() and fire based on backtestable entry/exit logic. For pattern automation, indicator alerts offer more flexibility in alert message customization. See our guide on strategy vs. study alerts.
Most traders who automate candlestick pattern detection make predictable errors. Here are the ones that cause the most damage:
No backtesting before going live. Running a pattern alert in production without checking historical performance is gambling with extra steps. Use TradingView's strategy tester to run at least 200 trades worth of data before committing real capital. If you don't know your expected win rate and average win/loss ratio, you're not ready to automate.
Overfitting to specific patterns. Optimizing your detection rules until they produce a 90% backtest win rate usually means you've fit the model to past data. When market conditions change, the pattern stops working. Keep your detection rules simple and test across different time periods and market conditions.
Ignoring context entirely. A bullish hammer candle during a strong downtrend on high volume is a different situation than a hammer during a choppy range on low volume. Automating pattern detection without any contextual filters (trend, volume, support/resistance) produces mediocre results at best.
Running too many pattern alerts simultaneously. Detecting 20 different patterns across 4 instruments on 3 timeframes gives you 240 potential signal sources. That's unmanageable. Pick 2-3 high-quality patterns, apply them to 1-2 instruments, and add filters. Quality matters more than quantity in TradingView bot trading.
Yes. TradingView has a built-in "All Candlestick Patterns" indicator that identifies roughly 30 formations automatically. For custom detection rules and webhook integration, you'll need a Pine Script indicator with alertcondition() functions.
Detection accuracy (identifying the pattern correctly) is near 100% when coded properly since it's mathematical. Predictive accuracy (whether the pattern leads to a profitable trade) varies from 40-65% depending on pattern type, filters applied, and market conditions [1].
Candlestick patterns apply to any market with open, high, low, and close data, including ES, NQ, GC, and CL futures. Performance varies by instrument and timeframe, so backtest your specific pattern-instrument combination before automating.
You need at minimum a TradingView Plus plan for server-side alerts and webhooks. Premium is recommended if you're running pattern detection across multiple instruments and timeframes, since it allows up to 400 active alerts.
Configure your TradingView alert with a webhook URL from an automation platform like ClearEdge Trading. The platform receives the alert's JSON payload and routes the order to your connected futures broker.
Multi-candle patterns like engulfing and morning star produce fewer false signals than single-candle patterns like doji or hammer. Start with 2-bar patterns and add contextual filters before moving to single-bar detection.
TradingView candlestick pattern recognition automation lets you systematize what most traders do by eye. Pine Script handles the detection, webhooks handle the communication, and an automation platform handles execution. The hard part isn't the coding. It's building filters that separate high-quality signals from noise.
Start by backtesting 2-3 patterns on your preferred instrument using TradingView's strategy tester. Add trend and volume filters. Paper trade for 30 days. Then, if the numbers hold up, move to live automation with conservative position sizing. For a broader look at how all these pieces connect, read the full TradingView automation for futures trading guide.
Want to dig deeper? Read our complete guide to TradingView automation for more detailed setup instructions and strategies.
Disclaimer: This article is for educational purposes only. It is not trading advice. ClearEdge Trading executes trades based on your rules, it does not provide signals or recommendations.
Risk Warning: Futures trading involves substantial risk. You could lose more than your initial investment. Past performance does not guarantee future results. Only trade with capital you can afford to lose.
CFTC RULE 4.41: Hypothetical results have limitations and do not represent actual trading.
By: ClearEdge Trading Team | About
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Block quote
Ordered list
Unordered list
Bold text
Emphasis
Superscript
Subscript
Every week, we break down real strategies from traders with 100+ years of combined experience, so you can skip the line and trade without emotion.
