Two Moving Average Crossover Expert Advisor

Two Moving Average Crossover Expert Advisor
Download ALL MT4 experts (893)
YouTube Video Thumbnail



Similar MetaTrader Tools

Two Moving Average Crossover Expert Advisor

Info

The Two Moving Average Crossover Expert Advisor is a Expert Advisor for MetaTrader 4 that this expert advisor operates based on the crossover of two moving average lines. Trading Logic:A buy order is opened if the fast Moving Average is above the slow Moving Average and the distance between them exceeds a specified threshold.

Usage

This tool is typically used for automated trading on major forex pairs and gold.

Platform

This Expert Advisor works exclusively on MetaTrader 4 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL4/Experts folder via File ? Open Data Folder in MetaTrader 4.


How to Install and Use Two Moving Average Crossover Expert Advisor

1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.

2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.

3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.

4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.

Frequently Asked Questions

Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.

Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.

Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.

What this tool does

This Expert Advisor operates based on the crossover of two Moving Average lines.

Typical Use Case

This Expert Advisor excels in automated trading and technical analysis on MetaTrader 4.

Compatible Platform & Setup

This Expert Advisor works on MetaTrader 4. Place the file in the MQL4/Experts folder and restart the terminal.

Description & Settings

Related: e-moving in wl2: automated stop loss adjustment - another powerful expert for MetaTrader 4 traders.

This Expert Advisor operates based on the crossover of two Moving Average lines.

Also recommended: moving average grid ea - similar expert with strong performance on MetaTrader 4.


Trading Logic:

A buy order is opened if the fast Moving Average is above the slow Moving Average and the distance between them exceeds a specified threshold.
A sell order is opened under the opposite indicator conditions.
Orders are closed based on Moving Average indicator crossovers.

Additional Plugin Modules:

- Distance between Fast and Slow Moving Averages
- Take Profit
- Stop Loss
- Trailing Stop
- Order Distance (Step Up)
- Order Distance (Step Down)
- Take Profit Averaging Methods
- Trade Time
- Turn Module
- Lot Increase for Subsequent Orders


Expert Advisor Algorithm:

The EA first checks for existing open orders.

If no orders are open, it analyzes the chart. If all user-defined settings are met, it places the initial main order.

Upon opening the initial main order, the EA sets Take Profit and Stop Loss levels, if these modules are enabled.

If the initial main order is closed at a loss, the subsequent order may be placed with an increased lot size.

If the initial main order is placed and the Step Up and Step Down modules are active, with the price reaching specified values, additional orders are placed according to these modules. These additional orders are contingent on the EA having previously opened the initial main order or having unclosed additional orders.


Operation Modes:

Mode 1: If the trend changes (fast MA crosses below slow MA), all open orders are closed, and opposite orders are initiated.

Mode 2: If the trend changes while buy orders are open (fast MA crosses below slow MA), the open orders remain. Sell orders are only placed when the fast MA is below the slow MA and all existing EA orders are closed (via Take Profit, Stop Loss, or manually).


Trade Time Module:

If activated, this module restricts the placement of the initial main order to a specified time period. This module does not affect additional orders from the Step Up, Step Down, or Turn modules. If previous orders exist and any of these modules are activated, additional orders will be placed irrespective of the time.


Expert Advisor Settings:

Operation Mode:
1 - Close all open orders and open opposite orders upon trend change.
2 - Do not close open orders upon trend change; wait for Take Profit, Stop Loss, or manual closure.

Fast MA Settings:
Period, Offset, MA Method. Uses the Moving Average indicator available in MetaTrader 4.

Slow MA Settings:
Period, Offset, MA Method. Uses the Moving Average indicator available in MetaTrader 4.

Initial Lot Settings:

Lot Calculation Method:
Constant Lot: The initial lot size remains fixed as specified.
Dynamic Lot: The initial lot size is recalculated based on account balance and risk percentage.
lots - Sets the fixed initial lot size.
riskpercent - Sets the initial lot size dynamically based on account balance and risk percentage.

Lot Increase Settings:

firstlotmultiplicator - The multiplier for increasing the lot size of subsequent initial main orders if the previous one closed at a loss.
first_lotsize - If the initial main order reaches this size, a new Take Profit level is applied as defined in first_lotsize_takeprofit.
first_lotsize_takeprofit - A modified Take Profit level for the initial main order when it reaches the size specified in first_lotsize.
first_maxlotsize - The maximum lot size for the initial main order. If the calculated size exceeds this value, the EA reverts to the lot size defined in the initial lot settings.

Distance Between Moving Averages:

distance - The required distance between the fast and slow Moving Averages, in chart points, to open an order. Enable (true) or disable (false).

Take Profit (Points):

takeprofit - The target profit in points for closing an order or a group of orders. Enable (true) or disable (false).
averaging method (varyant) - Selects the Take Profit level averaging method (1 or 2).
Varyant 1: The averaging level is calculated as (Sum of opening prices) / Number of orders + Take Profit level.
Varyant 2: The averaging level is calculated by determining the

You may also like: average range monitor (arm) - excellent alternative for expert users on MetaTrader 4.

Source Code

/*------------------------------------------------------------------------------------------------------------------------------- specification ---//
enum enum_tf { current=0,m1=1,m5=5,m15=15,m30=30,h1=60,h4=240,d1=1440,w1=10080,mn1=43200 };
extern             string _0_="___   ___";
extern                int trademode=1;
extern             string _1_="___  fast ma ___";
extern                int period_=13,
shift_=0;
extern     enum_ma_method method_ma_=mode_sma;
extern enum_applied_price apply_to_=price_close;
extern             string _2_="___  slow ma ___";

.......

Leave your opinion, ask a question, share some knowledge

⚠ Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.