MetaTrader

MetaTrader Script for MT5

UPDATE
Showing 5 results

Advanced Trade History Exporter: MAE, MFE and Time-Based Excursions (Points)

Evaluating your trading edge requires more than just looking at your win rate and net profit. You need to know how efficient your entries and exits are. Are your stop losses too wide? Are you leaving money on the table by closing too early?

This script analyzes your historical deals, reconstructs your trades, and calculates advanced quantitative metrics, outputting everything into a clean .csv file that you can open directly in Excel.

Key Features & Metrics Calculated:

  • MAE (Maximum Adverse Excursion): Calculates the maximum number of points the market moved against your position during the lifespan of the trade. Helps you optimize your stop-loss placement.

  • MFE (Maximum Favorable Excursion): Calculates the maximum number of points the market moved in your favor before the trade was closed. Helps you identify if you are giving back too many unrealized gains.

  • Forward Returns (Time-Based Excursions): Analyzes the exact price difference relative to your entry price at specific future intervals (T+30m, T+1h, T+4h, T+12h, T+1d, T+1w). This answers the quantitative question: "What if I had just held the trade for exactly X hours?" If a future time period hasn't occurred yet, it safely outputs n/a .

  • T+1w MIN (Forward Risk): Calculates the absolute worst-case drawdown (maximum adverse points) that occurred over the entire 1-week period following your entry. If the trade never went against you during that week, it reports 0 .

Output Format: The script generates a CSV file with the following columns: Position ID | Symbol | Type | Open Time | Close Time | Duration (Hrs) | Open Price | Close Price | Profit ($) | Profit (Pts) | MAE (Pts) | MFE (Pts) | T+30m | T+1h | T+4h | T+12h | T+1d | T+1w | T+1w MIN

Input Parameters
  • Start Date: Choose how far back in your terminal's history you want the script to scan (Default: 2026.01.01 ).

How to Use
  1. Download the .mq5 source code file.

  2. In your MetaTrader 5 terminal, go to the top menu and click File -> Open Data Folder.

  3. Navigate to the MQL5\Scripts folder and place the .mq5 file inside.

  4. Open the MetaEditor (press F4 on your keyboard).

  5. In the MetaEditor Navigator, find the script under the Scripts folder, open it, and click the Compile button at the top (or press F7).

  6. Back in the MT5 terminal, open the Navigator panel (Ctrl+N).

  7. Expand the Scripts folder, find Export_MAE_MFE_Points , and drag it onto any open chart.

  8. Set your desired Start Date and click OK.

  9. The script will process your history and save a file named TradeHistory_Stats_Points.csv in your MQL5\Files folder.

Note: The script utilizes M1 timeframe data ( CopyHigh , CopyLow , CopyClose ) to calculate the highly accurate excursion metrics. Please ensure you have sufficient M1 history downloaded from your broker for the symbols and dates you are querying, otherwise, some metrics may report as 0.

L1 Trend Filter Demo

Description:

The L1 filter enables extraction of piecewise-linear trends that preserve essential market structure while reducing price noise.

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

The applications in trading can be found in .

All codes from the article are also available in the "MQL5\Shared Projects\".

Image:

ASQ Trading Journal Export

ASQ Trading Journal Export — Your Trades, Your Data, One Click

AlgoSphere Quant — Precision before profit.

ASQ Trading Journal Export is a script that exports your complete trade history to a clean CSV file in one click. Every closed trade is reconstructed from the deal history with full details: ticket, symbol, direction, open/close time, lots, open/close price, SL, TP, gross P/L, swap, commission, net P/L, duration in minutes, magic number, and comment.

The CSV is ready to open in Excel, Google Sheets, or import into Python, R, or any analytics tool. At the bottom of the file you get a summary section with total trades, wins, losses, win rate, gross P/L, and net P/L.

Features

  • One-click execution — run the script, get your CSV instantly
  • Full trade reconstruction from MT5 deal history
  • Configurable date range (last N days or all history)
  • Symbol filter and magic number filter
  • Optional columns: swap, commission, duration, magic, comment
  • Summary section with win/loss count, win rate, gross and net P/L
  • Clean CSV format compatible with Excel, Sheets, Python, R
  • Auto-generated filename with date stamp
  • Output to MQL5/Files/ for easy access

Parameters

Export: filename, days back (0 = all), symbol filter, magic filter. Fields: include swap, commission, duration, magic, comment (each on/off).

Installation

  1. Download ASQ_TradingJournalExport.mq5
  2. Place in MQL5/Scripts/
  3. Compile in MetaEditor
  4. Drag onto any chart — the export runs immediately

MetaTrader 5, all brokers, all account types. Free and open-source.

Portfolio Scorer — Multi-EA Correlation and Coverage Analyzer

Portfolio Scorer evaluates multi-EA portfolios by measuring three dimensions: inter-strategy correlation, temporal coverage, and asset class diversity. It produces a composite grade from A+ to F.

The script reads daily P&L data from CSV files located in the MQL5\Files\ folder. If no files are found, it automatically generates sample data for five EAs (forex, index, metal, energy, and forex-JPY) so the user can see the full output immediately.

Input parameters:

InpFileList — comma-separated list of CSV filenames to analyze. Default: EA_EUR.csv, EA_NDX.csv, EA_XAU.csv, EA_OIL.csv, EA_JPY.csv.

InpSeparator — delimiter character used to split the file list. Default: comma.

InpMinDays — minimum number of trading days required per EA to be included in the analysis. Default: 60.

InpCorrThresh — absolute correlation threshold above which a pair is flagged as dangerously correlated. Default: 0.35.

InpWeightCorr — weight assigned to the correlation dimension in the composite score. Default: 0.50.

InpWeightCov — weight assigned to the coverage dimension. Default: 0.25.

InpWeightDiv — weight assigned to the diversity dimension. Default: 0.25.

Output (Experts tab):

Full NxN Pearson correlation matrix with threshold flags. Hour-by-hour coverage map (0-23 UTC) showing active EAs per hour. Weekday coverage breakdown (Mon-Fri). Composite score report with individual dimension scores and letter grade. Actionable recommendations based on detected weaknesses.

CSV format expected: Each file must have a header row followed by one row per trading day with four columns: Date, DailyPnL, TradeHour, TradeWeekday. A companion function (ExportDailyPnL) for generating these files from EA backtests is described in the accompanying article.

Attach the script to any chart and run. No specific symbol or timeframe is required — the script operates on CSV data, not on chart prices.

NeuroPro Converter

NeuroPro Verbalisation Converter for MQL5

This script is designed to automate the process of transferring neural networks from the analytical package NeuroPro (1997 release) to MetaTrader 4/5 trading terminals.

Problem to be solved

The classic article describes the process of "verbalising" the trained network into a text code, and it also points out that the NeuroPro output format is incompatible with the modern MQL5 syntax:

  1. Syntax: lack of data type declarations ( double ), unnecessary closing brackets, lack of semicolons and specific recording of array indexes ( ___1__ ).

  2. Arithmetic: erroneous interpretation of " --" sequence as a decrement operator.

  3. Encoding: software of the 90's outputs text in ANSI (CP1251), which leads to loss of Cyrillic identifiers (turning them into "krakozabras").

This script converter fully automates 90% of the " dirty" work that used to take a lot of useful time due to manual edits to translate verbalisation into code.

Key features of the algorithm
  • Byte reading: the script reads the source file IN.txt directly through FILE_BIN , eliminating character distortion by the system clipboard.

  • Smart substitution: only key elements are transformed:

    • SigmoidX → SiX (the index of the activation function is preserved).

    • SyndromeX → double SyX (automatic declaration of intermediate neurons).

  • Syntax corrector: the script calculates the balance of brackets in each line, removes redundant characters in the tail of formulas and arranges " ;" .

Instructions for use
  1. In NeuroPro, verbalise the network and save the result to a text file (e.g. IN.txt ).

  2. Place the file in the terminal data folder: MQL5\Files\NeuroPro\.

  3. Run the script. In the input parameters window you can specify the path and file names.

  4. The resulting file IN ready.txt contains clean MQL5 code ready to be inserted into the Expert Advisor.

Example of the script operation: 1) Screenshot of the NeuroPro program in the part of calling the verbalisation window 2) Screenshot of the open file - the result of running the script.

    Technical details

    The script uses character-by-character parsing (token analysis) of the right part of expressions, which guarantees preservation of all mathematical coefficients and Latin identifiers. Full Cyrillic support is implemented through forced decoding of 1251 page.

    RobotFX does not own any of the code provided on this platform. All tools are freely available on the internet; we simply index and re-offer them for download. We are not responsible for any financial losses that may occur. Trading responsibilities rely solely on the traders downloading and using the displayed Expert Advisors, indicators, and scripts. These tools are provided for educational purposes only and may require modification or optimization to align with a trader's specific strategy or needs.
    © ROBOTFX - Best MetaTrader Expert Advisors & Indicators