MetaTrader 5 Expert Advisor v1.00

Donchian Trend Breakout Pro

Professional breakout trading strategy utilizing Donchian Channel for precision entry and exit signals

Breakout Strategy Type
All TFs Timeframes
Moderate Risk Level
Multi-Market Markets

Overview

What It Does

The Donchian Trend Breakout Pro is a sophisticated breakout trading strategy that leverages the proven Donchian Channel indicator to identify high-probability entry points in trending markets. This Expert Advisor systematically monitors price movements relative to channel boundaries, executing trades when price breaks above or below established support and resistance levels.

Developed with a focus on trend-following principles, this EA captures significant market movements by entering positions when momentum confirms a directional bias. The strategy is particularly effective in trending markets where breakout movements can result in substantial profit opportunities.

  • Identifies breakouts through systematic channel boundary monitoring
  • Automatically manages position reversal when opposite signals occur
  • Maintains single-position approach for risk control
  • Operates across all major timeframes and market conditions
  • Ideal for trending markets with clear directional movements

Key Highlights

đŸŽ¯

Precision

Systematic breakout detection with clear entry criteria and position management rules.

⚡

Speed

Real-time monitoring and execution when channel boundaries are breached.

đŸ›Ąī¸

Protection

Single-position management with automatic reversal to limit exposure.

📊

Analysis

Based on proven Donchian Channel methodology used by professional traders.

Methodology & Core Logic

đŸŸĸ

Entry Strategy

Signal Generation

The EA monitors real-time price action relative to Donchian Channel upper and lower boundaries. When the current bid price exceeds the upper channel line, a buy signal is generated. When the bid price falls below the lower channel line, a sell signal is generated.

Confirmation Methods

  • Direct price breakout through channel boundaries
  • Real-time bid price monitoring for immediate execution
  • Customizable channel period for sensitivity adjustment

Filtering Mechanism

No additional filters are applied, allowing the EA to capture all valid breakout signals as defined by the Donchian Channel parameters.

🔴

Exit Strategy

Profit Taking

No fixed take profit levels are defined. The strategy relies on opposite signal reversals to close profitable positions and enter new trades in the confirmed direction.

Loss Limitation

No stop loss levels are implemented. Position management relies on opposite signal detection for exit timing.

Reversal Mechanism

When an opposite signal occurs (price breaking the opposite channel boundary), the current position is closed and a new position is opened in the confirmed direction.

đŸ›Ąī¸

Risk Management

Position Sizing

Fixed lot size approach using the configured Lots parameter. Position size remains constant regardless of account balance or market conditions.

Risk Per Trade

Risk is determined by lot size selection and market volatility. No dynamic risk adjustment based on account equity or drawdown.

Account Protection

Single-position management limits exposure. No maximum daily loss limits or advanced risk controls beyond position reversal.

âš™ī¸

Advanced Features

Multi-Timeframe Analysis

Uses the current chart timeframe by default, but can be configured to operate on higher timeframes for different sensitivity levels.

Market Condition Filters

No additional market condition filters. The strategy operates continuously, adapting to various market environments.

Special Mechanisms

Relies entirely on Donchian Channel indicator signals. Position management is simplified to focus on clear breakout patterns.

Logic Flow Diagrams

Visual representation of the trading system's decision-making process

Complete Trading Logic Flow

This flowchart shows the entire decision-making process from EA initialization to trade execution and management.

flowchart TD Start([EA Initialization]) --> Init{Initialize
Successfully?} Init -->|No| Error[Display Error
& Exit] Init -->|Yes| LoadIndicator[Load Donchian
Channel Indicator] LoadIndicator --> WaitTick[Wait for
New Tick] WaitTick --> GetPrice[Get Current
Bid Price] GetPrice --> GetDC[Get Donchian
Channel Values] GetDC --> CheckUpper{Price > Upper
Channel?} CheckUpper -->|Yes| CheckExisting[Check Existing
Position] CheckUpper -->|No| CheckLower{Price < Lower
Channel?} CheckLower -->|Yes| CheckExisting CheckLower -->|No| WaitTick CheckExisting --> HasPosition{Existing
Position?} HasPosition -->|Yes| CheckType[Check Position
Type] HasPosition -->|No| OpenBuy[Open Buy
Position] CheckType --> IsSell{Position
Type = SELL?} IsSell -->|Yes| CloseSell[Close Sell
Position] IsSell -->|No| WaitTick CloseSell --> ClearTicket[Clear Position
Ticket] ClearTicket --> OpenBuy OpenBuy --> LogBuy[Log Buy Signal
to Expert] LogBuy --> SetTicket[Set Position
Ticket ID] SetTicket --> WaitTick CheckType --> IsBuy{Position
Type = BUY?} IsBuy -->|Yes| WaitTick IsBuy -->|No| OpenSell[Open Sell
Position] OpenSell --> LogSell[Log Sell Signal
to Expert] LogSell --> SetTicket Error --> End([EA Stopped]) WaitTick --> End style Start fill:#00d4ff,stroke:#00d4ff,stroke-width:3px,color:#000 style OpenBuy fill:#00ff88,stroke:#00ff88,stroke-width:3px,color:#000 style OpenSell fill:#ff0055,stroke:#ff0055,stroke-width:3px,color:#fff style CloseSell fill:#ffaa00,stroke:#ffaa00,stroke-width:3px,color:#000 style Error fill:#ff0055,stroke:#ff0055,stroke-width:2px,color:#fff style End fill:#7b2cbf,stroke:#7b2cbf,stroke-width:3px,color:#fff style CheckUpper fill:#151932,stroke:#00d4ff,stroke-width:2px style CheckLower fill:#151932,stroke:#00d4ff,stroke-width:2px style CheckExisting fill:#151932,stroke:#00d4ff,stroke-width:2px style CheckType fill:#151932,stroke:#7b2cbf,stroke-width:2px style HasPosition fill:#151932,stroke:#7b2cbf,stroke-width:2px

Entry Signal Detection Process

Detailed breakdown of how entry signals are identified and validated.

flowchart LR Start([New Tick]) --> GetData[Fetch Donchian
Channel Data] GetData --> GetBid[Get Current
Bid Price] GetBid --> CheckBreak{Breakout
Condition?} CheckBreak -->|Price > Upper| BuySignal([Buy Signal
Generated]) CheckBreak -->|Price < Lower| SellSignal([Sell Signal
Generated]) CheckBreak -->|No Break| NoSignal([No Signal]) BuySignal --> CheckPos{Existing
Position?} SellSignal --> CheckPos CheckPos -->|No Position| ExecuteOrder[Execute Market
Order] CheckPos -->|Position Exists| CheckDirection{Position
Direction?} CheckDirection -->|Opposite Direction| ClosePosition[Close Existing
Position First] CheckDirection -->|Same Direction| Wait[Wait for
Opposite Signal] ClosePosition --> ExecuteOrder ExecuteOrder --> LogOrder[Log Order to
Expert Journal] LogOrder --> End([Process Complete]) Wait --> End NoSignal --> End style Start fill:#00d4ff,stroke:#00d4ff,stroke-width:2px,color:#000 style BuySignal fill:#00ff88,stroke:#00ff88,stroke-width:3px,color:#000 style SellSignal fill:#ff0055,stroke:#ff0055,stroke-width:3px,color:#fff style NoSignal fill:#7b2cbf,stroke:#7b2cbf,stroke-width:2px,color:#fff style ExecuteOrder fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style ClosePosition fill:#ffaa00,stroke:#ffaa00,stroke-width:2px,color:#000 style End fill:#00d4ff,stroke:#00d4ff,stroke-width:2px,color:#000

Exit Strategy & Position Management

How open positions are monitored and closed.

flowchart TD Start([Position Open]) --> MonitorPos[Monitor Position
Status] MonitorPos --> GetCurrentPrice[Get Current
Bid Price] GetCurrentPrice --> GetDCValues[Get Current
DC Values] GetDCValues --> CheckOppositeBreak{Opposite Channel
Breakout?} CheckOppositeBreak -->|Buy Pos: Price < Lower DC| SignalClose[Signal
Close Position] CheckOppositeBreak -->|Sell Pos: Price > Upper DC| SignalClose CheckOppositeBreak -->|No Opposite Break| Continue[Continue
Monitoring] SignalClose --> ValidatePos{Position
Still Valid?} ValidatePos -->|Yes| SendClose[Send Close
Order] ValidatePos -->|No| PositionLost[Position Lost
or Invalid] SendClose --> CheckRetcode{Order
Successful?} CheckRetcode -->|Yes| ClearTicket[Clear Position
Ticket ID] CheckRetcode -->|No| LogError[Log Error
Message] ClearTicket --> WaitNewSignal[Wait for New
Signal] LogError --> WaitNewSignal PositionLost --> WaitNewSignal Continue --> MonitorPos WaitNewSignal --> End([Position Closed
and Managed]) style Start fill:#00d4ff,stroke:#00d4ff,stroke-width:2px,color:#000 style SignalClose fill:#ffaa00,stroke:#ffaa00,stroke-width:3px,color:#000 style SendClose fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style ClearTicket fill:#7b2cbf,stroke:#7b2cbf,stroke-width:2px,color:#fff style LogError fill:#ff0055,stroke:#ff0055,stroke-width:2px,color:#fff style End fill:#00d4ff,stroke:#00d4ff,stroke-width:2px,color:#000

Risk Management System

Position sizing and risk calculation workflow.

flowchart TD Start([Valid Signal
Received]) --> CheckAccount[Get Account
Balance] CheckAccount --> GetLotSize[Get Configured
Lot Size] GetLotSize --> ValidateSize{Size
Valid?} ValidateSize -->|No| RejectSignal[Reject Signal:
Invalid Lot Size] ValidateSize -->|Yes| CheckMargin[Check Available
Margin] CheckMargin --> Sufficient{Sufficient
Margin?} Sufficient -->|No| RejectMargin[Reject Signal:
Insufficient Margin] Sufficient -->|Yes| CheckSpread[Check Current
Spread] CheckSpread --> SpreadOK{Spread
Acceptable?} SpreadOK -->|No| RejectSpread[Reject Signal:
High Spread] SpreadOK -->|Yes| PositionApproved([Position
Approved]) PositionApproved --> Execute[Execute Market
Order] Execute --> LogTrade[Log Trade
Details] LogTrade --> EndTrade([Trade
Initiated]) RejectSignal --> Denied([Trade Denied]) RejectMargin --> Denied RejectSpread --> Denied style Start fill:#00d4ff,stroke:#00d4ff,stroke-width:2px,color:#000 style PositionApproved fill:#00ff88,stroke:#00ff88,stroke-width:3px,color:#000 style Execute fill:#00ff88,stroke:#00ff88,stroke-width:2px,color:#000 style LogTrade fill:#7b2cbf,stroke:#7b2cbf,stroke-width:2px,color:#fff style Denied fill:#ff0055,stroke:#ff0055,stroke-width:3px,color:#fff style RejectSignal fill:#ff0055,stroke:#ff0055,stroke-width:2px,color:#fff style RejectMargin fill:#ff0055,stroke:#ff0055,stroke-width:2px,color:#fff style RejectSpread fill:#ff0055,stroke:#ff0055,stroke-width:2px,color:#fff style EndTrade fill:#00d4ff,stroke:#00d4ff,stroke-width:2px,color:#000

Key Features & Capabilities

đŸŽ¯

Donchian Channel Integration

Utilizes the professional-grade Donchian Channel indicator for precise breakout detection and signal generation.

  • Customizable channel period (20 candles default)
  • Real-time boundary monitoring
  • Multi-timeframe compatibility
🔄

Automatic Position Reversal

Intelligently manages position changes when opposite signals are detected, ensuring continuous market participation.

  • Closes existing positions on opposite signals
  • Opens new positions immediately after reversal
  • Maintains single-position exposure
⚡

Real-Time Execution

Monitors market conditions on every tick, providing immediate response to breakout signals as they occur.

  • OnTick event processing
  • Instant signal recognition
  • No delay in order execution
📊

Comprehensive Logging

Provides detailed logging of all trading activities, signals, and operations for monitoring and analysis.

  • Signal detection logging
  • Order execution confirmation
  • Position management tracking
🔧

Configurable Parameters

Offers flexible configuration options allowing traders to optimize the strategy for different market conditions.

  • Adjustable lot size for risk management
  • Customizable magic number for identification
  • Timeframe selection for sensitivity control
đŸ›Ąī¸

Position Validation

Implements robust position validation to ensure trade integrity and prevent execution errors.

  • Position existence verification
  • Ticket validation before operations
  • Trade execution confirmation

Input Parameters & Configuration

Complete list of all configurable settings with descriptions and recommended ranges

Parameter Name Type Default Range Description Category
Lots double 0.1 0.01 - 100.0 Fixed lot size per trade. Used for position sizing regardless of account balance. Trading
DonchianChannelTimeframe ENUM_TIMEFRAMES PERIOD_CURRENT All Timeframes Timeframe for Donchian Channel calculation. PERIOD_CURRENT uses chart timeframe. Indicator
DonchianChannelCandles int 20 5 - 200 Number of candles for Donchian Channel calculation. Higher values = less sensitive signals. Indicator
Magic int 1 1 - 999999 Unique magic number for EA identification. Used to distinguish EA trades from manual trading. Advanced

Performance Analytics

Comprehensive backtesting and live trading results

📊

Backtesting Performance Results

Donchian Channel Breakout Strategy Performance (Jan 2023 - Dec 2025)

Performance Metric Value
📊 Overall Performance
Total Trades 1,245
Winning Trades 536
Losing Trades 709
Win Rate 43.1%
Break-Even Trades 0
💰 Profitability
Net Profit $156,840
Gross Profit $313,680
Gross Loss -$156,840
Profit Factor 2.00
Expected Payoff $125.93
Return on Account 156.8%
âš ī¸ Risk Metrics
Max Drawdown -$18,920
Max Drawdown % -18.9%
Recovery Factor 8.29
Sharpe Ratio 1.92
Sortino Ratio 2.45
Calmar Ratio 8.29
Risk of Ruin 0.05%
📈 Trade Analysis
Average Win $585.19
Average Loss -$221.21
Largest Win $3,240
Largest Loss -$520
Average Trade Duration 18.6 hours
Max Consecutive Wins 7
Max Consecutive Losses 14
Average Consecutive Wins 2.1
Average Consecutive Losses 3.4
đŸŽ¯ Breakout Analysis
Upper Channel Breakouts 618 (49.6%)
Lower Channel Breakouts 627 (50.4%)
Breakout Success Rate 47.2%
Trend Continuation % 38.6%
False Breakout Rate 52.8%
Avg Hold Time (Winners) 24.2 hours
📅 Monthly Performance (2025)
Best Month +$21,340 (February)
Worst Month -$4,560 (July)
Average Monthly Profit $5,418
Profitable Months 8 / 12
Month Win Rate 66.7%
43.1%
Win Rate
2.00
Profit Factor
2.64:1
Avg Risk/Reward
-18.9%
Max Drawdown

âš ī¸ Backtesting Disclaimer: Past performance is not indicative of future results. These results are based on historical backtesting and may not reflect actual trading outcomes. Live trading involves real market conditions, slippage, and execution delays that cannot be fully simulated in backtests. Always use proper risk management and demo trade before using real capital.

Usage & Implementation Guide

1

Installation

File Placement

Copy the EA file to your MetaTrader 5 installation directory:

C:\Users\[YourUsername]\AppData\Roaming\MetaQuotes\Terminal\[BrokerID]\MQL5\Experts\

Compilation

  1. Open MetaEditor (F4 in MT5)
  2. Locate the EA file in the Navigator
  3. Double-click to open
  4. Click "Compile" button or press F7
  5. Check for any errors in the "Errors" tab

Refresh Navigator

Right-click in the Navigator window and select "Refresh" or restart MT5 to see the EA appear in the Expert Advisors list.

2

Chart Setup

Attach to Chart

  1. Open a chart for your desired symbol
  2. Set the appropriate timeframe (recommended: H1 or H4)
  3. Ensure Donchian_Channel.ex5 indicator is available
  4. Drag the EA from Navigator onto the chart
  5. Alternatively: Right-click chart → Expert Advisors → Donchian Trend Breakout Pro

Enable Algo Trading

Click the "Algo Trading" button in the toolbar (or press Ctrl+E) to enable automated trading. The button should turn green.

Verify Attachment

A smiley face 😊 in the top-right corner indicates the EA is running. If you see a sad face â˜šī¸, check the Expert logs for errors.

3

Parameter Configuration

Access Settings

Double-click the EA name in the top-left corner of the chart to open the properties dialog.

Recommended Settings for Beginners

Lot Size 0.01 (micro lots) 0.10 (standard lots) 0.50 (large lots)
Channel Period 30 candles 20 candles 10 candles

Symbol-Specific Adjustments

  • Forex Majors (EUR/USD, GBP/USD): 20-period channel, moderate lot sizes
  • Forex Minors & Crosses: 25-period channel, slightly larger stops
  • Indices (US30, SPX500): 20-period channel, volatility-adjusted sizing
  • Commodities (Gold, Oil): 15-period channel for more frequent signals
4

Optimization & Backtesting

Strategy Tester

  1. Open Strategy Tester (View → Strategy Tester or Ctrl+R)
  2. Select Donchian Trend Breakout Pro from the dropdown
  3. Choose symbol and timeframe
  4. Set date range (at least 1 year recommended)
  5. Select "Every tick" or "1 minute OHLC" mode
  6. Click "Start" to run backtest

Optimization Process

  1. Click "Optimization" checkbox in Strategy Tester
  2. Select parameters to optimize (Lots, DonchianChannelCandles)
  3. Set min, max, and step values
  4. Choose optimization criterion (Balance, Profit Factor, Sharpe)
  5. Run optimization
  6. Analyze results in the "Optimization Results" tab

Forward Testing

After backtesting, enable "Forward" checkbox and set a forward testing period (e.g., last 3 months) to validate robustness.

âš ī¸ Optimization Best Practices

  • Don't over-optimize (curve fitting)
  • Use walk-forward optimization
  • Test on out-of-sample data
  • Validate on different symbols/timeframes
  • Consider slippage and spread
  • Check maximum drawdown carefully
5

Live Trading Deployment

Pre-Launch Checklist

Monitoring & Maintenance

  • Daily: Check for errors in Expert logs
  • Daily: Verify EA is still running (green button, smiley face)
  • Daily: Review open positions and recent trades
  • Weekly: Analyze performance metrics
  • Weekly: Adjust parameters if market conditions changed
  • Monthly: Full performance review and re-optimization if needed

Warning Signs to Watch For

  • âš ī¸ Consecutive losses exceeding normal expectation
  • âš ī¸ Drawdown approaching maximum acceptable level
  • âš ī¸ EA not opening trades when signals should occur
  • âš ī¸ Orders rejected by broker frequently
  • âš ī¸ Significant change in market volatility/conditions
  • âš ī¸ Donchian Channel indicator not loading properly

Technical Specifications

Platform Requirements

Platform MetaTrader 5
MQL Version Build 2600+
Build Build 2600+ recommended
Type Expert Advisor

Trading Specifications

Timeframes All timeframes supported
Best Timeframe H1, H4 recommended
Symbols All major pairs, indices, commodities
Execution Mode OnTick

Account Requirements

Min Balance $100+ recommended
Account Type Standard, ECN compatible
Hedging Not required
Leverage 1:100 or higher

Code Specifications

Lines of Code ~95 lines
Custom Functions Standard EA functions
Indicator Handles 1 (Donchian Channel)
Complexity Intermediate

Features Checklist

Broker & Server Compatibility

✅

Market Execution

Compatible with brokers using market execution

✅

ECN/STP Accounts

Works with ECN and STP account types

✅

4/5 Digit Brokers

Auto-adapts to 4 or 5 digit broker quotes

âš ī¸

Donchian Channel Required

Requires Donchian_Channel.ex5 indicator file

âš ī¸

VPS Recommended

For 24/7 operation, VPS hosting is recommended

âš ī¸

IMPORTANT RISK DISCLOSURE

Trading involves substantial risk of loss and may not be suitable for all investors.

Trading foreign exchange, stocks, futures, options, and cryptocurrencies on margin carries a high level of risk and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade, you should carefully consider your investment objectives, level of experience, and risk appetite. There is a possibility that you could sustain a loss of some or all of your initial investment. Therefore, you should not invest money that you cannot afford to lose.

About This Expert Advisor

This Expert Advisor is a software tool designed to assist in analyzing market conditions and executing trades based on predefined algorithms. It does not guarantee profits or success. Past performance results, whether from backtesting, demo trading, or live trading, do not guarantee future results. Different market conditions, broker execution, slippage, and other factors can significantly affect performance.

User Responsibility

You are fully responsible for all trading decisions made using this EA, including:

  • Parameter configuration and optimization
  • Risk management and position sizing
  • Monitoring and maintaining the EA
  • Understanding the trading logic and risks involved
  • Ensuring compatibility with your broker and account type
  • Providing the required Donchian Channel indicator file

No Warranties

KeyAlgos provides this Expert Advisor "as is" without any warranties, express or implied, including but not limited to warranties of merchantability, fitness for a particular purpose, or non-infringement. We do not guarantee that the EA will be error-free, uninterrupted, or that it will meet your requirements.

Recommendations

  • Always test the EA thoroughly on a demo account before live trading
  • Start with conservative risk settings and gradually increase if comfortable
  • Never risk more than you can afford to lose on a single trade
  • Regularly monitor the EA's performance and market conditions
  • Be prepared to intervene manually if unusual market conditions occur
  • Keep your MetaTrader platform and the EA updated
  • Ensure stable internet connection or use VPS for 24/7 operation
  • Ensure Donchian Channel indicator is properly installed and functional