Idea Creator: Scriptor.
MQL5 Code Author: Vladimir Karputov.
Introducing the Donchian Counter, an Expert Advisor (EA) designed for MetaTrader 5 that utilizes the Donchian Channel indicator. Keep in mind that this EA has a couple of limitations: it can only hold one position at a time, and you’ll need to wait a full 24 hours before opening a new trade.
The signals generated by the Donchian Channel are key to executing trades and utilizing the trailing stop function effectively.
Example of a BUY Signal: If the upper buffer of the indicator on the first bar exceeds that of the second bar, it's time to go long. Check out the visual below for clarity:

For SELL signals, we look at the lower buffer of the indicator: if the lower buffer on the first bar is below that of the second bar, that’s a green light to sell.
Input Parameters
- Lots: This determines the size of the position you want to open;
- Donchian Channel: Averaging Period: This is the indicator parameter you can adjust;
- Donchian Channel: Time Frame: Another adjustable parameter for the indicator;
- Magic Number: This is a unique ID for your EA, helping you manage your trades.
Here are the testing results on EURUSD with the default settings:

Related Posts
- Creating an Expert Advisor for Dark Cloud Cover and Piercing Line Patterns with CCI Confirmation
- Harnessing MQL5 Wizard for Trading Signals: 3 Black Crows & 3 White Soldiers with MFI
- Creating a Stochastic-Based EA for Hammer and Hanging Man Patterns in MetaTrader 5
- Mastering Bullish and Bearish Harami Patterns with Stochastic in MT5
- Mastering Trading Signals with MQL5 Wizard: Bullish and Bearish Engulfing Strategies