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

MQL4 Source Code Library for MetaTrader 4


The largest library features codes of free trading Expert Advisors, technical indicators and scripts. With the available applications you can trade in automated mode and analyze price dynamics. Use the library of codes to learn more about financial market sentiments.

Download free applications, test them and run in your MetaTrader 4. You can access them from the MetaTrader 4 platform and the MetaEditor development environment.

Submit your code

Classic & Virtual Trailing for MT4

Virtual SL TP Pending with SL Trailing for Symbol Chart

This MQL4 EA is designed to close positions for a basket of currency pairs based on certain profit and loss thresholds.

Reverses all open trades after Closure for all symbols .

Trailing_StopLoss_for All_orders_and_symbols

Simple continuous trend-following strategy for buying and selling based on predefined conditions

Bars Pips for Chart Symbol and Period selected

Hedge Symbol 100%

Changing the size of the chart window is important in my EA, but it may serve as inspiration for others.

Open Charts

Simple banner showing Symbol Spread Equity Profit Banner

Orders Closure

Hedge with a stop order, instead of placing a Stop Loss.

Short description.

Short description.


Hedge Dollar index USIDX against its constitutive FOREX pairs EURUSD GBPUSD USDJPY USDCAD USDSEK USDCHF

Break on Code Error ! This script is a general example of using error brake in any strategy.

simple trail stop loss code example.

This is an indicator to calculate 14 types of moving averages based on close price.

This is a indicator to plot hidden and regular divergences on chart.

Many Expert Advisors (EAs) tend to close orders at the take profit level, considering the pip distance from the purchase price.

[@Buy_Sell_Close] Manual trading EA for trading newbies, EA can be used in backtesting visual mode, EA can also be used in live trading. You can practice your own trading system in backtesting.

AVA adapts its analysis based on current market dynamics. This adaptability makes it invaluable for predicting shifts towards higher volatility or calmer periods.

this shortcode will calculate the drawdown of a particular ea, where it is applied to a specified symbol.

The Breakeven Point, or Titik Impas, denotes the price level at which a trade's profit becomes zero. By setting a position to Titik Impas Breakeven, the stop-loss is aligned with the position's opening price. This strategy proves valuable when you aim to allow profits to accumulate while ensuring that the trade remains secure and does not revert to negative territory.

Displays the gains and losses for all candles where the given threshold is surpassed. The values are calculated in points and percentage.

mt4 version of original indicator

When we want to know how many times price will goes up and down 40 pips before breaking this channel, we will need Bounce Number tool.

SSH is popular indicator as it uses simply two moving averages. This version is a mylti-TF of SSH with TF change ability from screen.

This is the exact conversion of pivotshigh and pivotslow functions from pine script v4 as an mql4 indicator.

This strategy eliminates the need to rely on indicators, candlestick patterns, chart patterns, or any price action. This EA employs a progressive system that I have been using for the past six months and have backtested for over three years.

All open trades must be of same symbol and type, e.g. all GBPUSD and all BUY. This script will close out your position using one large trade to hedge your position then using CloseBy() function to close all trades against the one large trade until all trades are closed. There can be a maximum of 500 open trades.

A simpler way to display Heikin Ashi

a Simple Visual Strategy Tester / Manual Trade Training using Martingale.

The purpose of this indicator is to demonstrate newbie friendly way a structure of a multi time frame indicator based on recursion.

Few improvements from standart fractal: 1. You can chouse size of fractal. Standart version use 2 as constant 2. It does not draw fractals against the trend, which makes your chart much more informative

Show MACD directly on chart

Donchian Channel with mid line and moving average of mid line. Updated Dec 6, 2023 Minor code update

The Oscillator Indicator for MetaTrader 4 is a powerful tool that accurately identifies the perfect signal on the completion of trends.