Trade Veto Council
A trading system usually accumulates several independent pre-trade checks over time - spread too wide, too many trades already open, account in too deep a drawdown, outside the trading session, a news event pending - and they end up scattered across the EA as separate if-statements that each either allow the trade or silently return without saying why. This header gathers them into one GuardCouncil and one EvaluateCouncil call that always runs every configured guard and returns the FULL list of what currently blocks a trade, not just the first check that failed. MQL4 has no function pointers, so this is not a callback-based plugin system - it cannot be, in this language. Each GuardRule carries an ENUM_GUARD_TYPE, and EvaluateCouncil dispatches on that type through a switch statement against a shared MarketSnapshot the caller fills in once per evaluation. Five guard types are built in (spread, open-trade count, equity drawdown, session-time window, news blackout); for any check this header cannot anticipate, GUARD_CUSTOM_BOOL is the escape hatch - the caller computes their own boolean elsewhere (a correlation check, a prop-firm rule, anything) and stores it on the rule's customResult field before calling EvaluateCouncil. That field is the closest approximation to a callback that MQL4's type system allows, and is documented plainly as such rather than pretending this is a real plugin architecture. Guards are evaluated independently and unconditionally: EvaluateCouncil never short-circuits at the first veto, so a trader debugging "why won't this EA trade right now" sees every currently-active blocker in one pass instead of fixing one guard only to immediately hit the next. Notes and limitations - GUARD_SESSION_TIME's [thresholdA, thresholdB) hour range wraps past midnight correctly when thresholdA > thresholdB (e.g. 22 to 4), but currentHour must be supplied in the same clock the caller intends - broker time and server time are not automatically reconciled here. - GUARD_CUSTOM_BOOL requires the caller to set rule.customResult BEFORE each EvaluateCouncil call; a stale value from a previous evaluation will silently be reused if it is not refreshed every pass - the demo shows updating it explicitly between the two snapshots. - thresholdA/thresholdB are reused with different meaning per guard type (documented in the header above each case in TVC_EvaluateRule) rather than one dedicated field per possible guard - check the meaning for the specific ENUM_GUARD_TYPE in use before setting them. - This header makes no trading decision itself; it only evaluates the rules it is given and reports the verdict. Computing equityDrawdownPct, detecting news blackouts, etc. remains the caller's responsibility. - No thread or state concerns beyond the caller-supplied snapshot and rule array.
Script · MT5 · v1.0 · Free
About Trade Veto Council
Trade Veto Council is a script for MetaTrader 5. MQL source code included.
Files in the download: TradeVetoCouncil.mq5.mqh, TradeVetoCouncil.txt, TradeVetoCouncilDemo.ex5, TradeVetoCouncilDemo.mq5.
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 → Scripts.
- 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 script onto a chart to run it once.
Tags: Trading Sessions · News Trading · MT5 Script · MQL5 Source Code