VizionAI-Trading-EA/AILabels.mqh

84 行
2.8 KiB
MQL5

#ifndef AI_LABELS_MQH
#define AI_LABELS_MQH
#include "LabelUtils.mqh"
void UpdateAILabel()
{
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;
VZ_DrawLabel("AILabel", 1, gw_text, gw_color, 10);
// Validation stats
if(AI_Validate_Trades && GW_Initialized)
{
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) + "%)";
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);
}
// Per-TF briefing display (upper-left stack)
if(StringLen(GW_Brief_H1) > 0)
{
string lbl = "AIBriefH1";
VZ_DrawLabel(lbl, 3, "H1: " + StringSubstr(GW_Brief_H1, 0, 60), clrAqua, 8);
}
if(StringLen(GW_Brief_H4) > 0)
{
string lbl = "AIBriefH4";
VZ_DrawLabel(lbl, 4, "H4: " + StringSubstr(GW_Brief_H4, 0, 60), clrDeepSkyBlue, 8);
}
if(StringLen(GW_Brief_D1) > 0)
{
string lbl = "AIBriefD1";
VZ_DrawLabel(lbl, 5, "D1: " + StringSubstr(GW_Brief_D1, 0, 60), clrKhaki, 8);
}
// Last AI decision in upper-left
if(StringLen(Last_AI_Analysis) > 0)
{
string lbl = "AIAnalysisBox";
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);
}
}
void CleanupAILabels()
{
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();
}
void DisplayAIValidation(const string setup, const bool approved, const string reasoning)
{
Last_AI_Analysis = "GW Val " + setup + ": " + (approved ? "APPROVED" : "REJECTED") + " | " + reasoning;
UpdateAILabel();
}
#endif