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 · MT4 · v1.0 · Free
About Trade Frequency Limiter
Trade Frequency Limiter is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. 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.ex4, TradeFrequencyLimiter.mq4, TradeFrequencyLimiter.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Max per symbol per hour | 5 | Cap on orders opened, this symbol, in the trailing hour |
| Max per symbol per day | 15 | Cap on orders opened, this symbol, in the trailing 24 hours |
| Max total per hour | 15 | Cap on orders opened, all matching symbols, in the trailing hour |
| Max total per day | 40 | Cap on orders 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 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Trailing Stop & Break-even · Alerts · MT4 Expert Advisor · MQL4 Source Code