TwoCandlesPattern

**TwoCandlesPattern – Expert Advisor for MetaTrader 5**  
*A simple and robust trading system based on a two‑candle pattern, optimized for EURUSD on M15, with anti‑martingale risk management and trailing stop.*

---

### Overview

**TwoCandlesPattern** is a fully automated Expert Advisor designed to detect reversal patterns on two consecutive candlesticks. The strategy has been specifically developed and tested on the **EURUSD** pair on the **M15** timeframe, where it demonstrates stable and reliable performance. It can be used on other instruments as well, but optimal results are achieved within this framework.

The strategy is simple, proven, and incorporates advanced risk management features to help protect your capital and optimize your performance. Whether you are a beginner or an experienced trader, **TwoCandlesPattern** offers a turnkey solution to capitalize on market reversals with rigorous risk discipline.

---

### Key Features

- **Two‑Candle Pattern** : detects bullish configurations (two green candles, the second breaking below the low of the first) and bearish configurations (two red candles, the second breaking above the high of the first).
- **Flexible Trading Window** : precisely define the trading time range (start and end hours) to target the most opportune moments (default 9:00–12:00).
- **Quality Filter** : validates signals using a minimum body/ATR ratio, eliminating low‑amplitude candles (dojis, pin bars).
- **Proportional Risk Management** : automatically calculates the lot size based on a percentage of your capital to risk per trade.
- **Built‑in Anti‑Martingale** : after a win, the lot size is multiplied by a factor (e.g., 3) to capitalize on winning streaks; after a loss, the lot returns to the base size. You control the maximum number of steps (default 10) and the number of consecutive wins before resetting.
- **Safety Caps** : limit the maximum lot via a multiplier of the base lot, a maximum risk percentage per trade, and an absolute maximum lot (default 5 lots), preventing excessive exposure.
- **Advanced Trailing Stop** : activates trend following after a defined profit threshold (default 200 points), with a fixed trailing distance – ideal for letting profits run while protecting gains.
- **Margin Check** : before opening a trade, the EA calculates the required margin and automatically reduces the volume if needed, avoiding order rejections.
- **Multi‑Instrument Compatibility** : works on all symbols thanks to a universal point‑value calculation, although the default parameters have been optimized for EURUSD M15.

---

### How It Works

The EA analyzes the last two closed candles within your defined time range. A buy signal is generated when:

- Both candles are bullish (close > open),
- The second candle breaks below the low of the first (low2 < low1),
- The close of the first candle is above the open of the second (close1 > open2).

A sell signal is generated in the opposite case.

An optional ATR‑based filter (period 14) requires each candle's body to be at least 40% of the ATR (adjustable ratio), eliminating low‑quality signals.

Once a signal is validated, the EA opens a position with a stop loss placed below the low (for a buy) or above the high (for a sell). The take profit is set by default to 2 times the stop loss distance, but you can also use the trailing stop for dynamic management.

---

### Advanced Risk Management

The EA offers several mechanisms to control your risk:

- **Proportional Risk** : choose the percentage of your capital you are willing to risk on each trade. The EA then calculates the appropriate lot size.
- **Anti‑Martingale** : after a winning trade, the lot size is multiplied by a factor (e.g., 3). You set the maximum number of steps and the maximum consecutive wins allowed before resetting to the base step.
- **Safety Caps** : you can limit the maximum lot (as a multiple of the base lot), the maximum risk percentage per trade, and an absolute maximum lot, even if the anti‑martingale logic would otherwise go higher.
- **Trailing Stop** : once the profit reaches a defined threshold (default 200 points), the stop loss is moved to follow the price, locking in gains.
- **Margin Check** : before sending an order, the EA ensures sufficient free margin; if not, it automatically reduces the volume in an attempt to execute the order.

---

### Input Parameters

All parameters are accessible in the EA's input window. Here is their meaning, with default values optimized for EURUSD M15:

| Group | Parameter | Description |
|--------|-----------|-------------|
| **Trading Window** | `InpStartHour`, `InpStartMinute` | Start hour and minute of the trading session (default 9:00). |
| | `InpEndHour`, `InpEndMinute` | End hour and minute of the session (default 12:00). |
| | `InpTimeZone` | Time zone: 0 = UTC, 1 = server time. |
| **Money Management** | `InpLotSize` | Base lot size (used if proportional risk is disabled, default 0.1). |
| | `InpStopLossPoints` | Stop loss distance in points (default 30). |
| | `InpMagicNumber` | Unique identifier for the EA's orders (default 23456). |
| | `InpUseRiskManagement` | Enables lot calculation based on a percentage of capital (default true). |
| | `InpRiskPercent` | Percentage of capital to risk per trade (default 0.1%). |
| **Anti‑Martingale** | `InpMartingaleFactor` | Multiplication factor after a win (default 3.0). |
| | `InpMaxSteps` | Maximum number of progression steps (default 10). |
| | `InpMaxConsecutiveWins` | Maximum consecutive wins before resetting (default 4). |
| **Safety Caps** | `InpUseVolumeCaps` | Enables safety limits on volume (default true). |
| | `InpMaxLotMultiplier` | Maximum allowed multiplier of the base lot (default 5.0). |
| | `InpMaxRiskPerTrade` | Maximum percentage of capital that can be risked on a trade (default 3.0%). |
| | `InpMaxAbsoluteLot` | Absolute maximum lot size, overriding all other caps (default 5.0). |
| **Signal Filter** | `InpUseCandleSizeFilter` | Enables the candle size filter (default true). |
| | `InpMinBodyRatio` | Minimum ratio (body / ATR) to validate a candle (default 0.4). |
| | `InpATRPeriod` | Period for ATR calculation (default 14). |
| **Trailing Stop** | `InpUseTrailingStop` | Enables the trailing stop (default true). |
| | `InpTrailingStartPoints` | Profit in points at which trailing is activated (default 200). |
| | `InpTrailingDistancePoints` | Trailing distance in points (default 5). |

---

### Specifics and Recommendations

- **Recommended Timeframe** : M15 (tested and validated on this period).
- **Recommended Pair** : EURUSD (default parameters have been optimized for this pair).
- **Suggested Minimum Deposit** : 500 USD (or equivalent) for a base lot of 0.1.
- **Account Type** : any type (hedging or netting), the EA opens only one position at a time.

---

### Disclaimer

Automated trading involves risk of loss. Past performance does not guarantee future results. It is strongly recommended to test the EA on a demo account before using it in live conditions. Ensure you fully understand all parameters and adapt them to your risk profile.

---

**Ready to optimize your trading?**  

Download the trial version and test **TwoCandlesPattern** on EURUSD M15 in the Strategy Tester today.
Filtrele:
İnceleme yok
İncelemeye yanıt