2026-02-15 05:13:55 +00:00
|
|
|
#ifndef AI_LABELS_MQH
|
|
|
|
|
#define AI_LABELS_MQH
|
|
|
|
|
|
2026-03-31 02:57:33 +00:00
|
|
|
#include "LabelUtils.mqh"
|
|
|
|
|
|
2026-02-15 05:13:55 +00:00
|
|
|
void UpdateAILabel()
|
|
|
|
|
{
|
feat: replace OpenAI with n8n AI Gateway + session + watchlist
- Remove OpenAI.mqh entirely (no direct API calls)
- Add AIGateway.mqh: unified gateway → n8n → OpenRouter → Claude
- advisory mode: EA never fails to start (gateway down = MAYBE 0.5x)
- mandatory mode: blocks trades if gateway unreachable
- actions: validate_trade, get_briefing, get_session, get_news_bias,
report_trade, watchlist_status, ping
- includes bid/est_sl/est_tp in validate_trade payload
- Add AISession.mqh: AMD session detection (Asia/London/NY/Interbank)
with corner chart labels showing session phase + GW status
- InputParams.mqh: AI_Mode, AI_Gateway_URL, briefing TF flags,
AI_Session_Draw, Use_Watchlist_Gate
- GlobalVariables.mqh: gateway state, per-TF briefing cache,
session + news headlines globals
- MasterAICoordinator.mqh: wired to AIGateway (SetUseOpenAI shim kept)
- NewsEngine.mqh: merges live AI news bias from gateway
- AISignalConfirmation.mqh: delegates to AIValidateTrade()
- AILabels.mqh: GW status (color-coded), validation stats, per-TF briefs
- ChartLabels.mqh: session label integration
- profitgtx.mq5 v7.00: OnInit init gateway + session, OnTimer multi-TF
briefing refresh, OnTradeTransaction fire-and-forget trade report
- Recompile: 0 errors, 0 warnings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 06:34:27 +00:00
|
|
|
color gw_color = clrGray;
|
|
|
|
|
string gw_text = "GW: " + GW_Status;
|
|
|
|
|
if(GW_Status == "ACTIVE") gw_color = clrLime;
|
|
|
|
|
if(GW_Status == "OFFLINE_ADVISORY") gw_color = clrOrange;
|
|
|
|
|
if(GW_Status == "ERROR") gw_color = clrRed;
|
|
|
|
|
if(GW_Status == "DISABLED") gw_color = clrDimGray;
|
2026-02-15 05:13:55 +00:00
|
|
|
|
2026-03-31 02:57:33 +00:00
|
|
|
VZ_DrawLabel("AILabel", 1, gw_text, gw_color, 10);
|
2026-02-15 05:13:55 +00:00
|
|
|
|
feat: replace OpenAI with n8n AI Gateway + session + watchlist
- Remove OpenAI.mqh entirely (no direct API calls)
- Add AIGateway.mqh: unified gateway → n8n → OpenRouter → Claude
- advisory mode: EA never fails to start (gateway down = MAYBE 0.5x)
- mandatory mode: blocks trades if gateway unreachable
- actions: validate_trade, get_briefing, get_session, get_news_bias,
report_trade, watchlist_status, ping
- includes bid/est_sl/est_tp in validate_trade payload
- Add AISession.mqh: AMD session detection (Asia/London/NY/Interbank)
with corner chart labels showing session phase + GW status
- InputParams.mqh: AI_Mode, AI_Gateway_URL, briefing TF flags,
AI_Session_Draw, Use_Watchlist_Gate
- GlobalVariables.mqh: gateway state, per-TF briefing cache,
session + news headlines globals
- MasterAICoordinator.mqh: wired to AIGateway (SetUseOpenAI shim kept)
- NewsEngine.mqh: merges live AI news bias from gateway
- AISignalConfirmation.mqh: delegates to AIValidateTrade()
- AILabels.mqh: GW status (color-coded), validation stats, per-TF briefs
- ChartLabels.mqh: session label integration
- profitgtx.mq5 v7.00: OnInit init gateway + session, OnTimer multi-TF
briefing refresh, OnTradeTransaction fire-and-forget trade report
- Recompile: 0 errors, 0 warnings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 06:34:27 +00:00
|
|
|
// Validation stats
|
|
|
|
|
if(AI_Validate_Trades && GW_Initialized)
|
2026-02-15 05:13:55 +00:00
|
|
|
{
|
feat: replace OpenAI with n8n AI Gateway + session + watchlist
- Remove OpenAI.mqh entirely (no direct API calls)
- Add AIGateway.mqh: unified gateway → n8n → OpenRouter → Claude
- advisory mode: EA never fails to start (gateway down = MAYBE 0.5x)
- mandatory mode: blocks trades if gateway unreachable
- actions: validate_trade, get_briefing, get_session, get_news_bias,
report_trade, watchlist_status, ping
- includes bid/est_sl/est_tp in validate_trade payload
- Add AISession.mqh: AMD session detection (Asia/London/NY/Interbank)
with corner chart labels showing session phase + GW status
- InputParams.mqh: AI_Mode, AI_Gateway_URL, briefing TF flags,
AI_Session_Draw, Use_Watchlist_Gate
- GlobalVariables.mqh: gateway state, per-TF briefing cache,
session + news headlines globals
- MasterAICoordinator.mqh: wired to AIGateway (SetUseOpenAI shim kept)
- NewsEngine.mqh: merges live AI news bias from gateway
- AISignalConfirmation.mqh: delegates to AIValidateTrade()
- AILabels.mqh: GW status (color-coded), validation stats, per-TF briefs
- ChartLabels.mqh: session label integration
- profitgtx.mq5 v7.00: OnInit init gateway + session, OnTimer multi-TF
briefing refresh, OnTradeTransaction fire-and-forget trade report
- Recompile: 0 errors, 0 warnings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 06:34:27 +00:00
|
|
|
int total = AI_Validation_Accepts + AI_Validation_Rejects;
|
|
|
|
|
double rate = (total > 0) ? ((double)AI_Validation_Accepts / total) * 100.0 : 0.0;
|
|
|
|
|
string stats = "AI Val: +" + IntegerToString(AI_Validation_Accepts) +
|
|
|
|
|
" -" + IntegerToString(AI_Validation_Rejects) +
|
|
|
|
|
" (" + DoubleToString(rate, 0) + "%)";
|
2026-03-31 02:57:33 +00:00
|
|
|
color rate_color = clrYellow;
|
|
|
|
|
if(rate >= 90.0) rate_color = clrGold;
|
|
|
|
|
else if(rate >= 70.0) rate_color = clrLime;
|
|
|
|
|
else if(rate >= 50.0) rate_color = clrCyan;
|
|
|
|
|
else if(rate >= 35.0) rate_color = clrOrange;
|
|
|
|
|
else rate_color = clrRed;
|
|
|
|
|
VZ_DrawLabel("AIStatsLabel", 2, stats, rate_color, 9);
|
2026-02-15 05:13:55 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-31 02:57:33 +00:00
|
|
|
// Per-TF briefing display (upper-left stack)
|
feat: replace OpenAI with n8n AI Gateway + session + watchlist
- Remove OpenAI.mqh entirely (no direct API calls)
- Add AIGateway.mqh: unified gateway → n8n → OpenRouter → Claude
- advisory mode: EA never fails to start (gateway down = MAYBE 0.5x)
- mandatory mode: blocks trades if gateway unreachable
- actions: validate_trade, get_briefing, get_session, get_news_bias,
report_trade, watchlist_status, ping
- includes bid/est_sl/est_tp in validate_trade payload
- Add AISession.mqh: AMD session detection (Asia/London/NY/Interbank)
with corner chart labels showing session phase + GW status
- InputParams.mqh: AI_Mode, AI_Gateway_URL, briefing TF flags,
AI_Session_Draw, Use_Watchlist_Gate
- GlobalVariables.mqh: gateway state, per-TF briefing cache,
session + news headlines globals
- MasterAICoordinator.mqh: wired to AIGateway (SetUseOpenAI shim kept)
- NewsEngine.mqh: merges live AI news bias from gateway
- AISignalConfirmation.mqh: delegates to AIValidateTrade()
- AILabels.mqh: GW status (color-coded), validation stats, per-TF briefs
- ChartLabels.mqh: session label integration
- profitgtx.mq5 v7.00: OnInit init gateway + session, OnTimer multi-TF
briefing refresh, OnTradeTransaction fire-and-forget trade report
- Recompile: 0 errors, 0 warnings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 06:34:27 +00:00
|
|
|
if(StringLen(GW_Brief_H1) > 0)
|
2026-02-15 05:13:55 +00:00
|
|
|
{
|
feat: replace OpenAI with n8n AI Gateway + session + watchlist
- Remove OpenAI.mqh entirely (no direct API calls)
- Add AIGateway.mqh: unified gateway → n8n → OpenRouter → Claude
- advisory mode: EA never fails to start (gateway down = MAYBE 0.5x)
- mandatory mode: blocks trades if gateway unreachable
- actions: validate_trade, get_briefing, get_session, get_news_bias,
report_trade, watchlist_status, ping
- includes bid/est_sl/est_tp in validate_trade payload
- Add AISession.mqh: AMD session detection (Asia/London/NY/Interbank)
with corner chart labels showing session phase + GW status
- InputParams.mqh: AI_Mode, AI_Gateway_URL, briefing TF flags,
AI_Session_Draw, Use_Watchlist_Gate
- GlobalVariables.mqh: gateway state, per-TF briefing cache,
session + news headlines globals
- MasterAICoordinator.mqh: wired to AIGateway (SetUseOpenAI shim kept)
- NewsEngine.mqh: merges live AI news bias from gateway
- AISignalConfirmation.mqh: delegates to AIValidateTrade()
- AILabels.mqh: GW status (color-coded), validation stats, per-TF briefs
- ChartLabels.mqh: session label integration
- profitgtx.mq5 v7.00: OnInit init gateway + session, OnTimer multi-TF
briefing refresh, OnTradeTransaction fire-and-forget trade report
- Recompile: 0 errors, 0 warnings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 06:34:27 +00:00
|
|
|
string lbl = "AIBriefH1";
|
2026-03-31 02:57:33 +00:00
|
|
|
VZ_DrawLabel(lbl, 3, "H1: " + StringSubstr(GW_Brief_H1, 0, 60), clrAqua, 8);
|
feat: replace OpenAI with n8n AI Gateway + session + watchlist
- Remove OpenAI.mqh entirely (no direct API calls)
- Add AIGateway.mqh: unified gateway → n8n → OpenRouter → Claude
- advisory mode: EA never fails to start (gateway down = MAYBE 0.5x)
- mandatory mode: blocks trades if gateway unreachable
- actions: validate_trade, get_briefing, get_session, get_news_bias,
report_trade, watchlist_status, ping
- includes bid/est_sl/est_tp in validate_trade payload
- Add AISession.mqh: AMD session detection (Asia/London/NY/Interbank)
with corner chart labels showing session phase + GW status
- InputParams.mqh: AI_Mode, AI_Gateway_URL, briefing TF flags,
AI_Session_Draw, Use_Watchlist_Gate
- GlobalVariables.mqh: gateway state, per-TF briefing cache,
session + news headlines globals
- MasterAICoordinator.mqh: wired to AIGateway (SetUseOpenAI shim kept)
- NewsEngine.mqh: merges live AI news bias from gateway
- AISignalConfirmation.mqh: delegates to AIValidateTrade()
- AILabels.mqh: GW status (color-coded), validation stats, per-TF briefs
- ChartLabels.mqh: session label integration
- profitgtx.mq5 v7.00: OnInit init gateway + session, OnTimer multi-TF
briefing refresh, OnTradeTransaction fire-and-forget trade report
- Recompile: 0 errors, 0 warnings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 06:34:27 +00:00
|
|
|
}
|
|
|
|
|
if(StringLen(GW_Brief_H4) > 0)
|
|
|
|
|
{
|
|
|
|
|
string lbl = "AIBriefH4";
|
2026-03-31 02:57:33 +00:00
|
|
|
VZ_DrawLabel(lbl, 4, "H4: " + StringSubstr(GW_Brief_H4, 0, 60), clrDeepSkyBlue, 8);
|
feat: replace OpenAI with n8n AI Gateway + session + watchlist
- Remove OpenAI.mqh entirely (no direct API calls)
- Add AIGateway.mqh: unified gateway → n8n → OpenRouter → Claude
- advisory mode: EA never fails to start (gateway down = MAYBE 0.5x)
- mandatory mode: blocks trades if gateway unreachable
- actions: validate_trade, get_briefing, get_session, get_news_bias,
report_trade, watchlist_status, ping
- includes bid/est_sl/est_tp in validate_trade payload
- Add AISession.mqh: AMD session detection (Asia/London/NY/Interbank)
with corner chart labels showing session phase + GW status
- InputParams.mqh: AI_Mode, AI_Gateway_URL, briefing TF flags,
AI_Session_Draw, Use_Watchlist_Gate
- GlobalVariables.mqh: gateway state, per-TF briefing cache,
session + news headlines globals
- MasterAICoordinator.mqh: wired to AIGateway (SetUseOpenAI shim kept)
- NewsEngine.mqh: merges live AI news bias from gateway
- AISignalConfirmation.mqh: delegates to AIValidateTrade()
- AILabels.mqh: GW status (color-coded), validation stats, per-TF briefs
- ChartLabels.mqh: session label integration
- profitgtx.mq5 v7.00: OnInit init gateway + session, OnTimer multi-TF
briefing refresh, OnTradeTransaction fire-and-forget trade report
- Recompile: 0 errors, 0 warnings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 06:34:27 +00:00
|
|
|
}
|
|
|
|
|
if(StringLen(GW_Brief_D1) > 0)
|
|
|
|
|
{
|
|
|
|
|
string lbl = "AIBriefD1";
|
2026-03-31 02:57:33 +00:00
|
|
|
VZ_DrawLabel(lbl, 5, "D1: " + StringSubstr(GW_Brief_D1, 0, 60), clrKhaki, 8);
|
feat: replace OpenAI with n8n AI Gateway + session + watchlist
- Remove OpenAI.mqh entirely (no direct API calls)
- Add AIGateway.mqh: unified gateway → n8n → OpenRouter → Claude
- advisory mode: EA never fails to start (gateway down = MAYBE 0.5x)
- mandatory mode: blocks trades if gateway unreachable
- actions: validate_trade, get_briefing, get_session, get_news_bias,
report_trade, watchlist_status, ping
- includes bid/est_sl/est_tp in validate_trade payload
- Add AISession.mqh: AMD session detection (Asia/London/NY/Interbank)
with corner chart labels showing session phase + GW status
- InputParams.mqh: AI_Mode, AI_Gateway_URL, briefing TF flags,
AI_Session_Draw, Use_Watchlist_Gate
- GlobalVariables.mqh: gateway state, per-TF briefing cache,
session + news headlines globals
- MasterAICoordinator.mqh: wired to AIGateway (SetUseOpenAI shim kept)
- NewsEngine.mqh: merges live AI news bias from gateway
- AISignalConfirmation.mqh: delegates to AIValidateTrade()
- AILabels.mqh: GW status (color-coded), validation stats, per-TF briefs
- ChartLabels.mqh: session label integration
- profitgtx.mq5 v7.00: OnInit init gateway + session, OnTimer multi-TF
briefing refresh, OnTradeTransaction fire-and-forget trade report
- Recompile: 0 errors, 0 warnings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 06:34:27 +00:00
|
|
|
}
|
2026-02-15 05:13:55 +00:00
|
|
|
|
2026-03-31 02:57:33 +00:00
|
|
|
// Last AI decision in upper-left
|
feat: replace OpenAI with n8n AI Gateway + session + watchlist
- Remove OpenAI.mqh entirely (no direct API calls)
- Add AIGateway.mqh: unified gateway → n8n → OpenRouter → Claude
- advisory mode: EA never fails to start (gateway down = MAYBE 0.5x)
- mandatory mode: blocks trades if gateway unreachable
- actions: validate_trade, get_briefing, get_session, get_news_bias,
report_trade, watchlist_status, ping
- includes bid/est_sl/est_tp in validate_trade payload
- Add AISession.mqh: AMD session detection (Asia/London/NY/Interbank)
with corner chart labels showing session phase + GW status
- InputParams.mqh: AI_Mode, AI_Gateway_URL, briefing TF flags,
AI_Session_Draw, Use_Watchlist_Gate
- GlobalVariables.mqh: gateway state, per-TF briefing cache,
session + news headlines globals
- MasterAICoordinator.mqh: wired to AIGateway (SetUseOpenAI shim kept)
- NewsEngine.mqh: merges live AI news bias from gateway
- AISignalConfirmation.mqh: delegates to AIValidateTrade()
- AILabels.mqh: GW status (color-coded), validation stats, per-TF briefs
- ChartLabels.mqh: session label integration
- profitgtx.mq5 v7.00: OnInit init gateway + session, OnTimer multi-TF
briefing refresh, OnTradeTransaction fire-and-forget trade report
- Recompile: 0 errors, 0 warnings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 06:34:27 +00:00
|
|
|
if(StringLen(Last_AI_Analysis) > 0)
|
|
|
|
|
{
|
|
|
|
|
string lbl = "AIAnalysisBox";
|
2026-03-31 02:57:33 +00:00
|
|
|
color analysis_color = clrSilver;
|
|
|
|
|
string analysis_upper = UpperCopy(Last_AI_Analysis);
|
|
|
|
|
if(StringFind(analysis_upper, "APPROVED") >= 0) analysis_color = clrLime;
|
|
|
|
|
else if(StringFind(analysis_upper, "REJECTED") >= 0) analysis_color = clrRed;
|
|
|
|
|
else if(StringFind(analysis_upper, "BLOCK") >= 0) analysis_color = clrOrange;
|
|
|
|
|
VZ_DrawLabel(lbl, 6, StringSubstr(Last_AI_Analysis, 0, 120), analysis_color, 8);
|
2026-02-15 05:13:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CleanupAILabels()
|
|
|
|
|
{
|
feat: replace OpenAI with n8n AI Gateway + session + watchlist
- Remove OpenAI.mqh entirely (no direct API calls)
- Add AIGateway.mqh: unified gateway → n8n → OpenRouter → Claude
- advisory mode: EA never fails to start (gateway down = MAYBE 0.5x)
- mandatory mode: blocks trades if gateway unreachable
- actions: validate_trade, get_briefing, get_session, get_news_bias,
report_trade, watchlist_status, ping
- includes bid/est_sl/est_tp in validate_trade payload
- Add AISession.mqh: AMD session detection (Asia/London/NY/Interbank)
with corner chart labels showing session phase + GW status
- InputParams.mqh: AI_Mode, AI_Gateway_URL, briefing TF flags,
AI_Session_Draw, Use_Watchlist_Gate
- GlobalVariables.mqh: gateway state, per-TF briefing cache,
session + news headlines globals
- MasterAICoordinator.mqh: wired to AIGateway (SetUseOpenAI shim kept)
- NewsEngine.mqh: merges live AI news bias from gateway
- AISignalConfirmation.mqh: delegates to AIValidateTrade()
- AILabels.mqh: GW status (color-coded), validation stats, per-TF briefs
- ChartLabels.mqh: session label integration
- profitgtx.mq5 v7.00: OnInit init gateway + session, OnTimer multi-TF
briefing refresh, OnTradeTransaction fire-and-forget trade report
- Recompile: 0 errors, 0 warnings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 06:34:27 +00:00
|
|
|
string labels[] = {"AILabel","AIStatsLabel","AIBriefH1","AIBriefH4","AIBriefD1","AIAnalysisBox"};
|
|
|
|
|
for(int i = 0; i < ArraySize(labels); i++)
|
|
|
|
|
ObjectDelete(0, labels[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DisplayAIBriefing(const string briefing)
|
|
|
|
|
{
|
|
|
|
|
Last_AI_Analysis = briefing;
|
|
|
|
|
Print("[AI BRIEFING] ", briefing);
|
|
|
|
|
UpdateAILabel();
|
2026-02-15 05:13:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DisplayAIValidation(const string setup, const bool approved, const string reasoning)
|
|
|
|
|
{
|
feat: replace OpenAI with n8n AI Gateway + session + watchlist
- Remove OpenAI.mqh entirely (no direct API calls)
- Add AIGateway.mqh: unified gateway → n8n → OpenRouter → Claude
- advisory mode: EA never fails to start (gateway down = MAYBE 0.5x)
- mandatory mode: blocks trades if gateway unreachable
- actions: validate_trade, get_briefing, get_session, get_news_bias,
report_trade, watchlist_status, ping
- includes bid/est_sl/est_tp in validate_trade payload
- Add AISession.mqh: AMD session detection (Asia/London/NY/Interbank)
with corner chart labels showing session phase + GW status
- InputParams.mqh: AI_Mode, AI_Gateway_URL, briefing TF flags,
AI_Session_Draw, Use_Watchlist_Gate
- GlobalVariables.mqh: gateway state, per-TF briefing cache,
session + news headlines globals
- MasterAICoordinator.mqh: wired to AIGateway (SetUseOpenAI shim kept)
- NewsEngine.mqh: merges live AI news bias from gateway
- AISignalConfirmation.mqh: delegates to AIValidateTrade()
- AILabels.mqh: GW status (color-coded), validation stats, per-TF briefs
- ChartLabels.mqh: session label integration
- profitgtx.mq5 v7.00: OnInit init gateway + session, OnTimer multi-TF
briefing refresh, OnTradeTransaction fire-and-forget trade report
- Recompile: 0 errors, 0 warnings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 06:34:27 +00:00
|
|
|
Last_AI_Analysis = "GW Val " + setup + ": " + (approved ? "APPROVED" : "REJECTED") + " | " + reasoning;
|
2026-02-15 05:13:55 +00:00
|
|
|
UpdateAILabel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|