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

Top scripts for MetaTrader 5 based on user ratings - 2

Submit your code

Script to set Stop Loss on every open position based on a target loss in the account's currency (e.g. $50 per position). Works on any deposit currency and any forex symbol. Validates broker stops/freeze levels. Currency conversion handled automatically.

Open-source MT5 script that records XAUUSD/GOLD symbol settings, spread, tick value, contract size, volume step, stop/freeze levels, swap, and account context to the log and optional CSV.

Read-only MT5 script reporting broker volume, price, stops, freeze, spread and execution constraints.

Measures whether a drawing indicator repaints, instead of asserting that it does not. The invariant: once a bar has closed and been processed, no object drawn on it may ever change - not move, not recolour, not change its text, and not disappear. The script seeds a custom symbol with real history, attaches your indicator through a template, records every object, appends bars, forces a full recalculation, and compares object by object. Changes and disappearances are counted separately, because only a change means the claim is false. A run that compared nothing is reported as INCONCLUSIVE, never as a pass. Output is a CSV you can publish next to the number.

Sizes your next trade based on the correlated risk you already have open across other positions — not just the trade in isolation.

A datetime in MQL5 is seconds since 1970 - but server time (TimeCurrent, bar times, deal times) is the broker's wall clock stored AS IF it were UTC. Export it to CSV, read it in Python or a spreadsheet with a "seconds since 1970 UTC" parser, and every timestamp shifts by the server's UTC offset. On a UTC-3 broker that is three hours: the daily bar dated 00:00 reads as 21:00 of the previous day, and "yesterday's session" silently becomes "today's, half formed". That happened to a morning report of mine before this script existed. The script prints TimeTradeServer, TimeCurrent, TimeGMT and TimeLocal, the three offsets between them, the tick lag, and this chart's last bar time in server time and in real UTC - then states the rule: export server timestamps as wall-clock text, or export the epoch together with the offset, and never let the consumer apply its own timezone.

Set TakeProfit by just dragging and dropping script on the desired price level.

Time-related functions for empirical detection of server time zone and daylight savings mode (DST) from history of quotes

This is a simple script file to compute lot size either using risk percentage approach or the actual amount to risk.

This Script collects all MQL5 built-in indicators buffers and stores them in a CSV file for analysis purposes

This script is a reference solution for mapping symbol names configured by users in MetaTrader 5 EAs or scripts to the actual names provided by the broker. It uses the Levenshtein distance algorithm to automatically identify the most similar symbol in Market Watch. It is ideal for developers facing compatibility issues with prefixes or suffixes in symbol names. This is a customizable starting point to adapt to any specific needs.

Candle Signature with Example | For Research and Development

Showing different ways of the Aroon values calculation

One-click CSV export of trade history with P&L, duration & stats

A pure-MQL5 script that measures how robust a strategy's edge is to execution costs. It reads a Date,Profit,Volume CSV of closing deals and models each deal's cost as a fixed part plus a per-lot part. It prints the breakeven cost per deal, the cushion (the multiple of an assumed realistic cost at which the net profit reaches zero), the net profit and profit factor re-priced at the assumed cost, the share of winners the cost turns into losers, and a composite A+ to F cost-robustness score with recommendations. If no file is present it generates a reproducible sample and analyzes it, so the output is visible on the first run. No external libraries, no Python, no AI.

This CalculateHistoryProfit script version 1.0 is designed to calculate profit for a specified period using a chart panel.

Diagnostic script that compares SYMBOL_TRADE_TICK_VALUE, SYMBOL_TRADE_TICK_VALUE_LOSS and SYMBOL_TRADE_TICK_VALUE_PROFIT for every symbol in Market Watch. Classifies each symbol into one of four categories (ALL_EQUAL, TV_MATCHES_PROFIT, TV_MATCHES_LOSS, ALL_DIFFER) and provides an aggregated summary plus interpretation tip. Useful for verifying which tick-value property to rely on when implementing risk-based lot sizing in EAs. Exports full per-symbol report to CSV in MQL5/Files.

This is a simple program to compare asynchronous and synchronous all close. It is a sample program, so feel free to modify it for your own testing purposes, such as adding conditions.

The script shows the usage of L1 Trend Filter methods in MQL5 for float and double vectors on random walk simulated data.

It will delete all objects on the chart when the compiled executable is dragged onto the chart

A quick little script to make traders' lives easier. The one thing that always annoys me is resetting the properties like colors for a new chart, to make it look the way i like it. So Here is a script to make things smoother.

Provide simplest class to read and parse CSV file

Script to determine whether your Broker follows the US, UK or AU daylight (DST) schedule.

Export history of closed positions from MT5 retail hedging account selected between two dates. The resulting file is CSV that can be opened/imported with any spreadsheet software.

This is a script to print all open trades and their PnLs at a specific time in history.

Script for partially close active buy orders

Partially close active sell orders

MQL5 script for MetaTrader 5 that adds two buttons to close all buy or sell positions for the current symbol.

Provide simplest class to write CSV file

This script serves as a practical example of how developers can programmatically work with files using MQL5. One of its key objectives is to demonstrate effective project file organization, which is essential for developers working on large-scale systems or aiming to create portable, self-contained projects. The concept can be expanded further and refined with additional ideas to support more advanced development workflows.

A native MQL5 script that analyzes the structure of an account's drawdowns, not just the single "maximum drawdown" figure. It reads a daily equity curve (Date,DailyPnL CSV), rebuilds the underwater curve, and splits it into individual drawdown episodes with their depth, duration and recovery time. It then reports the Ulcer Index, Pain Index, Recovery Factor and time spent underwater, and combines them into a single resilience score (A+ to F) with recommendations, printed in the Experts tab. No external libraries; if no file is found it generates a sample curve so it runs out of the box.

Exports your closed positions for a configurable period to a CSV file for journal analysis in Excel or Google Sheets: entry and exit time and price (volume-weighted over partial fills), volume, result in points, commission, swap, net profit and trade duration.

Reads a closed-position trade history (a CSV file, or one generated automatically from the current account's deal history by the companion RuinExport.mq5 script) and reports four independent risk fingerprints: volume escalation after a loss, overlapping same-direction exposure that averages into a worse price, payoff asymmetry between wins and losses, and a classical risk-of-ruin estimate at a stated risk per trade. The four scores combine into a single A-to-F grade with plain-language recommendations. If no CSV is found, the script generates a reproducible demonstration book automatically, so the report is visible on the first run.

Read-only analytics for accounts that run several Expert Advisors. It groups closed trades by magic number and measures what running those systems together actually saves you: standalone versus combined drawdown, the pairwise correlation matrix drawn as a heat map on the chart, and a Monte Carlo reshuffle of the portfolio's period returns.

Checks a hypothetical MT5 market or pending order against current symbol, volume, tick-size, stop-distance and filling rules without sending a trade.

A native MQL5 tool that reconstructs closed positions from deal-level history, flags the ones closed through more than one exit, and reprices each one at its own first, last, and best exit rates to measure whether scaling out actually added value. Reports a Value-Add Ratio, a Scale Out Win Rate, an Efficiency figure, and a single-trade dependence check, combined into an A+ to F score with recommendations. Runs out of the box against a built-in demonstration data set; a companion script exports the real input file from your own account history. Pure MQL5, no external libraries.

A read-only audit script for accounts running several EAs (or manual trades alongside them). It groups the closed-trade history by magic number and prints one line per magic: closed round turns, net P/L including swap and commission from BOTH sides of the trade, win rate, profit factor, average win/loss, currently open positions and pendings, activity dates and symbols - sorted by net result, with a CSV export for spreadsheets.

Deterministic synthetic acceptance checks for MT5 EA entry-state logic, with no market, account or order access.

Read-only broker-native trading-session inspector with current status, next transition, multi-symbol scope, and CSV export.

Prints the invisible contract limits that silently reject orders: stops level, freeze level, min/step/max lot, tick size and value, spread type, execution mode, swaps, and the margin needed for the minimum lot against your free margin.

12345678910