Spezifikation
Updated Freelance Job Instruction (Copy-Paste Ready)
Description:
Hello,
I need a simple, secure MT4 Expert Advisor (pure MQL4, NO DLLs) that protects my XAUUSD trading by instantly closing any new position opened by another EA (identified by magic number) when price is inside user-defined "block zones", and then enforces a cooldown period before allowing the next position from that EA.
This is for risk management on M1 timeframe – the other EA is aggressive and opens many positions in bad zones, causing cumulative spread losses. The goal is to limit openings in block zones to 1 per cooldown period (e.g., 5 minutes) while allowing normal trading outside zones.
Detailed Requirements:
- Pure MQL4 only – no DLLs, no external libraries, no Windows API calls. Must compile with 0 errors/warnings in strict mode.
- 10 independent block zones defined in inputs (grouped for easy editing).
- Each zone has:
- High price (double)
- Low price (double)
- Cooldown in minutes (int, e.g., 5) – time to wait after an allowed open before the next one is permitted.
- If High=0 or Low=0 or High≤Low → zone disabled.
- Magic number filter: Input for blocked magic numbers (string, comma-separated, e.g., "123456,202312"). Only positions with these magic numbers are affected.
- Symbol filter: Input for protected symbol (default "XAUUSD").
Core Logic (Must Work Exactly Like This):
- Run on every tick for instant reaction.
- Scan all open orders.
- If a position matches:
- Protected symbol
- Blocked magic number
- Current price (Bid for buy, Ask for sell) is inside any active zone
- Then:
- If cooldown is active for that zone → instantly close the position (market or pending).
- If cooldown is finished → allow the position and start/restart cooldown for that zone.
- Cooldown timer must restart on every closure to enforce the full minutes.
- Result: Maximum 1 position per cooldown period per zone → minimal spread loss.
Notifications (Important – One-Time Only):
- Send one notification (Alert + Print + optional Push/Email) when price first enters any block zone ("Block Zone Active – Cooldown Enforced").
- Send one notification when price exits all block zones ("All Block Zones Exited – Normal Trading Resumed").
- Do not notify on every tick or every closure — only once on entry and once on exit.
Visuals:
- Optional red semi-transparent rectangles for active zones on chart (toggle in inputs).
- Tooltip on rectangle: "Block Zone X – Cooldown Active"
Other:
- OnInit: Print "Blocker active".
- OnDeinit: Clean up objects.
- Log prints when closing or allowing a position.
- Compatible with VPS/RDP.
- Test with EA Gold Stuff (magic usually 123456 or similar) to confirm no rapid re-opens in zones.
Budget: $50
Timeline: 1–2 days
Please confirm you can do this without DLL and share similar work.
Thank you!