Candlestick Patterns Settings/Inputs Guide for MT4 & MT5

Candlestick Patterns Settings/Inputs Guide for MT4 & MT5

12 March 2026, 08:43
Biswarup Banerjee
0
228

Complete User Documentation — MT4 & MT5

1. OVERVIEW

The Candlestick Patterns Strategy EA automates trading decisions by recognizing over a dozen classic candlestick formations — from single-bar dojis and hammers to multi-bar patterns like three-white soldiers and morning stars. Instead of you staring at charts waiting for a pattern to complete, the EA scans every tick or each new bar, then fires entries and exits based on the formations you select. It solves the core problem of pattern-based trading: catching reversals and continuations consistently without emotional interference or fatigue.

Who Should Use It: Retail forex traders who already use candlestick patterns in their manual analysis but want to automate the execution, or anyone looking to backtest a pattern-based strategy across multiple pairs and timeframes.

Main Benefit: You get a disciplined, rule-based system that never hesitates or second-guesses a valid pattern — freeing you to focus on risk management and overall strategy refinement.


2. INPUT PARAMETERS & SETTINGS

This product shares a common set of general input settings with all Expert Advisor products in this series. The following sections are covered in the common guide: General Settings (lot size, SL/TP modes, magic number, trade direction), Breakeven Settings, Trailing Stop Settings, News Filter Settings and News Action Settings, Martingale Settings, Grid Settings, Hedge Settings, Risk Settings, Position Sizing, Alert Settings, Display Settings, Trade Time Settings, Trade Days Settings, Safeguard Settings, and Trend Filter Settings (MA Filter, ADX Filter, RSI Filter, MACD Filter, Parabolic SAR Filter — each with their own strategy options). All of these are fully documented in the Common General Input Settings for Expert Advisors. The sections below cover only the product-specific inputs unique to this product.

General Settings

These settings control how the EA handles virtual stop-loss/take-profit lines, swap inclusion in profit calculations, and whether historical trade data is recorded for backtest analysis.

Setting Name Type Default Value Description Example
Chart lines for virtual SL/TP (never drawn during optimization) bool false When enabled, the EA draws horizontal lines on the chart showing where your hidden stop-loss and take-profit levels sit. Useful for visual confirmation during live trading, but the EA never draws these during optimization runs to avoid clutter and speed things up. true — Enable this on a live chart if you want to see exactly where your virtual SL/TP levels are placed without relying on the broker's order window.
Include Swap charges in Profit bool true Toggles whether overnight swap fees are factored into the profit calculation used by breakeven and trailing stop logic. Set to false if you want the EA to ignore swap costs and only consider raw price movement for those triggers. false — Use this when trading high-swap pairs like gold or indices to prevent swap charges from prematurely activating breakeven.
Enable history for backtests or optimization bool false When turned on, the EA records trade history into a file during backtests or optimization runs. This allows you to analyze individual trades later, but it also slows down the backtest slightly. Leave it off unless you need detailed trade logs. true — Enable this during a single backtest on EURUSD H1 if you want to export trade data for deeper analysis in Excel or Python.

Atr Trailingstop Settings

This group configures an ATR-based trailing stop that adapts to market volatility — the stop widens in volatile conditions and tightens in calm ones, giving your trades room to breathe.

Setting Name Type Default Value Description Example
Use ATR Trailing Stop bool false Master switch for the ATR-based trailing stop. When enabled, the EA replaces the fixed trailing stop with one that dynamically adjusts based on the Average True Range. This is ideal for volatile pairs where a fixed pip distance would get you stopped out too early. true — Turn this on for GBPJPY or XAUUSD to let the trailing stop adapt to their wider price swings.
ATR Timeframe ENUM PERIOD_CURRENT Selects the timeframe used to calculate the ATR value for the trailing stop. Using a higher timeframe (e.g., H4 on an H1 chart) gives a smoother, more stable ATR that ignores short-term noise. Defaults to the chart's own timeframe. PERIOD_H4 — Set this when trading on an M15 chart to get a broader view of volatility and avoid whipsaws.
ATR Period int 14 The number of bars used to calculate the ATR. A lower period (e.g., 7) makes the trailing stop react faster to recent volatility changes, while a higher period (e.g., 21) smooths out spikes. Standard 14 is a good starting point for most pairs. 21 — Use a longer period on daily charts to filter out noise and get a more reliable volatility baseline.
Activation (ATR multiplier) double 2.0 The trailing stop only activates once the trade's profit reaches this multiple of the current ATR. For example, with a multiplier of 2.0, the stop kicks in when profit equals 2 ATR values. This prevents the stop from engaging too early on small moves. 3.0 — Increase this to 3.0 on low-volatility pairs like EURCHF to avoid triggering the trailing stop on minor fluctuations.
Trail distance (ATR multiplier) double 1.0 Sets how far behind the current price the trailing stop sits, measured in ATR units. A value of 1.0 means the stop trails one ATR below the price for longs. Lower values tighten the stop; higher values give more room. 1.5 — Use 1.5 on volatile sessions (e.g., London open) to avoid getting stopped out by sudden spikes.
Trail increment (ATR multiplier) double 0.5 The step size by which the trailing stop moves up (or down) as price progresses, expressed in ATR units. A smaller increment means the stop updates more frequently, locking in profit faster. A larger increment reduces updates and is gentler on CPU. 0.3 — Set this lower on fast-moving pairs like GBPJPY to capture profits more aggressively as price runs.

Grid Settings

This single setting controls whether the EA attempts to recover losses from all grid trades by closing them as a group when total profit turns positive.

Setting Name Type Default Value Description Example
Recover profit from all grid trades bool false When enabled, the EA monitors the combined profit of all grid trades and closes the entire grid once total profit becomes positive. This is useful for recovering from a series of losing grid entries without waiting for each individual trade to hit its take-profit. true — Enable this if you run a grid strategy and want the EA to automatically close all grid trades when the net position turns green, rather than managing each leg separately.

Safeguard Settings

These backtest-only safeguards let you set minimum performance thresholds — if the EA fails to meet them during optimization, the run is discarded, saving you time sifting through poor results.

Setting Name Type Default Value Description Example
Max Loss from initial balance [0: disable] double 0.0 Sets a maximum drawdown limit as a percentage of the starting balance. If the equity drops below this threshold during a backtest, the EA stops trading and the run is flagged. Leave at 0 to disable this check. 20.0 — Set this to 20% to automatically reject any optimization run where the account loses more than a fifth of its starting capital.
Minimum Profit Percent [backtesting only] [0: disable] double 0 Defines the minimum total profit percentage required for a backtest to be considered valid. If the EA doesn't hit this threshold, the run is discarded. Useful for filtering out unprofitable parameter sets during optimization. 5.0 — Use this to discard any backtest that fails to return at least 5% profit over the test period.
Minimum Trades [backtesting only] [0: disable] double 0 Specifies the minimum number of trades that must be executed during a backtest for the run to be kept. This prevents the EA from being evaluated on just a handful of lucky trades. Set to 0 to disable. 50 — Set this to 50 to ensure you're only looking at backtests with statistically meaningful trade counts.
Max inactive days [backtesting only] [0: disable] int 0 Limits the maximum number of consecutive days the EA can go without opening a trade during a backtest. If this threshold is exceeded, the run is discarded. Helps filter out parameter sets that produce long periods of inactivity. 30 — Set this to 30 to reject any backtest where the EA sits idle for a month or more.

Settings

These are the core pattern-recognition controls — you pick which candlestick formations trigger entries and exits, and on which timeframe the EA should look for them.

Setting Name Type Default Value Description Example
Bollinger Band Timeframe ENUM PERIOD_CURRENT Selects the timeframe on which the EA evaluates candlestick patterns. You can set it to a higher timeframe than the chart (e.g., H4 on an M15 chart) to filter patterns based on higher-level structure. Defaults to the chart's own timeframe. PERIOD_H1 — Set this to H1 when trading on an M5 chart so the EA only acts on patterns that form on the hourly level, reducing noise.
Candlestick Entry Strategy ENUM ENTRY_ENGULFING See options explained below. ENTRY_HAMMER — Choose this if you want the EA to enter on hammer and inverted hammer patterns, which often signal trend reversals.

3. HOW IT WORKS

Core Calculation & Logic

The EA continuously monitors each new tick or completed candle (depending on your scan mode setting) and evaluates the most recent candlestick formations against the pattern definitions you've selected. It uses standard candlestick pattern recognition logic — comparing open, close, high, and low relationships across consecutive candles — to determine whether a valid entry or exit signal has occurred. For example, a bullish engulfing pattern is detected when the current candle's body completely "swallows" the previous candle's body and closes higher, while a hammer requires a small real body with a long lower shadow at least twice the body size. The EA doesn't rely on any external indicators for pattern detection; it's pure price action based on the raw OHLC data of the chart timeframe you attach it to.

Once a pattern is confirmed, the EA checks your active filters (trend, time, news, etc.) before executing the trade. If you've set a candlestick exit strategy, the EA will also monitor for opposing patterns to close positions. The mathematical basis is straightforward: each pattern has a set of boolean conditions coded directly into the EA, and when those conditions evaluate to true, the corresponding action is triggered. This approach keeps latency low and avoids the lag that can come with indicator-based systems.

Entry Strategies Explained

Each entry strategy corresponds to a specific candlestick pattern or pattern group. The EA checks for these patterns on every tick or at the close of each period, depending on your scan mode. Below is the full breakdown of every available entry strategy.

ENTRY_DISABLE

BUY Signal: None — no buy signals are generated.

SELL Signal: None — no sell signals are generated.

Best For: When you want to use the EA only for managing existing positions (e.g., trailing stop or breakeven) without opening new trades. Useful during high-impact news events or when you're manually trading around the EA.

ENTRY_HAMMER

BUY Signal: A hammer pattern is detected — the current candle has a small real body near the top of its range, with a lower shadow at least twice the body length, and the close is in the upper half of the candle. The previous candle must be bearish (close lower than open).

SELL Signal: An inverted hammer pattern is detected — the current candle has a small real body near the bottom of its range, with an upper shadow at least twice the body length, and the close is in the lower half. The previous candle must be bullish.

Best For: Trending markets where you expect a reversal at key support or resistance levels. Works well on H1 and H4 timeframes.

ENTRY_ENGULFING

BUY Signal: A bullish engulfing pattern — the current candle's body completely engulfs the previous candle's body, and the close is higher than the open. The previous candle must be bearish.

SELL Signal: A bearish engulfing pattern — the current candle's body completely engulfs the previous candle's body, and the close is lower than the open. The previous candle must be bullish.

Best For: Capturing strong momentum shifts after a pullback. This is the most widely used pattern and works across all timeframes.

ENTRY_HARAMI

BUY Signal: A bullish harami — the current candle's body is completely inside the previous candle's body, and the close is higher than the open. The previous candle must be bearish.

SELL Signal: A bearish harami — the current candle's body is completely inside the previous candle's body, and the close is lower than the open. The previous candle must be bullish.

Best For: Identifying potential trend exhaustion. Best used after a strong directional move when you suspect the trend is losing steam.

ENTRY_PIERCING

BUY Signal: A piercing line — the current candle opens below the previous bearish candle's low, then closes above the midpoint of the previous candle's body.

SELL Signal: A dark-cloud cover — the current candle opens above the previous bullish candle's high, then closes below the midpoint of the previous candle's body.

Best For: Reversal entries after a clear trend. The piercing line is considered a stronger reversal signal than the harami.

ENTRY_STAR

BUY Signal: A morning star pattern — three candles: a long bearish candle, a small-bodied candle (doji or spinning top) that gaps below the first, and a long bullish candle that closes at least halfway into the first candle's body.

SELL Signal: An evening star pattern — three candles: a long bullish candle, a small-bodied candle that gaps above the first, and a long bearish candle that closes at least halfway into the first candle's body.

Best For: Major trend reversals, especially at the end of extended moves. Works best on daily or higher timeframes.

ENTRY_THREE_INSIDE

BUY Signal: A 3-inside-up pattern — a long bearish candle, followed by a smaller bullish candle that closes inside the first candle's body, then a third bullish candle that closes above the first candle's high.

SELL Signal: A 3-inside-down pattern — a long bullish candle, followed by a smaller bearish candle inside its body, then a third bearish candle that closes below the first candle's low.

Best For: Confirming a reversal after a harami-like setup. The third candle provides extra confirmation, reducing false signals.

ENTRY_TASUKI_GAP

BUY Signal: A tasuki gap up — a bullish candle gaps above the previous candle, followed by a bearish candle that opens within the gap and closes below the gap but above the first candle's close.

SELL Signal: A tasuki gap down — a bearish candle gaps below the previous candle, followed by a bullish candle that opens within the gap and closes above the gap but below the first candle's close.

Best For: Continuation trading during strong trends. The gap acts as a support/resistance zone, and the retracement candle gives a second entry point.

ENTRY_BREAKAWAY

BUY Signal: A breakaway up pattern — five candles: a long bearish candle, three small-bodied candles moving sideways or slightly up, then a long bullish candle that closes above the first candle's high.

SELL Signal: A breakaway down pattern — five candles: a long bullish candle, three small-bodied candles moving sideways or slightly down, then a long bearish candle that closes below the first candle's low.

Best For: Capturing breakouts from consolidation zones after a strong initial move. The pattern filters out weak reversals.

ENTRY_WINDOW

BUY Signal: A rising window — the current candle's low is above the previous candle's high (a gap up), and the close is in the upper half of the candle.

SELL Signal: A falling window — the current candle's high is below the previous candle's low (a gap down), and the close is in the lower half of the candle.

Best For: Trend continuation after a gap. Works well on instruments that frequently gap, like indices or certain forex pairs during high-volatility sessions.

ENTRY_ON_NECK

BUY Signal: An on-neck up pattern — a bearish candle followed by a bullish candle that closes at or near the previous candle's low.

SELL Signal: An on-neck down pattern — a bullish candle followed by a bearish candle that closes at or near the previous candle's high.

Best For: Short-term reversals in ranging markets. This is a less common pattern, so it tends to produce fewer but more precise signals.

ENTRY_SPINNING

BUY Signal: A bullish spinning top — a candle with a small real body (less than 10% of the total range) and both upper and lower shadows longer than the body, closing higher than it opened.

SELL Signal: A bearish spinning top — same shape but closing lower than it opened.

Best For: Identifying market indecision before a potential reversal. Often used as a warning signal rather than a direct entry — combine with a trend filter for better results.

ENTRY_DOJI

BUY Signal: A bullish doji — the open and close are nearly equal (within 5% of the total range), and the close is above the open. The previous candle must be bearish.

SELL Signal: A bearish doji — same shape but the close is below the open. The previous candle must be bullish.

Best For: Reversal entries after a strong trend. Dojis are among the most reliable reversal signals when they appear at support or resistance levels.

ENTRY_SOLDIERS_CROWS

BUY Signal: Three white soldiers — three consecutive bullish candles, each closing higher than the previous, with each candle's body roughly the same size or growing. Each candle opens within the previous candle's body.

SELL Signal: Three black crows — three consecutive bearish candles, each closing lower than the previous, with each candle's body roughly the same size or growing. Each candle opens within the previous candle's body.

Best For: Strong trend continuation. This pattern signals that momentum is firmly in one direction — ideal for trend-following strategies with a trailing stop.

Step-by-Step Workflow

Step 1: Attach the EA to a chart. Drag the EA onto any MT4 or MT5 chart. Make sure the chart timeframe matches the pattern detection timeframe you intend to use — the EA reads patterns from the chart it's attached to.

Step 2: Configure entry and exit strategies. Set your Candlestick Entry Strategy to one of the patterns listed above. If you want the EA to also close trades based on patterns, set Candlestick Exit Strategy to a pattern as well — otherwise leave it on EXIT_DISABLE.

Step 3: Set your risk parameters. Define your lot size, stop loss, and take profit in the General Settings section. If you're unsure, start with a small lot (0.01) and a fixed stop loss of 20-30 pips.

Step 4: Enable or disable filters. Go through the trend filter settings (MA, ADX, RSI, MACD, Parabolic SAR) and decide which ones you want active. For a simple start, enable just the MA filter set to a 200-period moving average to trade with the trend.

Step 5: Run a backtest first. Before going live, run the EA in the Strategy Tester for at least 6 months of data. Pay attention to the win rate and drawdown — if the drawdown exceeds 20%, consider tightening your filters or reducing lot size.

Step 6: Deploy on a demo account. Run the EA on a demo account for at least 2 weeks to verify it behaves as expected in live market conditions. Check that patterns are being detected correctly and that trades are opening and closing at the right times.

Step 7: Go live with caution. Once you're satisfied with demo performance, switch to a live account with a small balance. Start with the same settings you used in demo, and only increase risk after 20-30 profitable trades.


4. RISK MANAGEMENT FEATURES

The EA includes several built-in risk controls that work alongside the common settings documented in the general guide. These features help protect your account during adverse market conditions.

Feature Description
Hidden SL/TP When enabled, stop loss and take profit levels are managed internally by the EA rather than being sent to the broker. This prevents other traders or algorithms from seeing your exit levels. Useful if you're trading on a platform where stop hunting is a concern.
Risk-Reward Ratio If set above 0, the EA automatically calculates the take profit based on your stop loss distance multiplied by this ratio. For example, a 2:1 ratio with a 20-pip stop loss gives a 40-pip take profit. This ensures every trade has a positive expectancy before it's opened.
Scan Mode Control Choose between checking for patterns on every tick or only at the close of each period. Every-tick mode catches intra-candle patterns but uses more CPU. Period-wise mode reduces false signals by waiting for the candle to close — better for slower timeframes like H4 or daily.
Magic Number Isolation When enabled, the EA assigns a unique magic number to all its trades. This prevents it from interfering with manual trades or other EAs running on the same account. Disable this only if you want the EA to manage all positions regardless of origin.
Logging Control Enable logs to record every pattern detection and trade action in the Experts tab. Useful for debugging during backtesting or when first deploying live. Disable in production to reduce file size and improve performance.

Quick Start Guide

Follow these steps to get started in under 5 minutes:

  1. Download and install: Purchase the EA from the MQL5 Market and install it via the Tools > Options > Expert Advisors menu in MT4/MT5. Make sure "Allow automated trading" is checked.
  2. Attach to a chart: Open a chart for your preferred symbol (e.g., EURUSD on H1). Drag the EA from the Navigator panel onto the chart. A settings dialog will appear.
  3. Set your entry strategy: In the Settings tab, find "Candlestick Entry Strategy" and choose ENTRY_ENGULFING for a simple start. Leave the exit strategy on EXIT_DISABLE for now.
  4. Configure basic risk: Set Lot Size to 0.01, SLTP_MODE to "Pips", STOPLOSS to 30, and TAKEPROFIT to 60. This gives you a 1:2 risk-reward ratio with minimal capital exposure.
  5. Enable a trend filter: Scroll down to the MA Filter settings. Set MA_FILTER to true, MA_PERIOD to 200, and MA_STRATEGY to "MA_ABOVE" for buy-only signals when price is above the 200 MA. This keeps you trading with the long-term trend.
  6. Run a backtest: Open the Strategy Tester (Ctrl+R), select your EA, set the date range to the last 12 months, and click Start. Review the results — look for a profit factor above 1.5 and a drawdown below 15%.
  7. Go to demo: Once backtest results look solid, attach the EA to a demo account with the same settings. Let it run for at least 50 trades before making any changes.
  8. Monitor and adjust: Check the EA's performance weekly. If you see three consecutive losing trades, consider switching to a different entry pattern or tightening your trend filter. The EA's logs will show you exactly which patterns triggered each trade.


Installation Guide for MQL Products | Updating Purchased MQL Products on MT4/MT5 | General Troubleshooting Guide | Backtest and Set Files

Check all my products: https://www.mql5.com/en/users/biswait50/seller

Contact me for support: https://www.mql5.com/en/users/biswait50