Loading…

Prohibited Strategy Detector

Funded programme rulebooks commonly ban a handful of specific patterns outright, and traders using a strategy they did not write themselves frequently have no idea whether it does any of them. This EA checks for three that are actually visible in ordinary MQL4 order history: trades held for only a few seconds (tick scalping), a sequence of same-symbol, same-direction trades opened close together with lot size climbing by a fixed multiple each time (a grid or martingale progression), and overlapping opposite-direction trades on the same symbol (hedging, banned on many netting-style funded accounts even when the platform itself allows it). It deliberately does not attempt to detect latency arbitrage or other patterns that need data outside what a terminal's own order history contains - a check invented from insufficient evidence would produce false confidence in either direction. Everything it does flag is a mechanical fact about the trade sequence, stated plainly, for the trader to check against their programme's actual wording. The history scan is bounded to a configurable number of most recent matching trades, keeping this fast on an account with years of history, and the overlap check - the only one with worse-than-linear cost - stays inside that same bound. Notes and limitations Read-only detector - it never closes a position or blocks a trade, because whether a flagged pattern actually violates your programme's rules depends on wording this EA cannot read. It only sees this terminal's own account history, so a strategy that trades across multiple accounts or terminals will only be partially visible here. A flagged pattern is a prompt to check the rulebook, not proof of a violation. On MQL5, a trade whose entry deal has aged out of local history is skipped from the sample rather than guessed at.

Expert advisor · MT4 · v1.0 · Free

About Prohibited Strategy Detector

Prohibited Strategy Detector is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 8 settings, such as Lookback trades, Scalp max hold seconds and Scalp flag threshold percent. MQL source code included.

Files in the download: ProhibitedStrategyDetector.ex4, ProhibitedStrategyDetector.mq4, ProhibitedStrategyDetector.txt.

Settings

SettingDefaultWhat it does
Lookback trades200Most recent matching closed trades sampled (bounds the scan)
Scalp max hold seconds30Trades held at or under this duration are scalp candidates
Scalp flag threshold percent10.0Flag scalping once this percent of the sample are scalp candidates
Grid lot multiplier1.5Consecutive same-direction, same-symbol lot growth ratio that flags a grid/martingale signature
Grid window seconds300Maximum gap between opens for two trades to be considered part of the same sequence
Detect hedgingtrueFlag overlapping opposite-direction trades on the same symbol
Magic filter-1Magic number filter (-1 = every magic number)
Recalc seconds60Minimum seconds between rescans

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Scalping · Grid · Martingale · Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria