- Implemented complete trend-following strategy with EMA-based signals - Added 5 visual indicator lines (3 EMAs + 2 Border Lines) - Implemented breakthrough and pullback signal detection - Added dynamic lot sizing (0.01/0.02 based on pullback) - Implemented comprehensive filters: * Volume filter (20-bar average) * Spread filter (max 30 points) * Multiple Timeframe filter (H1 trading, D1 trend confirmation) * News filter (Thailand timezone) - Added advanced risk management: * Take Profit in USD * Stop Loss at Border Lines * Breakeven (100 points) * Trailing Stop (100 points) * Max drawdown protection (10%) - Created comprehensive documentation - Connected to Gitea repository
MAEA - Moving Average Expert Advisor
Advanced trend-following Expert Advisor for MetaTrader 4 with sophisticated filtering and risk management features.
📋 Table of Contents
- Overview
- Features
- Strategy Details
- Installation
- Parameters
- Usage
- Visual Indicators
- Risk Management
- Troubleshooting
- Disclaimer
🎯 Overview
MAEA is a sophisticated trading robot that uses Exponential Moving Averages (EMAs) with dynamic border lines to identify trend-following opportunities. The EA includes multiple filters to ensure high-quality trade entries and comprehensive risk management to protect your account.
Repository: https://git.moreminimore.com/kunthawat/MAEA
Platform: MetaTrader 4
Language: MQL4
Timezone: Thailand (UTC+7)
✨ Features
Core Strategy
- 5 Visual Indicator Lines: 3 EMA lines + 2 dynamic Border Lines
- Breakthrough Signals: Entry when price breaks through EMA High/Low
- Pullback Signals: Enhanced lot sizing after pullback detection
- Dynamic Lot Sizing: 0.01 or 0.02 lots based on market behavior
- Single Order Management: Prevents over-trading
Advanced Filters
- Volume Filter: Trade only when volume exceeds 20-bar average
- Spread Filter: Avoid high spread periods (max 30 points)
- Multiple Timeframe Filter: D1 trend confirmation (optional)
- News Filter: Avoid specific hours/days (Thailand timezone, optional)
Risk Management
- Take Profit: Target in USD (default $5)
- Stop Loss: At dynamic Border Lines
- Breakeven: Move SL to entry at 100 points profit
- Trailing Stop: Trail by 100 points after breakeven
- Max Drawdown Protection: Stop trading at 10% drawdown
📊 Strategy Details
Indicator System
EMA Lines (3 Base Lines)
All EMAs use period 30 with different price sources:
- EMA High (Light Blue) - EMA of High prices
- EMA Medium (Yellow) - EMA of Close prices
- EMA Low (Orange) - EMA of Low prices
Border Lines (2 Dynamic Lines)
Calculated based on the range between EMAs:
- High Border (Purple) = EMA High + (EMA Medium - EMA Low)
- Low Border (Purple) = EMA Low - (EMA Medium - EMA Low)
Example Calculation:
EMA High = 3500
EMA Medium = 3400
EMA Low = 3300
Range = EMA Medium - EMA Low = 3400 - 3300 = 100
High Border = 3500 + 100 = 3600
Low Border = 3300 - 100 = 3200
Signal Types
1. Breakthrough Signal
- Buy Signal: Close price breaks above EMA High
- Sell Signal: Close price breaks below EMA Low
- Purpose: Triggers order opening
2. Pullback Signal
- Buy Pullback: Price moves down to hit any line, then closes above the line
- Sell Pullback: Price moves up to hit any line, then closes below the line
- Purpose: Increases lot size when breakthrough occurs in same direction
- Tracking: Separate for buy and sell directions
Order Management
- Single Order: Only one order at a time
- Dynamic Lot Sizing:
- 0.01 lot (no pullback before breakthrough)
- 0.02 lot (pullback occurred before breakthrough)
- Stop Loss: At Border Lines (Low Border for buys, High Border for sells)
- Take Profit: Target in USD (default $5)
- Breakeven: Move SL to entry at X points profit (default 100)
- Trailing Stop: Trail by X points after breakeven (default 100)
🚀 Installation
-
Download the EA:
- Clone the repository:
git clone https://git.moreminimore.com/kunthawat/MAEA.git - Or download
MAEA.mq4directly
- Clone the repository:
-
Copy to MT4:
- Navigate to your MT4 data folder
- Go to
MQL4/IndicatorsorMQL4/Experts - Copy
MAEA.mq4to that folder
-
Compile in MetaEditor:
- Open MetaEditor (press F4 in MT4)
- Open
MAEA.mq4 - Press F7 to compile
- Ensure no compilation errors
-
Attach to Chart:
- Open MT4
- Drag MAEA from Navigator to your chart
- Recommended timeframe: H1
- Configure parameters as needed
-
Enable Auto Trading:
- Click "Auto Trading" button in MT4 toolbar
- Ensure EA is allowed to trade in Tools → Options → Expert Advisors
⚙️ Parameters
EMA Settings
| Parameter | Default | Description |
|---|---|---|
EMAPeriod |
30 | EMA period for all lines |
Lot Settings
| Parameter | Default | Description |
|---|---|---|
LotSizeNormal |
0.01 | Lot size without pullback |
LotSizePullback |
0.02 | Lot size with pullback |
Risk Management
| Parameter | Default | Description |
|---|---|---|
TakeProfitUSD |
5.0 | Take profit target in USD |
BreakevenPoints |
100 | Points to trigger breakeven |
TrailingStopPoints |
100 | Trailing stop distance |
MaxDrawdownPercent |
10.0 | Maximum drawdown percentage |
Filters
| Parameter | Default | Description |
|---|---|---|
MaxSpread |
30 | Maximum allowed spread in points |
VolumePeriod |
20 | Period for volume average |
UseMTFFilter |
true | Enable MTF filter |
UseNewsFilter |
true | Enable news filter |
NewsAvoidHours |
"14,15,20,21" | Hours to avoid (Thailand time) |
NewsAvoidDays |
"1,5" | Days to avoid (Monday=1, Friday=5) |
General
| Parameter | Default | Description |
|---|---|---|
MagicNumber |
12345 | EA unique identifier |
📖 Usage
Basic Setup
- Attach MAEA to an H1 chart
- Adjust parameters according to your risk tolerance
- Enable Auto Trading
- Monitor the EA's performance
Recommended Timeframes
- Trading Timeframe: H1 (recommended)
- Filter Timeframe: D1 (for MTF filter)
Currency Pairs
- Works on all major currency pairs
- Best performance on trending pairs (EURUSD, GBPUSD, USDJPY)
Account Types
- Compatible with any MT4 account type
- Ensure sufficient margin for lot sizes
🎨 Visual Indicators
The EA displays 5 lines on your chart:
| Line | Color | Style | Description |
|---|---|---|---|
| EMA High | Light Blue | Solid | EMA of High prices |
| EMA Medium | Yellow | Solid | EMA of Close prices |
| EMA Low | Orange | Solid | EMA of Low prices |
| High Border | Purple | Dashed | Upper dynamic border |
| Low Border | Purple | Dashed | Lower dynamic border |
Reading the Indicators
- Price above all lines: Strong uptrend
- Price below all lines: Strong downtrend
- Price between lines: Consolidation/ranging
- Border Lines: Dynamic support/resistance levels
🛡️ Risk Management
Take Profit
- Closes order when profit reaches target amount in USD
- Automatically calculated based on lot size and symbol
Stop Loss
- Buy Orders: SL at Low Border Line
- Sell Orders: SL at High Border Line
- Moves dynamically as Border Lines update
Breakeven
- Triggered when profit reaches specified points (default 100)
- Moves Stop Loss to breakeven (entry price)
- Protects profits while allowing room for trend continuation
Trailing Stop
- Activates after breakeven is reached
- Trails Stop Loss by specified points (default 100)
- Locks in profits as trend continues
Drawdown Protection
- Calculates drawdown percentage from peak equity
- Stops trading if drawdown exceeds limit (default 10%)
- Resumes trading when drawdown is below limit
🔧 Troubleshooting
EA Not Opening Orders
Problem: EA is attached but not opening any orders
Solutions:
- Check if Auto Trading is enabled (green button in MT4 toolbar)
- Verify EA is allowed in Tools → Options → Expert Advisors
- Check if filters are too restrictive:
- Reduce
MaxSpreadif spread is too high - Disable
UseMTFFiltertemporarily - Disable
UseNewsFiltertemporarily
- Reduce
- Verify account has sufficient margin
- Check Experts tab for error messages
Compilation Errors
Problem: EA fails to compile in MetaEditor
Solutions:
- Ensure you're using MT4 (not MT5)
- Check for missing brackets or semicolons
- Verify all function names are spelled correctly
- Update MetaEditor to latest version
Incorrect Indicator Display
Problem: Lines not displaying correctly on chart
Solutions:
- Ensure sufficient historical data (at least 50 bars)
- Check if
EMAPeriodis too high for available data - Refresh chart (right-click → Refresh)
- Reattach EA to chart
Orders Closing Prematurely
Problem: Orders closing too early or not reaching TP
Solutions:
- Check if
TakeProfitUSDis too low - Verify
MaxDrawdownPercentis not too restrictive - Check if spread is causing SL hits
- Review trade logs for closure reasons
Drawdown Protection Triggering
Problem: EA stops trading due to drawdown
Solutions:
- Increase
MaxDrawdownPercentif too conservative - Wait for equity to recover above threshold
- Review trading strategy and risk settings
- Consider reducing lot sizes
Timezone Issues
Problem: News filter not working at expected times
Solutions:
- Verify your MT4 server timezone
- Adjust
NewsAvoidHoursaccordingly - Thailand timezone is UTC+7
- Test with different hour values
Performance Issues
Problem: EA slow or causing MT4 lag
Solutions:
- Reduce
EMAPeriodfor faster calculations - Disable MTF filter if not needed
- Close unnecessary charts and indicators
- Check MT4 and computer performance
📝 Best Practices
- Start Small: Begin with minimum lot sizes and conservative settings
- Test Thoroughly: Use demo account before live trading
- Monitor Regularly: Check EA performance and adjust as needed
- Keep Records: Track trades and analyze performance
- Stay Informed: Be aware of market conditions and news events
- Use Stop Loss: Never disable risk management features
- Diversify: Don't rely on a single EA or strategy
⚠️ Disclaimer
IMPORTANT NOTICE:
Trading Forex and CFDs involves significant risk of loss and may not be suitable for all investors. MAEA is provided as-is without any warranty or guarantee of performance.
- Past performance is not indicative of future results
- Always trade with money you can afford to lose
- Test thoroughly on demo accounts before live trading
- The authors are not responsible for any financial losses
- Use at your own risk
By using MAEA, you acknowledge that:
- You understand the risks involved in trading
- You are solely responsible for your trading decisions
- You will not hold the authors liable for any losses
- You have read and understood this disclaimer
📞 Support
For issues, questions, or contributions:
- Repository: https://git.moreminimore.com/kunthawat/MAEA
- Issues: Report bugs or request features via repository issues
📄 License
This project is provided for educational and research purposes. Use responsibly and in accordance with your broker's terms of service.
Version: 1.00
Last Updated: 2026-01-02
Timezone: Thailand (UTC+7)