Watch how to download trading robots for free
Find us on Telegram!
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 - 2

icon

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

Detrended Price Oscillator (MetaTrader indicator) — a version of the price oscillator based on the difference between the current price and the simple moving average shifted by (Period / 2) + 1 bars. Unlike the stochastic oscillator, this indicator aims to show the short-term trend changes (price waves inside the long-term trend). The indicator is displayed in the separate window of the chart. You can use this Detrended Price Oscillator (DPO) indicator in both MT4 and MT5 versions of the platform.

Daily Percentage Change (MetaTrader indicator) — calculates the change of currency rate related to the previous daily close and displays it in percentage points in the main chart window of the platform. Additionally, it can display the weekly and monthly percentage changes. Different colors can be set for positive or negative price increases. Also, a small customizable arrow helps to visualize the price change direction. If your broker uses an unconventional time zone, the indicator can use Time Shift parameter to adjust the hour it will use for the day's end. The indicator works equally well in MT4 and MT5.

Coppock MetaTrader indicator — is an implementation of the famous Coppock curve indicator first created by Edward Coppock in 1962. The indicator shows long-term buy and sell opportunities (classically, it is used for only buying) by measuring the weighted moving average (with a period of 10) of the sum of two rates of change (with a period of 14 and 11). It is the classical version. In this MetaTrader version, you can modify the parameters of the basic indicators. You can use this Coppock indicator in MT4 and MT5.

CCI Arrows MetaTrader indicator — will show you where the CCI cross with the zero occur (marking it with the red or blue arrow) to help you decide whether to go short or long. It has a minimal lag and a relatively high accuracy. This simple indicator is a good choice for those traders that prefer to keep it simple and hate complex indicators. CCI Arrows supports all types of alerts. The indicator is available in MT4 and MT5 versions.

Candle Wicks Length Display MetaTrader indicator is an indicator that can display the length of candle wicks in pips directly on your chart. You can set the minimum length to be displayed. Alternatively, it can show wick lengths that are less than the given limit. The indicator supports all sorts of alerts and works with both MT4 and MT5.

Bollinger Squeeze Basic MetaTrader indicator — is a complex indicator based on Momentum, Bollinger bands, and Keltner channel. The indicator is drawn in the separate window of the chart as a Momentum histogram and a range of dots when show the relationship between the current Bollinger bands and Keltner channel values. This indicator is available for both MT4 and MT5 versions of the trading platform.

Bollinger Squeeze Advanced MetaTrader indicator — is a complex indicator consisting of two components: A measure of trendedness based on the Bollinger bands and Keltner channel "squeeze". A trend direction and strength histogram based on one of the following eight oscillators: Stochastic, CCI, RSI, MACD, Momentum, Williams % Range, ADX, DeMarker.

BMA MetaTrader indicator or Band Moving Average — was created by using the original moving average indicator and the idea from one of the site's visitors. The indicator displays itself in the form of three lines: the central one is the standard MT4/MT5 moving average (which can be simple, exponential or weighted), the upper line is the same as the central one but lifted up by 2% (by default), the lower line is the same as the central one but pushed down by 2%. Those two additional lines serve as the support and resistance levels. The indicator is available for both MT4 and MT5.

Beginner MetaTrader indicator — a very simple custom indicator that displays the local tops and bottoms on the chart with the red and blue dots near them. It analyzes the maximum and minimums on the certain period and then compares them to the range, in which the currency pair was trading, and if the top/bottom is significant enough, it marks it with the dot. This indicator redraws itself and thus should not be used for generating trading signals as the dots' positions may change. Both MT4 and MT5 versions of the indicator are available.

BB MACD MetaTrader indicator — is a basic MACD (Moving Average Convergence Divergence) indicator variation, which helps in detecting the trend change points and measuring the current trend's strength. The indicator is drawn in the separate window on the chart and consists of two lines (blue and red) and the dots, which can be either green or magenta. The change of the dots' color is a good signal provider, while the width of gap between the two lines indicates the strength of the current trend. This indicator is available for MT4 and MT5.

Basing Candlesticks MetaTrader indicator — is an automatic indicator that detects and marks basing candles on the chart. A basing candle is a candle with body length less than 50% of its high-low range. The indicator highlights the basing candles using histogram lines (in MT4) or custom candles (in MT5) directly in the main chart of the platform. The percentage criterion can be changed via input parameters. You can also turn on alerts for when a new basing candle appears.

Aroon Up & Down MetaTrader indicator — detecting the local tops and bottoms of the chart it was applied to, this indicator provides the signals for buying and selling the currency pairs when they rise up from the bottom and fall from the top. The cross of the indicator lines provide a good signal to take the profit or to exit with a minimum loss. This indicator can send sound and e-mail alerts on the cross. It is available in both MT4 and MT5 versions.

3rd Generation Moving Average is an advanced version of the standard moving average (MA) indicator for MetaTrader. It implements a rather simple lag-reducing procedure based on the longer MA period. The method was first described by M. Duerschner in his article Gleitende Durchschnitte 3.0 (in German). The presented version uses λ = 2, which provides the best possible lag-reducing. Higher λ increases similarity with the classic moving average. The indicator is available for both MT4 and MT5. It does not require using any DLL

Breakeven Line Indicator is a MetaTrader indicator that calculates breakeven level based on all open positions and displays it on your chart as a horizontal line. Additionally, it will calculate the total number trades, the total number of lots, and the distance to the breakeven line in points and profit/loss. The indicator is available for both MT4 and MT5.

Negative Volume Index (NVI) is a free technical indicator for advanced chart analysis in MT4, MT5 platforms. It is based on tick volume (can be substituted with real volume in MT5) and has two useful features added:

CloseAllOrdersEA for MetaTrader 4 closes all existing orders upon initialization. It works by: OnInit: Calls CloseAllOrders to shut down all market and pending orders. OnDeinit: Only logs deinitialization. OnTick: No action needed as orders are closed on start. CloseAllOrders: Loops from last to first order, retries up to 3 times to close/delete orders with error handling, uses current price for market orders, and deletes pending orders. Error Handling: Logs detailed errors for unsuccessful operations.

Candle Range MetaTrader indicator — is a very simple and lightweight indicator that displays the candle's range in pips on mouseover. In addition, to the High/Low range, it can optionally display the body size (Open/Close) for candles. Multiple display parameters are available to control how the indicator looks. This indicator is available for both MT4 and MT5 versions of the trading platform.

A real-time monitoring tool for MetaTrader 4 that displays key financial data, allows quick symbol switching, and customizable symbol lists. Save and reload symbols, reset lists, and customize text and panel colors for a personalized trading experience.

Symbol Swap Panel: Effortlessly switch the active symbol on your chart while simultaneously adding the new symbol to Market Watch. This tool ensures seamless integration and access to real-time market data, optimizing your trading workflow.

The indicator shows the names of the days of the week as text labels on the chart.

Moving average with calculated period based on timeframe

This is a pretty simple startegy that follows trend. Recommended time frams is D1. when close price brakes up the EMA build based on high prices given that RSI is above 55 and RSI is above its Moving average - we buy. when close price brakes down the EMA build based on low prices given that RSI is below 45 and RSI is below its moving average - we sell. system closes previose trade if there is opposite signal system uses take profit and stop loss as well as trailing stop

ZigZag with automatic step size detection for changing wave direction.

Another version of ZigZag, where the step size for changing the direction of the segment is set in price points.

Double ZigZag draws virtual Buy and Sell levels on the price chart.

The indicator draws the nearest levels of the specified price range.

A new interface library has been developed to simplify converting MT4 indicators and Expert Advisors (EAs) to MT5. This library supports most of the MetaTrader 4 functions, offering developers a unified solution for cross-platform compatibility.

The same PNB from Yousufkhodja Sultonov.

The indicator displays the actual range of the hourly candle in percent and the calculated range based on average statistics.

The indicator searches for candles on the price chart that are larger than the size specified in the settings and marks them on the chart.

Backtesting Trade Assistant Panel

This expert opens trades based on signals from multiple technical indicators.

The Doji Pattern Detector EA is designed to automatically detect the classic Doji candlestick pattern on any chart. A Doji pattern occurs when the open and close prices of a candle are very close to each other, signaling market indecision. This EA identifies Doji candles where the open and close prices are within a small range and positioned near the midpoint of the candle's high and low.

The PrevDayLines.mq4 script is a tool for MetaTrader 4 that automatically draws three critical price levels from the previous trading day on your chart. These levels include the highest price (Max), the lowest price (Min), and the average price (Avg), providing traders with a clear visual reference for key support and resistance points.

The script creates a text object on the chart that continuously rotates and changes its position based on price levels.

This is a template switcher script mq4 file. This script will work with your MT4 (Metatrader 4) platform. It is to switch between templates.

The Trend Strength Index indicator measures strength of current trend.

This code can detect if its a friday of the first week of the month. It is usually to detect days with NFP. Sone trader dont want to trade at that day. Maybe this code can help some one who need it

change of MA curve to horizontal line and DPO curve shall represent the distance from close price to zero level (or MA curve)

Linear Regression Value (metatrader 4 version)

123456789...104