VizionAI-Trading-EA/ChartLabels.mqh

116 行
5.8 KiB
MQL5

#ifndef CHART_LABELS_MQH
#define CHART_LABELS_MQH
#include "AILabels.mqh"
string STATUS_LABEL = "VZ_STATUS";
string POLICY_LABEL = "VZ_POLICY";
string RISK_LABEL = "VZ_RISK";
string SIGNAL_LABEL = "VZ_SIGNAL";
string NEWS_LABEL = "VZ_NEWS";
string GATE_LABEL = "VZ_GATE";
string ADAPT_LABEL = "VZ_ADAPT";
void UpdateLabels()
{
string bias = "NEUTRAL";
if(IsBullBias()) bias = "BULL";
if(IsBearBias()) bias = "BEAR";
string coord = Coordinator_AllowTrade ? "ALLOW" : "BLOCK";
string news_dir = (News_Bias_Direction > 0 ? "BULL" : News_Bias_Direction < 0 ? "BEAR" : "NEUTRAL");
bool blocked = (News_Trade_Block_Active || StringLen(g_symbol_reject_reason) > 0 || !Coordinator_AllowTrade);
bool reduced = (!blocked && (Coordinator_Conflict_Score > 30.0 || News_Bias_Strength >= 40.0 || NN_Confidence < NN_MinConfidenceToUse));
bool perfect = (!blocked &&
Coordinator_AllowTrade &&
!News_Trade_Block_Active &&
NN_Confidence >= 80.0 &&
Coordinator_Conflict_Score <= 20.0 &&
g_symbol_spread_points <= (g_symbol_policy_ready ? (g_symbol_policy.max_spread_points * 0.60) : 99999.0));
color status_color = VZ_ColorFromGate(!blocked, blocked, reduced);
if(perfect) status_color = clrGold;
string text = "Mode:" + ModeToString(Current_Mode) +
" | State:" + StateToString(Current_State) +
" | Bias:" + bias +
" | W:" + IntegerToString(Active_Warnings) +
" | P:" + IntegerToString(Active_Praise_Signals) +
" | ADX:" + DoubleToString(Current_ADX, 1) +
" | StochK:" + DoubleToString(Stoch_K_Current, 1) +
" | Coord:" + coord +
" | CStr:" + DoubleToString(Coordinator_Cluster_Strength, 1) +
" | CConf:" + DoubleToString(Coordinator_Conflict_Score, 1) +
" | NN:" + IntegerToString(NN_Bias) + "/" + DoubleToString(NN_Confidence, 0) +
" | News:" + news_dir + "/" + DoubleToString(News_Bias_Strength, 0) +
(News_Trade_Block_Active ? " BLOCK" : "");
VZ_DrawLabel(STATUS_LABEL, 0, text, status_color, 10);
string policy_text = "Policy: " + g_symbol_policy.symbol_class +
" risk=" + DoubleToString(g_symbol_policy.base_risk_percent, 2) + "%" +
" spread<=" + DoubleToString(g_symbol_policy.max_spread_points, 0) +
" stop>=" + IntegerToString(g_symbol_policy.min_stop_points) +
" ses=" + g_symbol_policy.preferred_sessions;
color policy_color = g_symbol_policy_ready ? clrCyan : clrOrange;
if(g_symbol_policy_ready && g_symbol_policy.symbol_class != "MANUAL")
policy_color = clrGold;
VZ_DrawLabel(POLICY_LABEL, 9, policy_text, policy_color, 9);
double spread_pct = (g_symbol_policy.max_spread_points > 0.0)
? (g_symbol_spread_points / g_symbol_policy.max_spread_points) * 100.0
: 0.0;
double free_margin_pct = (g_symbol_equity > 0.0) ? (g_symbol_free_margin / g_symbol_equity) * 100.0 : 0.0;
string risk_text = "Risk: spread " + DoubleToString(g_symbol_spread_points, 1) +
" (" + DoubleToString(spread_pct, 0) + "%)" +
" fm=" + DoubleToString(free_margin_pct, 1) + "%" +
" req=" + DoubleToString(g_symbol_margin_required, 2) +
" lots=" + DoubleToString(g_symbol_final_lots, 2);
VZ_DrawLabel(RISK_LABEL, 10, risk_text, VZ_ColorFromHeadroom(free_margin_pct, g_symbol_policy.min_free_margin_pct), 9);
bool perfect_alignment = (Coordinator_AllowTrade && !News_Trade_Block_Active && NN_Bias != 0 &&
((NN_Bias > 0 && News_Bias_Direction >= 0) || (NN_Bias < 0 && News_Bias_Direction <= 0)) &&
Coordinator_Conflict_Score <= 20.0);
color signal_color = clrSilver;
if(perfect_alignment && NN_Confidence >= 80.0) signal_color = clrGold;
else if(Coordinator_AllowTrade && !blocked) signal_color = clrLime;
else if(blocked) signal_color = clrRed;
else signal_color = clrCyan;
string signal_text = "Signal: coord " + DoubleToString(Coordinator_Cluster_Strength, 1) +
"/" + DoubleToString(Coordinator_Conflict_Score, 1) +
" NN " + IntegerToString(NN_Bias) + "/" + DoubleToString(NN_Confidence, 0) +
" phase=" + GW_Session_Phase;
VZ_DrawLabel(SIGNAL_LABEL, 11, signal_text, signal_color, 9);
color news_color = VZ_ColorFromDirection(News_Bias_Direction);
if(News_Bias_Direction == 0 && News_Bias_Strength >= 70.0) news_color = clrGold;
else if(News_Bias_Direction == 0 && News_Bias_Strength >= 40.0) news_color = clrOrange;
string news_text = "News: " + news_dir + " " + DoubleToString(News_Bias_Strength, 0) +
" block=" + (News_Trade_Block_Active ? "Y" : "N") +
" allow=" + IntegerToString(News_Trade_Allowed_Direction);
VZ_DrawLabel(NEWS_LABEL, 12, news_text, news_color, 9);
color gate_color = blocked ? clrRed : (reduced ? clrOrange : clrLime);
string gate_text = "Gate: " + (blocked ? "BLOCK" : (reduced ? "REDUCE" : "ALLOW")) +
" | " + g_symbol_reject_reason;
VZ_DrawLabel(GATE_LABEL, 13, gate_text, gate_color, 9);
VZ_DrawLabel(ADAPT_LABEL, 14, SymbolPolicyFeedbackSummary(), SymbolPolicyFeedbackColor(), 9);
UpdateAILabel();
UpdateSessionLabel();
}
void CleanupLabels()
{
ObjectDelete(0, STATUS_LABEL);
ObjectDelete(0, POLICY_LABEL);
ObjectDelete(0, RISK_LABEL);
ObjectDelete(0, SIGNAL_LABEL);
ObjectDelete(0, NEWS_LABEL);
ObjectDelete(0, GATE_LABEL);
ObjectDelete(0, ADAPT_LABEL);
CleanupAILabels();
CleanupSessionLabel();
}
#endif