//+------------------------------------------------------------------+ //| ForexNewsRadar.mqh | //| ForexNewsRadar (https://forexnewsradar.com) //| 1-Line Zero-DLL Pre-Trade & Prop-Firm VETO Gate for Custom EAs | //+------------------------------------------------------------------+ //| Copyright 2026, ForexNewsRadar (https://forexnewsradar.com) | //| Usage in your Expert Advisor (.mq5): | //| #include | //| input string FNR_ApiKey = ""; // Free for EURUSD; $29 all 18 | //| ... | //| if(!FNR_IsPropSafe(_Symbol, FNR_ApiKey)) return; | //+------------------------------------------------------------------+ #ifndef __FOREX_NEWS_RADAR_MQH__ #define __FOREX_NEWS_RADAR_MQH__ static const string G_FNR_CANONICAL_PAIRS[18] = { "EURUSD", "XAUUSD", "GBPUSD", "USDJPY", "XAGUSD", "EURJPY", "GBPJPY", "AUDUSD", "USDCAD", "USDCHF", "NZDUSD", "EURAUD", "GBPAUD", "CADJPY", "AUDJPY", "NZDJPY", "CHFJPY", "EURCHF" }; string FNR_TrimTrailingSlash(const string rawUrl) { string s = rawUrl; StringTrimLeft(s); StringTrimRight(s); while(StringLen(s) > 1 && StringSubstr(s, StringLen(s) - 1, 1) == "/") { s = StringSubstr(s, 0, StringLen(s) - 1); } return s; } int FNR_FindCanonicalIndex(const string rawSymbol) { string up = rawSymbol; StringToUpper(up); if(StringFind(up, "GOLD") >= 0) return 1; // XAUUSD if(StringFind(up, "SILVER") >= 0) return 4; // XAGUSD string alpha = ""; int n = StringLen(up); for(int i = 0; i < n; i++) { ushort c = StringGetCharacter(up, i); if(c >= 'A' && c <= 'Z') alpha += ShortToString(c); } for(int k = 0; k < 18; k++) { if(StringFind(alpha, G_FNR_CANONICAL_PAIRS[k]) >= 0) return k; } return -1; } string FNR_CanonicalSymbol(const string rawSymbol) { int idx = FNR_FindCanonicalIndex(rawSymbol); if(idx >= 0) return G_FNR_CANONICAL_PAIRS[idx]; string up = rawSymbol; StringToUpper(up); string clean = ""; int n = StringLen(up); for(int i = 0; i < n; i++) { ushort c = StringGetCharacter(up, i); if(c >= 'A' && c <= 'Z') { clean += ShortToString(c); if(StringLen(clean) == 6) break; } } return (StringLen(clean) == 6) ? clean : "EURUSD"; } // Fast Multi-Pair Hybrid Gate: // 1. Returns true automatically inside Strategy Tester (MQL_TESTER) so backtests never fail. // 2. If ForexNewsRadar_PropShield.mq5 Master Hub EA is running on any chart (fresh <= 45s), // reads GlobalVariable in ~0.001ms RAM with zero HTTP latency. // 3. Otherwise polls GET /api/v1/pairs/?compact=1 with a per-pair 18-slot 15s cache // (zero cache-thrashing even inside multi-symbol portfolio OnTick loops). bool FNR_IsPropSafe( const string brokerSymbol, const string apiKey = "", const string baseUrl = "https://forexnewsradar.com", const int cacheSeconds = 15 ) { if(MQLInfoInteger(MQL_TESTER)) return true; int idx = FNR_FindCanonicalIndex(brokerSymbol); string canon = (idx >= 0) ? G_FNR_CANONICAL_PAIRS[idx] : FNR_CanonicalSymbol(brokerSymbol); int slot = (idx >= 0) ? idx : 18; datetime nowGmt = TimeGMT(); // Zero-latency RAM read when ForexNewsRadar_PropShield.mq5 Hub EA is active if(GlobalVariableCheck("FNR_HEARTBEAT_TS")) { datetime hb = (datetime)GlobalVariableGet("FNR_HEARTBEAT_TS"); if(nowGmt >= hb && (nowGmt - hb) <= 45 && GlobalVariableCheck("FNR_PROP_SAFE_" + canon)) { return (GlobalVariableGet("FNR_PROP_SAFE_" + canon) > 0.5); } } static datetime s_pollTs[19]; static bool s_cachedSafe[19]; int ttl = MathMax(5, cacheSeconds); if(s_pollTs[slot] > 0 && nowGmt >= s_pollTs[slot] && (nowGmt - s_pollTs[slot]) < ttl) { return s_cachedSafe[slot]; } string cleanBase = FNR_TrimTrailingSlash(baseUrl); string url = cleanBase + "/api/v1/pairs/" + canon + "?compact=1"; string headers = "Accept: application/json\r\n"; string cleanKey = apiKey; StringTrimLeft(cleanKey); StringTrimRight(cleanKey); if(StringLen(cleanKey) > 10) { headers += "Authorization: Bearer " + cleanKey + "\r\n"; } char post[], result[]; string resHeaders = ""; int code = WebRequest("GET", url, headers, 5000, post, result, resHeaders); s_pollTs[slot] = TimeGMT(); if(code == 402) { Print("ForexNewsRadar: ", canon, " is locked (HTTP 402). Unlock all 18 pairs at ", cleanBase, "/?unlock=ALL"); s_cachedSafe[slot] = false; return false; } if(code != 200) { s_cachedSafe[slot] = false; return false; // Fail-closed on network timeout or WebRequest whitelist error } string json = CharArrayToString(result, 0, WHOLE_ARRAY, CP_UTF8); s_cachedSafe[slot] = (StringFind(json, "\"stale\":false") >= 0 && StringFind(json, "\"prop_safe_to_trade\":true") >= 0); return s_cachedSafe[slot]; } #endif // __FOREX_NEWS_RADAR_MQH__