forked from MasoodIqbal/RSI-Stoch-MA-EA
137 lines
No EOL
5.2 KiB
MQL5
137 lines
No EOL
5.2 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| AILabels.mqh |
|
|
//| AI Analysis Display on Chart |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "QuarterTheory x VIZION"
|
|
#property strict
|
|
|
|
#include "GlobalVariables.mqh"
|
|
#include "InputParams.mqh"
|
|
|
|
//================ FORWARD DECLARATIONS ==================//
|
|
bool IsAIEnabled();
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Update AI analysis label |
|
|
//+------------------------------------------------------------------+
|
|
void UpdateAILabel()
|
|
{
|
|
if(!Use_OpenAI || !IsAIEnabled())
|
|
{
|
|
ObjectDelete(0, "AILabel");
|
|
ObjectDelete(0, "AIStatsLabel");
|
|
return;
|
|
}
|
|
|
|
//================================================================
|
|
// AI STATUS LABEL
|
|
//================================================================
|
|
ObjectDelete(0, "AILabel");
|
|
ObjectCreate(0, "AILabel", OBJ_LABEL, 0, 0, 0);
|
|
ObjectSetInteger(0, "AILabel", OBJPROP_CORNER, CORNER_RIGHT_UPPER);
|
|
ObjectSetInteger(0, "AILabel", OBJPROP_XDISTANCE, 10);
|
|
ObjectSetInteger(0, "AILabel", OBJPROP_YDISTANCE, 20);
|
|
|
|
string ai_text = "🤖 AI: ";
|
|
if(AI_Initialized)
|
|
ai_text += "ACTIVE";
|
|
else
|
|
ai_text += "INACTIVE";
|
|
|
|
if(AI_Validate_Trades)
|
|
ai_text += " | VALIDATING";
|
|
|
|
color ai_color = AI_Initialized ? clrLime : clrGray;
|
|
|
|
ObjectSetString(0, "AILabel", OBJPROP_TEXT, ai_text);
|
|
ObjectSetInteger(0, "AILabel", OBJPROP_COLOR, ai_color);
|
|
ObjectSetInteger(0, "AILabel", OBJPROP_FONTSIZE, 10);
|
|
|
|
//================================================================
|
|
// AI VALIDATION STATS
|
|
//================================================================
|
|
if(AI_Validate_Trades && AI_Initialized)
|
|
{
|
|
ObjectDelete(0, "AIStatsLabel");
|
|
ObjectCreate(0, "AIStatsLabel", OBJ_LABEL, 0, 0, 0);
|
|
ObjectSetInteger(0, "AIStatsLabel", OBJPROP_CORNER, CORNER_RIGHT_UPPER);
|
|
ObjectSetInteger(0, "AIStatsLabel", OBJPROP_XDISTANCE, 10);
|
|
ObjectSetInteger(0, "AIStatsLabel", OBJPROP_YDISTANCE, 40);
|
|
|
|
int total_validations = AI_Validation_Accepts + AI_Validation_Rejects;
|
|
double accept_rate = 0;
|
|
if(total_validations > 0)
|
|
accept_rate = (double)AI_Validation_Accepts / total_validations * 100;
|
|
|
|
string stats_text = "AI Validation: ✓" + IntegerToString(AI_Validation_Accepts);
|
|
stats_text += " ✗" + IntegerToString(AI_Validation_Rejects);
|
|
stats_text += " (" + DoubleToString(accept_rate, 1) + "%)";
|
|
|
|
ObjectSetString(0, "AIStatsLabel", OBJPROP_TEXT, stats_text);
|
|
ObjectSetInteger(0, "AIStatsLabel", OBJPROP_COLOR, clrYellow);
|
|
ObjectSetInteger(0, "AIStatsLabel", OBJPROP_FONTSIZE, 9);
|
|
}
|
|
|
|
//================================================================
|
|
// AI ANALYSIS TEXT BOX (if recent analysis available)
|
|
//================================================================
|
|
if(StringLen(Last_AI_Analysis) > 0)
|
|
{
|
|
ObjectDelete(0, "AIAnalysisBox");
|
|
ObjectCreate(0, "AIAnalysisBox", OBJ_LABEL, 0, 0, 0);
|
|
ObjectSetInteger(0, "AIAnalysisBox", OBJPROP_CORNER, CORNER_RIGHT_LOWER);
|
|
ObjectSetInteger(0, "AIAnalysisBox", OBJPROP_XDISTANCE, 10);
|
|
ObjectSetInteger(0, "AIAnalysisBox", OBJPROP_YDISTANCE, 100);
|
|
|
|
// Truncate if too long
|
|
string display_text = Last_AI_Analysis;
|
|
if(StringLen(display_text) > 300)
|
|
display_text = StringSubstr(display_text, 0, 297) + "...";
|
|
|
|
ObjectSetString(0, "AIAnalysisBox", OBJPROP_TEXT, "💡 " + display_text);
|
|
ObjectSetInteger(0, "AIAnalysisBox", OBJPROP_COLOR, clrAqua);
|
|
ObjectSetInteger(0, "AIAnalysisBox", OBJPROP_FONTSIZE, 8);
|
|
}
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Clean up AI labels |
|
|
//+------------------------------------------------------------------+
|
|
void CleanupAILabels()
|
|
{
|
|
ObjectsDeleteAll(0, "AILabel");
|
|
ObjectsDeleteAll(0, "AIStatsLabel");
|
|
ObjectsDeleteAll(0, "AIAnalysisBox");
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Display AI briefing on chart |
|
|
//+------------------------------------------------------------------+
|
|
void DisplayAIBriefing(string briefing)
|
|
{
|
|
Last_AI_Analysis = briefing;
|
|
|
|
// Also print to log
|
|
Print("================================");
|
|
Print("🤖 AI DAILY BRIEFING:");
|
|
Print(briefing);
|
|
Print("================================");
|
|
|
|
// Update label immediately
|
|
UpdateAILabel();
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Display AI trade validation result |
|
|
//+------------------------------------------------------------------+
|
|
void DisplayAIValidation(string setup, bool approved, string reasoning)
|
|
{
|
|
string msg = "AI Trade Validation - " + setup + ": ";
|
|
msg += approved ? "✅ APPROVED" : "❌ REJECTED";
|
|
msg += "\n" + reasoning;
|
|
|
|
Last_AI_Analysis = msg;
|
|
|
|
Print("🤖 ", msg);
|
|
UpdateAILabel();
|
|
} |