Trade Frequency Limiter
Overtrading rarely announces itself - it looks like conviction in the moment and only shows up as a pattern in hindsight. This EA counts every matching order (open positions plus closed history, by OrderOpenTime()) that falls inside the trailing hour and the trailing 24 hours, both per symbol and across the whole scope, and compares each count against its own configurable cap. Older orders have already "used" their slot in the window and are left alone; enforcement only ever touches currently open positions, and when a cap is breached it closes the NEWEST offender first and rechecks, so a sudden burst of entries is trimmed back down to the limit rather than closing an arbitrary position chosen without regard for order. As with every guard in this catalogue, it cannot reach into another program's OrderSend call and refuse the order before it exists - nothing running alongside another EA in the same terminal can - so it always acts after the fact, on the ticket that already appeared. On every recalculation pass the EA also rewrites a CSV snapshot of the current per-symbol and total counts to the sandbox, turning "did I overtrade this week" from a question that requires digging through history into a report you can open in a spreadsheet. Notes and limitations Counts are windowed from the current time backward, not from each order's own open time, so the reading can shift slightly as time passes between recalculations rather than updating continuously tick by tick - acceptable for a frequency guard, not appropriate for anything requiring exact real-time precision. History is walked in full on each recalculation; on accounts with very large trade history this could add a small, bounded cost at the configured recalculation cadence. It only sees orders visible in this terminal's account.
Expert advisor · MT5 · v1.0 · Free
About Trade Frequency Limiter
Trade Frequency Limiter is an expert advisor (trading robot) for MetaTrader 5. It has 11 settings, such as Max per symbol per hour, Max per symbol per day and Max total per hour. MQL source code included.
Files in the download: TradeFrequencyLimiter.ex5, TradeFrequencyLimiter.mq5, TradeFrequencyLimiter.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Max per symbol per hour | 5 | Cap on trades opened, this symbol, in the trailing hour |
| Max per symbol per day | 15 | Cap on trades opened, this symbol, in the trailing 24 hours |
| Max total per hour | 15 | Cap on trades opened, all matching symbols, in the trailing hour |
| Max total per day | 40 | Cap on trades opened, all matching symbols, in the trailing 24 hours |
| Magic filter | -1 | Magic number filter, -1 = every magic number |
| Recalc seconds | 15 | Minimum seconds between recalculation passes |
| Write report | true | Write a CSV snapshot of current counts to the sandbox each recalculation |
| Report filename | TradeFrequencyLimiter_Report.csv | Sandbox filename for the CSV snapshot |
| Dry run | false | true = alert only, never closes - use to observe before enforcing |
| Max retries | 5 | Attempts per close before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Trailing Stop & Break-even · MT5 Expert Advisor · MQL5 Source Code