EA Behavior Inspector
- Utilitários
-
Jorge Eliecer Valencia Ferreira
🤖 Desenvolvedor Quantitativo & Especialista em Trading Algorítmico | MQL5 & Python
Bem-vindo ao meu perfil oficial no MQL5. Sou Desenvolvedor Quantitativo e Trader Algorítmico focado na criação de Expert Advisors de alta qualidade, robustez institucional e estrita gestão de risco. - Versão: 1.0
- Ativações: 10
EA Behavior Inspector reads the closed trades of your account and shows how each Expert Advisor really trades, grouped by magic number. It looks for six behaviours that traders often discover only after a bad week: martingale, grid or averaging down, trades without stop loss, holding losers much longer than winners, one loss far bigger than the average win, and a large jump in lot size.
The reason is simple. A backtest or a sales page says little about how an EA behaves on a real account. Reviews of popular Experts often mention an undeclared grid or martingale, orders without a real stop loss, or small wins followed by one large loss. All of that is written in your own deal history. This tool reads it and puts the numbers in one panel.
It is an indicator. It does not open, close or modify any trade, and it works on any chart.
What it checks
Positions are rebuilt from the deal history. Each group (one magic number, or one magic number and symbol) gets six detectors, each marked OK, WARN or FAIL:
- MARTINGALE: of the entries made after the previous position on the same symbol closed at a loss, what percentage used a volume of at least the multiplier you set (1.5x by default).
- GRID/AVERAGING: how many positions were added on the same symbol and side, at a worse price, while another position was still open, and how many layers deep it went.
- NO STOP LOSS: percentage of positions opened without a stop loss, and percentage that never had one. Positions that were closed by a stop loss count as having one.
- LOSS HOLDING: average time a losing position stayed open divided by the average time of a winning one.
- TAIL RISK: largest single loss divided by the average win.
- LOT ESCALATION: largest volume divided by smallest volume. This one can only reach WARN.
Each group also gets a grade. A means no warnings, B one warning, C two or more warnings, F at least one FAIL. If the group has fewer closed positions than the minimum sample (5 by default), the grade is "?" and the detectors show "insufficient data". The grade describes behaviour. It does not say whether the EA made money or will make money.
The panel also shows basic figures from your own history for each group: closed positions, net result, profit factor, average win and loss, largest loss, longest losing run, the most positions open at once, and how many positions are open now without a stop loss.
How to use it
- Attach it to any chart. Make sure the terminal has loaded the history you want (Account History tab, "All history" or the period you need).
- Read the group list. Each row shows the group, closed positions, net result, profit factor, six flags (M G S H T L) and the grade.
- Press Next to change the group shown in the detail section. Press Rescan to read the history again.
- Open the CSV files for the full data. To look at one EA only, set its magic number in the inputs.
Inputs
Data
- InpDaysBack (default 180): days of history to read. 0 = all history.
- InpGroupBy (default Magic number): group by magic number, or by magic number and symbol.
- InpMagicFilter (default -1): only this magic number. -1 = all, 0 = manual trades.
- InpRefreshMinutes (default 5): refresh interval.
Martingale detector
- InpMartMult (default 1.5): volume multiplier after a loss that counts as a hit.
- InpMartWarnPct (default 20) and InpMartFailPct (default 50): percentage of post-loss entries for WARN and FAIL.
- InpMinSample (default 5): minimum number of positions (or post-loss entries for the martingale detector) to give a result.
Grid / averaging down detector
- InpGridWarn (default 3) and InpGridFail (default 5): number of layers for WARN and FAIL.
Stop loss detector
- InpNoSlWarnPct (default 10) and InpNoSlFailPct (default 50): percentage opened without stop loss for WARN and FAIL.
Loss holding detector
- InpHoldWarn (default 3.0) and InpHoldFail (default 6.0): loss hold time over win hold time.
Tail risk detector
- InpTailWarn (default 10.0) and InpTailFail (default 25.0): largest loss over average win.
Lot escalation detector
- InpLotRatioWarn (default 8.0): largest over smallest volume for WARN.
Panel
- InpMaxRows (default 8): groups listed in the panel.
- InpDetailMagic (default -1): group shown in detail at start. -1 = the one with most positions.
- InpX (10), InpY (25), InpFontSize (9) and five color inputs.
Output
- InpSaveCSV (default true): save the CSV files to MQL5\Files.
- InpAlertOnFail (default false): one alert when a group turns FAIL after the first scan.
- InpTesterSample (default true): show sample data in the Strategy Tester.
The thresholds are yours to change. The defaults are starting points, not industry standards.
Output
Panel on the chart: list of groups with flags and grade, then a detail block for the selected group with its figures and the six detectors with level and a short reason, for example "4 adds at worse price, max 3 layers".
CSV files in MQL5\Files, semicolon separated, rewritten on each scan:
- EABehaviorInspector_positions.csv: one row per position, with group, magic, symbol, type, open and close time, volume, entry price, net result, stop loss at entry, whether it ever had a stop loss, and status.
- EABehaviorInspector_summary.csv: one row per group, with the metrics, the level of each detector and the grade.
Limitations
- Grid detection is an approximation. It works from entry prices, sides and times in the history, not from the EA's code. A group of positions that looks like a grid may be something else, and an EA that hides a grid by spacing entries differently can be missed.
- It needs enough history. With few closed positions the result is "insufficient data" or may swing a lot with one trade. Positions opened before the history window and closed inside it are not counted.
- It can only see the account of the terminal where it runs, and only what the terminal has loaded. If the history is not loaded, the panel can show no positions.
- Stop loss detection uses the stop loss on the entry deal or order and whether the position was later closed by a stop. A stop loss added by hand afterwards counts as "ever had".
- Net result includes profit, swap, commission and fees as reported in the deals. Deposits and withdrawals are ignored.
- It does not say which EA is good. A grade of A is not a recommendation, and F does not mean the EA will lose.
- It does not stop, close or change any EA.
Strategy Tester demo
The Strategy Tester has no real trade history, so with InpTesterSample on, the tool shows synthetic sample data: two made-up groups, SAMPLE_A with fixed volume and a stop loss on every trade, and SAMPLE_B built with martingale, no stop loss, averaging and large losses. The panel says "SAMPLE DATA (tester demo) - not real trades". The tester does not write CSV files and shows the panel in visual mode only. On a normal chart it reads your real history.
Notes
- Works on any symbol and any timeframe.
- On a live chart it refreshes by timer, every 5 minutes by default.
Risk warning: this tool is a risk behaviour report on past trades. It is not trading advice, it does not generate signals and it does not predict results.
