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

Top MQL4 and MQL5 source codes based on user ratings - 6

Submit your code

Market Profile MetaTrader indicator — is a classic Market Profile implementation that can show the price density over time, outlining the most important price levels, value area, and control value of a given trading session. This indicator can be attached to timeframes between M1 and D1 and will show the Market Profile for daily, weekly, monthly, or even intraday sessions. Lower timeframes offer higher precision. Higher timeframes are recommended for better visibility. It is also possible to use a free-draw rectangle session to create a custom market profile on any timeframe. Six different color schemes are available to draw the profile's blocks. Drawing profiles as a plain color histogram is also possible. Alternatively, you may choose to color the profile based on bullish/bearish bars. This indicator is based on bare price action and does not use any standard indicators. It is available for MetaTrader 4, MetaTrader 5

Gain/Loss Info MetaTrader indicator — displays the gains and losses for all candles where the given threshold is surpassed. The values are calculated in points and percentage. The indicator can calculate gain/loss in two modes: plain candlestick Close and Open difference, and as difference between current Close and previous Close. You can set minimum change limits (for pips and percentage), change modes, and you can also control font color of the output numbers. The indicator is available for both MT4 and MT5.

Keltner Channel (MetaTrader indicator) — is a classical technical analysis indicator developed by Chester W. Keltner in 1960. The indicator is somewhat similar to the Bollinger Bands and Envelopes. It uses three plot lines: the middle line is the 10-day simple moving average applied to the typical price ((high + low + close) / 3), the upper and the lower bands are produced by adding and subtracting the moving average of the daily price range (High and Low difference) from the middle line. This way, a volatility-based channel is built. In this version of the indicator you can modify all the parameters of the MA. The indicator is available both for MT4 and MT5 versions of the platform.

Pinbar Detector is a MetaTrader indicator that tries to detect Pinbars (also known as "Pin-bar" or "Pin bar") and marks them by placing a "smiling face" symbol below the bullish Pinbars and above the bearish Pinbars. It is a pure price action indicator, which is not using any standard technical indicators in its code. The configuration of Pinbar detection can be done via the indicator's input parameters. Pinbar Detector can issue platform alerts and email alerts on detection. The indicator is available both for MT4 and MT5 versions of the trading platform.

Point-and-Figure MetaTrader 5 indicator is an indicator that can plot a point-and-figure chart directly in the main window of your normal MT5 chart. You can set up all the point-and-figure method parameters, such as the box size and the reversal distance, according to your preference. In addition, you can control all the display parameters of the PnF chart. This point-and-figure indicator supports all sorts of alerts. It is based on real ticks data, and thus is available only for MT5.

RSIOMA MetaTrader indicator — this indicator takes two moving averages, calculates their RSI (Relative Strength Index) and then also adds a moving average of the calculated RSI. These two lines now can accurately signal the trend changes. They are shown in the separate window where they change from 0 to 100. The auxiliary histogram is shown for a quick-glance view of the current trend. The indicator is available for both MT4 and MT5 versions of the MetaTrader platform.

Schaff Trend Cycle (MetaTrader indicator) — is a cyclical oscillator created by calculating the stochastic over stochastic over a MACD line using cycles. The result is the improved version of the oscillator that is not choppy during the trends and reacts to the changes very fast. It was developed by Doug Schaff, who assumed that the currency trends accelerate and decelerate in cycles. Its algorithm was made public in 2008. Schaff Trend Cycle tries to combine two different methods of determining the trend direction changes — MACD and smoothed stochastic oscillator. The value of the indicator fluctuates between 0 and 100. Two trigger levels are used — 25 and 75. Optional alerts are available. You can download this indicator for MT4, MT5

Support and Resistance MetaTrader indicator — as the name of this indicator suggests, it displays the support and resistance levels. It shows them directly on the chart, providing an easy help when you want to set stop-loss or take-profit level, or when you want to see the next market target. This indicator uses the standard MetaTrader Fractals indicator (by Bill Williams' method) and has no changeable input parameters. This indicator is available for MetaTrader version 4 and 5.

Total Power Indicator (MetaTrader indicator) — is based on the two standard indicators — Bear Power and Bull Power. The indicator calculates how many bullish and bearish bars were there during a given look-back period and then calculates the proportional index for bears, bulls, and total (calculated as the absolute difference between bulls and bears) for the current bar. This way, we get continuous lines of the relative average bear and bull power over a period, removing the main disadvantage of the original Bear/Bull Power indicators — the lack of a long-term perspective. The original MetaTrader 4 version of Total Power Indicator was created by Daniel Fernandez of Asirikuy.com in 2011. The version for MT5 is now also available.

A script which when dragged onto the chart will print out in the experts window the number of bars that are on that chart - like magic.

A simple starting-point script to collect data and send to a CSV in oldest-newest ordering. In this example only the close price data is collected.

Download all the ticks from your broker for all the symbols in the market watch. Download all history or until a specific date in the past if available.

Whether you’re running multiple trading robots simultaneously or just one sophisticated strategy, keeping track of each Expert Advisor’s performance can be surprisingly time-consuming. MetaTrader 5 (MT5) conveniently displays orders and positions in its “Toolbox,” but when numerous robots share the same account, it becomes harder to know which EA is generating your profits—or losses. A single account might have dozens or hundreds of trades, each opened by different EAs, making it difficult to separate the results of one robot from another.

Time to candle Close. Dynamic text colours. Optimised for back-testing.

This is a piece of code to add to an existing Expert advisor to track withdrawals from your account where the EA is running. It helps the user to monitor his or her withdrawals from a particular account.

Candle Signature with Example | For Research and Development

The XMA_Ishimoku indicator with additional trend strength indication using colored dots based on the standard deviation algorithm. The original code in the attached link had plotting problems.

Parallel use of the MetaTrader 4 and MetaTrader 5 order systems.

The VR Alert NT5 indicator warns the trader about the price reaching a specified level.

The Slope Direction Line indicator is displayed as a colored moving average line indicating the average market movement direction.

Multiple runs/optimisations in Tester.

Holt's double exponential smoothing with linear forecasting

This version can use one of the 4 basic averages types for smoothing.

ALGLIB math function library (v. 3.19) ported to MQL5.

Serialization and deserialization of JSON protocol. The code is ported from a high-speed С++ library.

Adaptive Laguerre filter trend.

Highest high & lowest low support resistance

This is MQL5 version of Shved Supply and Demand written by Shved and upgraded by eevviill7 with history mode.

Detecting the start of a new bar or candle in an Expert Advisor's OnTick() event handler.

To use martingale money management when a position is in loss and price hits any of specific distances.

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

This function performs the main logic of opening a trade. Calculates the opening price, take profit levels and stop loss based on symbol information and parameters provided by the user. Prepare a trade request (MqlTradeRequest) with the necessary information, such as symbol, volume, order type, deviation, comment, magic number, etc. Call the OrderSend function to send the operation request and get the result. SetTypeFillingBySymbol function: Determines the order fill type (Fill or Kill, Immediate or Cancel, or Return) based on the symbol's filling policy. GetMinTradeLevel function: Calculates the minimum operating level based on the freeze level and the symbol stops level. Adjusts the minimum level to make sure it is within certain limits and returns the result.

Indicator based on basic slope moving average and cloud around. Indicator shows two types of signals: prepearing - dot and entry - arrow.

When applied to financial markets this method is usually used to determine the moments of prices extreme deviation from a "standard" level.

Class for displaying multi-line comments.

YMA

Moving average for prices (O+C+H+L)/4.

A variation on the T3 theme that was made as a sort of envelopes using T3 for basic value.

The Aroon indicator in the new visualization.

The newest version of ALMA.

The Dynamic Trend signal indicator draws a two-color trend direction line and adds signal arrows.

12345678910111213...188