Ephemeris Trade Calendar
- Utilities
-
Syarief Azman Bin Rosli
Hello and welcome to my official MQL5 profile!
I am Syarief Azman Bin Rosli, an algorithmic trading systems developer and quantitative software engineer with over a decade of specialized experience creating robust automated trading solutions for MetaTrader 5 and MetaTrader 4. - Version: 1.0
- Activations: 5
Ephemeris Trade Calendar - your account history as a monthly profit calendar (MT4)
Ephemeris Trade Calendar turns your MetaTrader 4 history into a monthly profit calendar on the chart. Every closed trade lands on its day: cells are shaded by result, show win and loss counts and add up into weekly totals. A lower deck switches between statistics, an edge map (P/L by entry weekday and hour plus a closed-trade equity curve) and a day ledger, and a TODAY meter follows your daily target and loss limit. On live and demo charts it only reads history: it never opens, modifies or closes a trade.
Quick Start
- Attach it to any chart (any symbol, any timeframe). Algo Trading is not needed.
- In the Terminal window open Account History, right-click and choose All History. MT4 only gives programs the history loaded in that tab; a shorter period leaves older months empty and makes percentages approximate.
- Optional: set Symbol Filter and Magic Filter to follow one symbol or one EA, and Daily Target / Daily Loss Limit for the TODAY meter.
- Check: the badge reads TRACKING n TRADES and the month fills in. Click a day to open its ledger.
The panel
Header
- LED: violet normal, green target reached, red loss limit hit, amber within 80% of the loss limit, grey no closed trades.
- `<>` moves the panel to the next corner. `[-]` collapses it into an EPHEMERIS pill with today's P/L (closed + floating); `[+]` expands it.
- Sub line: #account, currency and filters: ALL SYM, the chart symbol or LIST(n); ALL MAGIC, MANUAL or MAGIC(n); NET (swap and commission included) or GROSS.
- Badge: TRACKING n TRADES, NO CLOSED TRADES, CHECK FILTER LIST (a list filter with an empty list), TARGET REACHED, LOSS LIMIT HIT, NEAR LOSS LIMIT. For a few seconds after an action: EXPORTED n TRADES, m DAYS, EXPORT FAILED (error code), HISTORY RELOADED, AUTOSCROLL OFF, DAY NOT ON CHART.
Month navigation
`<<` previous month, `>>` next month (up to the current one), TODAY returns to the current month and selects today. On the current month the calendar follows the date at midnight.
Calendar
- Columns MO to SU (or SU to SA) plus WEEK.
- Day cell: day number, value in the current unit and wins/losses such as 2W 1L (zero-net trades count in neither). Green = net profit, red = net loss, stronger shade = bigger result relative to the month's largest day; grey = traded, net zero; dark = no trades; faint numbers = neighbouring months.
- Cyan border = today, amber border = selected day.
- WEEK: row total in the current unit and trade count (n tr); in percent mode, the sum of daily percentages.
- Click a cell to select the day and open the DAY ledger; a faint neighbouring-month day switches to that month.
Month strip
NET (money), RETURN (month net / balance at month start), GREEN DAYS (profitable / traded days), TRADES, WIN RATE.
Deck tabs and toggles
- STATS, EDGE and DAY switch the lower deck.
- UNIT: MONEY, UNIT: % and UNIT: PTS cycle the calendar values: account currency; percent of the balance at the start of that day; points (price distance / symbol point, summed over symbols).
- SCOPE: MONTH or SCOPE: ALL applies STATS and EDGE to the viewed month or to all loaded history.
STATS deck (money)
Net P/L, Return (net / balance at scope start), Trades, Win rate, Profit factor (gross profit / gross loss; -- with no losing trade), Expectancy (net per trade), Avg win, Avg loss, Payoff ratio (avg win / avg loss), Largest win, Largest loss, Max drawdown (largest fall of cumulative closed-trade P/L from a peak, money and % of the balance at that peak), Win streak, Loss streak, Best day and Worst day (with date), Green days (profitable / traded, %), Swap + comm. Footer: SCOPE, LOTS and HISTORY FROM (earliest loaded record).
EDGE deck (money)
- ENTRY WEEKDAY: a bar per weekday with the P/L of trades opened that day (green up, red down, flat grey = none). ENTRY HOUR: 24 bars for entry hours 0-23. Both follow Day Shift; readouts name the best and worst weekday and hour.
- EQUITY CURVE: cumulative closed-trade P/L of the scope in close order (up to 82 columns), teal above zero, red below, with end and low values.
DAY deck (ledger)
Header: weekday, date, trade count, net, W/L. Columns TICKET, SYMBOL, SIDE, LOTS, OPEN >CLOSE (shifted time; * = opened or closed on another day), NET. Seven rows per page; `<` and `>` turn pages. GO TO DAY scrolls the chart to that day and turns chart autoscroll off (press End to return). An empty day shows "No closed trades on this day."
TODAY module
closed (today's closed net), open (floating P/L of open trades matching the filters), total. The meter runs from LIMIT (left) to TARGET (right) with a zero mark; the fill is the goal value (closed + floating, or closed trades only). With both at 0 it shows "no target or limit set".
Action deck
- PLOT: ON / PLOT: OFF draws the viewed month's trades of the chart symbol: open arrow (blue buy, orange sell), close mark and dotted line in the profit or loss colour, net label; hover for the ticket. The 400 most recent are drawn; the status line then shows PLOT n/m.
- EXPORT CSV writes the files below. REFRESH reloads history now. SYNC hh:mm:ss = last update.
Automatic behavior
- History is checked every History Check Interval seconds and on each tick; recalculation happens only when the record count, the account or the day changes.
- Only buy and sell trades count. Deleted pending orders, balance and credit records are skipped (balance operations feed percentages, never P/L). A partial close appears as separate trades because MT4 stores each closed part as its own ticket.
- Days follow Assign Trades to Days by and Day Shift from Server Time; the TODAY module uses the same rule. Percentages use the balance rebuilt backwards from the current balance.
- Target and limit alerts fire once per day each (again after re-attaching). They only inform: nothing is closed.
- Month, deck, unit, scope, plot, corner and collapsed state survive timeframe and symbol changes and reset on re-attach or input changes.
- Strategy Tester: on a chart the utility never trades. In the tester, where the Market demo runs, Sample Trades in the Strategy Tester opens one 0.10-lot sample trade (or the broker minimum) at 08, 11, 14 and 17 server time (direction from the H1 20-SMA, stop loss 1.2 ATR, take profit 1.6 ATR, margin checked) and closes it at 21, magic 20261105, so the calendar has history to show. Buttons work in the visual tester; day cells cannot be clicked there.
Alerts
"daily target reached" when the goal value reaches the target; "daily loss limit reached" when it falls to minus the limit. Popup Alert on Target or Limit shows a popup; Push Notification on Target or Limit sends a push (set your MetaQuotes ID in Tools > Options > Notifications).
Files and global variables
- EXPORT CSV writes MQL4\Files\Ephemeris\<account>_trades.csv (ticket, symbol, type, lots, open/close time and price, profit, swap, commission, net, points, magic, day) and <account>_days.csv (day, trades, wins, losses, net, gross profit, gross loss, lots, points, pct_of_balance). Each export overwrites them (File > Open Data Folder).
- With Publish Global Variables: EPH_<account>_TODAY_NET (today's closed net), EPH_<account>_TODAY_TOTAL (closed + floating), EPH_<account>_GOAL_STATE (1 target reached, -1 loss limit hit, 0 neither). Updated every second, deleted when the utility is removed.
string a = IntegerToString(AccountNumber());
double goal = GlobalVariableGet("EPH_" + a + "_GOAL_STATE");
if(goal < 0) return; // loss limit hit today: no new entries - Chart objects use the prefixes EPH_C_ (panel) and EPH_T_ (plotted trades); all are removed on exit. No DLLs.
Inputs
- Symbol Filter (All symbols): All symbols / Chart symbol only / Symbol list.
- Symbol List: comma separated, case-insensitive; an entry matches every symbol starting with it (EURUSD covers EURUSDm).
- Magic Filter (All trades): All trades / Manual trades only (magic 0) / Magic number list.
- Magic Number List: comma separated numbers.
- Include Swap and Commission (true): false = gross profit only (GROSS).
- Assign Trades to Days by (Close time): Close time / Open time.
- Day Shift from Server Time (0, -12 to 12 hours): moves day boundaries, entry hours and ledger times.
- Week Starts on (Monday): Monday / Sunday.
- Cell Value at Start (Money): Money / Percent of balance / Points.
- Stats Scope at Start (Viewed month): Viewed month / All loaded history.
- Lower Deck at Start (Stats): Stats / Edge map / Day ledger.
- Daily Target (0 = off), Daily Loss Limit (0 = off): positive values.
- Target and Limit Unit (Money): Money / Percent of day-start balance.
- Include Floating P/L in the Daily Goal (true).
- Popup Alert on Target or Limit (true), Push Notification on Target or Limit (false).
- Publish Global Variables (false). Plot Trades on Chart at Start (true).
- Profit Color, Loss Color: cells, labels and plots.
- Panel Corner (Top left): Top left / Top right / Bottom right / Bottom left. Panel X Offset (12), Panel Y Offset (24): pixels from that corner.
- Panel Scale (1.0, 0.6-2.0). Start Collapsed (false).
- History Check Interval (2, 1-60 seconds).
- Sample Trades in the Strategy Tester (true): tester only, see above.
Typical setups
- Whole-account journal: defaults, Account History on All History.
- One EA: Magic Filter = Magic number list, Magic Number List = its magic, PLOT: ON on its chart.
- Daily guard: Daily Target 1.0, Daily Loss Limit 2.0, Target and Limit Unit = Percent of day-start balance, Push Notification on Target or Limit and Publish Global Variables = true so your EAs can read GOAL_STATE.
- Local-time days: Day Shift from Server Time = your UTC offset minus the server's (server UTC+2, you UTC+8: 6).
Notes
- Only the history loaded in Account History is visible. Points add up across symbols with different point sizes. STATS and EDGE are always in money.
- Statistics describe past results only; they do not predict future results, and trading carries a risk of loss.
