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 solves the problem of position trailing along a given curve by moving its Stop Loss and Take Profit.

The trading system is based on direction changes of the wighted oscillator WeightOscillator

An example of receiving the High and Low prices of bars over the past 24 hours.

Trading system using the IBS_RSI_CCI_v4 indicator

The strategy uses two indicators Moving Average, MA with different periods, Commodity Channel Index, CCI and Williams’ Percent Range, %R.

The trading strategy uses two MA indicators, one ATR and one CCI.

The strategy is based on two indicators: ADX and MA, and the close of the first bar. Also, different TakeProfit, StopLoss and Trailing levels are used for Buy and Sell.

An assessment is made based on the values of five indicators (Gator, WPR, AC, DeMarker and RSI). Uses trapezoidal membership functions. Before sending a trade request, it checks if funds on the account are enough.

The Expert Advisor idea is based on the constant change of trade direction depending on the TakeProfit, StopLoss and TrailingStop levels.

The "MQL5 Wizard MA RSI" Expert Advisor has been generated using the MQL5 Wizard based on the signals of the trend MA (Moving Average) indicator and of the RSI (Relative Strength Index) oscillator.

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.

1...121314151617181920212223242526...36