Magic Ledger
- Yardımcı programlar
-
Jorge Eliecer Valencia Ferreira
🤖 Quantitative Developer & Algorithmic Trading Specialist | MQL5 & Python
Welcome to my official MQL5 profile. I am a Quantitative Developer and Algorithmic Trader focused on creating high-quality, institutionally robust Expert Advisors with strict risk management. - Sürüm: 1.0
- Etkinleştirmeler: 10
Magic Ledger is a table on your chart with one row for every Expert Advisor running on the account, identified by its magic number (0 is manual trading). For each one it shows the trade count, net result, profit factor, win rate, expectancy, longest losing streak, the closed drawdown, an estimate of the floating drawdown, and the ratio between the two.
A journal that only reads closed trades hides the loss that was open while the trades were running. With grid or averaging EAs this matters a lot: the equity drawdown can be many times the balance drawdown. A public review of 30 gold EAs measured it between 4 and 24 times. Magic Ledger puts both numbers next to each other for each EA, so you can see which one is carrying open risk that the closed history does not show.
The second part checks the account against the rules of a prop firm challenge: daily loss, maximum drawdown, profit target, minimum trading days and consistency. Each rule shows the current value, the limit, the margin in money and a status.
It is for traders who run several EAs on one account, and for traders who work with prop firm accounts. It only reads the account. It does not open, modify or close any order or position.
What the table shows
- Trades, net (commission and swap included), profit factor, win rate, expectancy per trade, longest losing streak.
- DD closed: maximum drawdown of the closed results of that magic.
- DD float: estimated maximum drawdown including floating losses (see how it is estimated below).
- Flt/Cls: DD float divided by DD closed. Orange from 3, red from 6.
- Float now and number of open positions, last trade time, and profit factor of the last N trades (20 by default).
- Rows are sorted by net result. A total row shows the whole account.
- Click a magic name (or use the Next button) to see its detail: result by symbol and by weekday of closing.
- Optional names for your magics, for example 12345=Gold EA;777=Scalper.
The closed drawdown is calculated over the same window as the floating one (90 days by default), so the ratio compares like with like.
How the floating drawdown is estimated
It is an estimate with the resolution of a price bar. It is not the real equity tick by tick.
- Positions are rebuilt from the deal history of the analysis window.
- Price bars of M5 are loaded for each symbol (M15 if you choose it, or if M5 is not available).
- In each bar, each open position of the magic counts its worst possible result in that bar: the low for buys, the high for sells. The value per point comes from the symbol's tick value, converted to the account currency when the broker reports it in another currency.
- The positions of the same magic open at the same time are added up. The curve is the cumulative closed net plus that floating part. The drawdown is the largest distance from a previous peak.
- Adding the worst case of every position in the same bar is conservative: it assumes they all touched their extreme at the same moment.
- For very short trades (a few minutes) the entry or exit bar can include prices from before or after the trade, so the estimate can come out higher than the real floating loss.
Prop firm rules
- Daily loss: the worst equity of the day against a base you choose (balance at day start, equity at day start, or the higher of the two).
- Maximum drawdown: static (from the starting balance) or trailing.
- Profit target, minimum trading days, and consistency (best day as a percentage of the total profit, off by default).
- Each rule gets a status: OK, WARN when more than a set percentage of the limit is used (80 by default), FAIL when the limit is reached. PEND means a target or a minimum is not met yet.
- You can switch the whole block off.
Every firm defines these rules in its own way. Set the numbers of your firm in the inputs and treat the panel as a guide. It does not replace the official dashboard of your firm and it does not know the rules of any firm.
Light on the terminal
OnCalculate does no work. Everything runs on a timer with a budget of 40 ms per step. The history is read again only when positions or balance change, or every 5 minutes by default, and the reading is incremental. The first floating estimate is split across several timer steps and the panel shows the progress.
How to use it
- Attach it to any chart of the account. It reads the whole account, whatever the symbol or timeframe of the chart.
- Wait for the panel. It shows "Reading account history", then the table, then "Estimating floating drawdown" until DD float and Flt/Cls are filled in.
- Set the rules of your prop firm in the inputs: starting balance, daily loss, maximum drawdown, target, minimum days. Leave the starting balance at 0 only if the first deposit is inside the loaded history.
- Click a magic name to see its detail. Use Min/Max to collapse the panel and CSV to export.
Inputs
Display
- InpMaxRows (default 8): magic numbers listed in the table, 1 to 20.
- InpDetailMagic (default -1): magic shown in the detail. -1 = the best row.
- InpMagicNames (default empty): optional names, example 12345=Gold EA;777=Scalper.
- InpX (default 10), InpY (default 25): panel offset in pixels.
- InpFontSize (default 9).
- InpStartMinimized (default false).
Data
- InpDays (default 90): analysis window in days, 7 to 180.
- InpHistoryDays (default 365): account history loaded for the rules. 0 = all.
- InpLastN (default 20): trades used for the recent profit factor.
- InpFloatEstimate (default true): estimate the floating drawdown from price bars.
- InpFloatTf (default M5): bar timeframe for the estimate, M5 or M15.
- InpRefreshSec (default 2): refresh of floating results and rules, in seconds.
- InpHistoryMinutes (default 5): full history re-read every N minutes.
Prop firm rules
- InpRulesOn (default true): show the rules block.
- InpInitialBalance (default 0): starting balance of the challenge. 0 = first deposit detected.
- InpChallengeStart (default 0): challenge start date. 0 = start of the loaded history.
- InpDailyLossPct (default 5.0): maximum daily loss, %. 0 = off.
- InpDayBase (default higher of balance and equity at day start).
- InpMaxDDPct (default 10.0): maximum drawdown, % of the starting balance. 0 = off.
- InpDDTrailing (default false): trailing instead of static.
- InpTargetPct (default 10.0): profit target, %. 0 = off.
- InpMinDays (default 4): minimum trading days. 0 = off.
- InpConsistencyPct (default 0): best day as a maximum % of the total profit. 0 = off.
- InpResetHour (default 0): hour the trading day resets, server time.
- InpWarnPct (default 80): WARN when a limit is used above this %.
Output
- InpExportCsv (default false): write the CSV files on each history update. The CSV button writes them on demand.
- InpTesterSample (default true): show sample data in the Strategy Tester.
Output files
The CSV export writes two files in MQL5\Files: MagicLedger_LOGIN_magics.csv (the table) and MagicLedger_LOGIN_rules.csv (the rules). Semicolon separated. Tracking of the worst equity of the day and of the account is stored in terminal global variables per account, so it survives a restart.
What it does not do
- It does not open, modify or close trades, and it does not stop any EA. If you need a tool that closes positions at a loss limit, this is not it.
- It does not give signals and it is not a strategy.
- It does not know the rules of any prop firm and does not connect to any firm.
- It does not measure the real equity curve of each EA. The floating drawdown per EA is an estimate.
Limitations
- The floating drawdown is an estimate with M5 or M15 bar resolution. It does not see movements inside a bar. The bar where a position is closed counts its full extreme, even if the extreme happened after the close. The value per point is the current one, so for crosses with another currency the historical exchange rate can differ. Partial closes and added volume are handled with the total volume and the average entry price. Floating swap and commission are not included (they are included in the closed net). Positions opened before the loaded history are left out of the estimate. If the bars of a symbol are missing, that part is not estimated and the panel says so.
- The equity of the account is seen only from the moment the indicator is loaded. The maximum drawdown rule and the daily loss rule depend on it. If you load the indicator after the daily reset, the equity at day start is approximated with the balance and the rule is marked with an asterisk.
- If the account is older than the loaded history and you leave the starting balance at 0, the balance at the start of the loaded history is used. In that case set the starting balance by hand.
- Results depend on the history your broker keeps and on the bars your terminal has. Increase the history in the terminal if the table looks short.
- To download bars for symbols that are not in the Market Watch, the indicator adds them and hides them again when removed, if it can.
- It needs the terminal to be running. It cannot see trades made on other accounts.
Strategy Tester
The tester has no real account history. With InpTesterSample on, the panel shows sample data, marked "SAMPLE DATA (Strategy Tester)", only so you can see the layout. These numbers are not real results of any EA. In the tester the indicator does not read bars, global variables or files.
Notes
- Works on any symbol and any timeframe. One instance per account is enough.
- Dark panel, can be minimized.
Risk warning: this tool shows information about past and current results. It is not trading advice, it does not generate signals, and the figures are estimates that can differ from the real equity. Trading carries a risk of loss.
