This repository has been archived on 2026-01-12. You can view files and clone it, but cannot push or open issues or pull requests.
Kunthawat Greethong 7c7c118c5f Initial commit: MAEA Expert Advisor v1.00
- 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
2026-01-02 11:13:52 +07:00

MAEA - Moving Average Expert Advisor

Advanced trend-following Expert Advisor for MetaTrader 4 with sophisticated filtering and risk management features.

📋 Table of Contents

🎯 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:

  1. EMA High (Light Blue) - EMA of High prices
  2. EMA Medium (Yellow) - EMA of Close prices
  3. EMA Low (Orange) - EMA of Low prices

Border Lines (2 Dynamic Lines)

Calculated based on the range between EMAs:

  1. High Border (Purple) = EMA High + (EMA Medium - EMA Low)
  2. 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

  1. Download the EA:

    • Clone the repository: git clone https://git.moreminimore.com/kunthawat/MAEA.git
    • Or download MAEA.mq4 directly
  2. Copy to MT4:

    • Navigate to your MT4 data folder
    • Go to MQL4/Indicators or MQL4/Experts
    • Copy MAEA.mq4 to that folder
  3. Compile in MetaEditor:

    • Open MetaEditor (press F4 in MT4)
    • Open MAEA.mq4
    • Press F7 to compile
    • Ensure no compilation errors
  4. Attach to Chart:

    • Open MT4
    • Drag MAEA from Navigator to your chart
    • Recommended timeframe: H1
    • Configure parameters as needed
  5. 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

  1. Attach MAEA to an H1 chart
  2. Adjust parameters according to your risk tolerance
  3. Enable Auto Trading
  4. Monitor the EA's performance
  • 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:

  1. Check if Auto Trading is enabled (green button in MT4 toolbar)
  2. Verify EA is allowed in Tools → Options → Expert Advisors
  3. Check if filters are too restrictive:
    • Reduce MaxSpread if spread is too high
    • Disable UseMTFFilter temporarily
    • Disable UseNewsFilter temporarily
  4. Verify account has sufficient margin
  5. Check Experts tab for error messages

Compilation Errors

Problem: EA fails to compile in MetaEditor

Solutions:

  1. Ensure you're using MT4 (not MT5)
  2. Check for missing brackets or semicolons
  3. Verify all function names are spelled correctly
  4. Update MetaEditor to latest version

Incorrect Indicator Display

Problem: Lines not displaying correctly on chart

Solutions:

  1. Ensure sufficient historical data (at least 50 bars)
  2. Check if EMAPeriod is too high for available data
  3. Refresh chart (right-click → Refresh)
  4. Reattach EA to chart

Orders Closing Prematurely

Problem: Orders closing too early or not reaching TP

Solutions:

  1. Check if TakeProfitUSD is too low
  2. Verify MaxDrawdownPercent is not too restrictive
  3. Check if spread is causing SL hits
  4. Review trade logs for closure reasons

Drawdown Protection Triggering

Problem: EA stops trading due to drawdown

Solutions:

  1. Increase MaxDrawdownPercent if too conservative
  2. Wait for equity to recover above threshold
  3. Review trading strategy and risk settings
  4. Consider reducing lot sizes

Timezone Issues

Problem: News filter not working at expected times

Solutions:

  1. Verify your MT4 server timezone
  2. Adjust NewsAvoidHours accordingly
  3. Thailand timezone is UTC+7
  4. Test with different hour values

Performance Issues

Problem: EA slow or causing MT4 lag

Solutions:

  1. Reduce EMAPeriod for faster calculations
  2. Disable MTF filter if not needed
  3. Close unnecessary charts and indicators
  4. Check MT4 and computer performance

📝 Best Practices

  1. Start Small: Begin with minimum lot sizes and conservative settings
  2. Test Thoroughly: Use demo account before live trading
  3. Monitor Regularly: Check EA performance and adjust as needed
  4. Keep Records: Track trades and analyze performance
  5. Stay Informed: Be aware of market conditions and news events
  6. Use Stop Loss: Never disable risk management features
  7. 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:

📄 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)

Description
No description provided
Readme 66 KiB
Languages
MQL5 100%