Watch how to download trading robots for free
Find us on Facebook!
Join our fan page
Access the CodeBase from your MetaTrader 5 terminal
Couldn't find the right code? Order it in the Freelance section
How to Write an Expert Advisor or an Indicator

MQL5 Source Codes of Expert Advisors for MetaTrader 5 - 19

icon

Expert Advisors analyze price charts and trade automatically following underlying rules. Here you can find MQL5 source codes solving a variety of problems. You are able to select both simple Expert Advisors based on moving average crossing and complex ones involving complicated signal generation algorithms and protection against trading mistakes.

You can download and launch offered Expert Advisors in MetaTrader 5. It is recommended that you test and optimize trading robots in the Strategy Tester before using them. The library of Expert Advisors is also available directly from MetaTrader 5 platform and MetaEditor development environment.

Submit your code

The Expert Advisor is based on the following indicators: RSI, WPR, Stochastic, Moving Average, deMarker

Modification of StopLoss of any positions. Trailing. Trailing.

Opens a SELL position on each bar, if Close of the 1st bar > Close of the 3rd bar. Opens a BUY position on each bar, if Close of the 3rd bar > Close of the 1st bar.

10 pips per day opposite to the "yesterday's trend".

The Expert Advisor trades by two iMA (Moving Average, MA) indicators. Trailing Stop. TrailingStop

The Expert Advisor uses the following indicators: Ichimoku, MA, SAR. Optimized for currency pairs: GBPUSD and EURUSD with the M30 timeframe. The full description is available in the code.

The Exp_TDI-2_ReOpen trading system based on the intersection of TDI-2 indicator lines, with adding to trend-following positions.

SilverTrend v3 - trading based on the analysis of the High, Low and Close prices of bars.

The New Martin Expert Advisor opens two opposite positions upon start. OnTradeTransaction handling. When Take Profit triggers, it opens a position (one position) in the same direction. The intersection of two MA indicators is a signal to open a position of a larger lot.

The simplest EA based on the Fractal_WeightOscillator weighted oscillator.

The MARE5.1 Expert Advisor is very easy to use. It uses the values of two Moving Averages (SMA) at the close of 0th, 2nd and 5th bar. The EA is configured to work on the M1 timeframe.

Trading on a new bar only. The rules are simple: if MAIN_LINE MACD (1) > MAIN_LINE MACD (2) -> Buy, if MAIN_LINE MACD (1) < MAIN_LINE MACD (2) -> Sell". When a signal opposite to open positions is received, close all positions.

The Expert Advisor uses the MACD, OsMA and WPR indicators. The Expert Advisor is configured to trade on the D1 timeframe with USDCHF, GBPUSD, USDJPY and EURUSD

The Expert Advisor synchronizes the local computer time in the interval from 9:50 to 9:59 (before the beginning of the morning session) with the MetaTrader 5 FORTS server time.

The strategy is based on Moving Averages with the periods of 5/20/40/60.

Trading based on the Bollinger Bands indicator. Chart time-frame — M30 and higher.

The Expert Advisor identifies trend based on three moving averages (with periods of 200, 50, 25 or other custom periods), and opens trades using the Parabolic SAR indicator. The EA uses martingale techniques, lot is calculated as percent of deposit depending on stop loss.

MACD based Expert Advisor

The Expert Advisor has been created using the MQL5 Wizard, on the basis of MACD (Moving Average Convergence/Divergence) signals and the Parabolic SAR trend indicator.

The iMAs on the current period.

Two iMA indicators with hard coded periods of 3 and 7, and on iRSI indicator with the period of 2.

The Expert Advisor makes trading decisions based on simple candlestick combinations. It is designed for use on the H4 period.

Two iMAs on the current period and one on PERIOD_D1.

Pending Buy Limit (BuyLimit) and Sell Limit (SellLimit) orders. Using OnTradeTransaction().

Analysis of bars, if they contain N consecutive bars of the same type.

Trading by Moving Average. Checking for sufficiency of funds.

RSI EA - trading based on overbought/oversold zones determined by the iRSI (Relative Strength Index, RSI) indicator.

An example for calculating the lot value with a fixed margin level. That is, if you specify 10%, a position with the margin equal to 10% of free margin will be opened.

The Expert Advisor places two pending orders at a certain time.

A tick Expert Advisor. It compares the price on the previous tick and the current price.

Comparing open prices of the zero and third bar.

The EA works based on the analysis of Open, High and Low.

An example of an Expert Advisor with a Trailing Stop implementation.

The EA places pending stop orders BUY_STOP and SELL_STOP.

The Expert Advisor places two pending orders (BuyStop and SellStop) with the specified expiration.

The Expert Advisor uses the values of two iMA (Moving Average, MA) indicators.

Uses two iStochastic (Stochastic Oscillator) indicators and one iRSI (RSI, Relative Strength Index). Calculates the lot size based on the analysis of closed trades.

The Expert Advisor searches for the momentum: iClose(t2)-iClose(t1).

The Expert Advisor opens or closes positions at the intersection of lines.

The Expert Advisor uses Parabolic SAR and three EMAs (with the periods of 10, 25 and 50).

1...121314151617181920212223242526...36