Summarizing Closed Trades with Performance Metrics and a Dashboard
Summary
This article completes a MetaTrader 5 trade analytics pipeline by adding summary calculations and a browser dashboard to an existing Flask and SQLite backend. An Expert Advisor sends closed-position records to the server; the analytics endpoint aggregates stored trades into measures such as trade count, total and average profit, win and loss counts, win rate, and trade-duration statistics. A separate root page presents the metrics for quick viewing, while the JSON endpoint remains available to scripts and other clients.
The article explains how to query records and handle an empty database when calculating ratios. It focuses on implementation and system structure rather than evaluating a trading strategy. No performance study is provided, and the usefulness of the statistics depends on the completeness and correctness of the captured trade records. The dashboard is a basic monitoring aid, not a substitute for deeper analysis of risk, costs, or strategy behavior.
Key ideas
- Closed trades are captured by a MetaTrader 5 Expert Advisor and stored as rows in SQLite.
- Aggregating trade records makes overall activity easier to inspect than reviewing each trade individually.
- The summary includes profitability, win and loss counts, and average, maximum, and minimum trade duration.
- A JSON analytics endpoint serves structured results while the API root displays them in a simple browser page.
- Calculations such as win rate need to account for an empty trade database.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.