2026-02-15 05:13:55 +00:00
|
|
|
#ifndef GLOBAL_VARIABLES_MQH
|
|
|
|
|
#define GLOBAL_VARIABLES_MQH
|
|
|
|
|
|
2026-03-31 02:57:33 +00:00
|
|
|
struct SymbolPolicy
|
|
|
|
|
{
|
|
|
|
|
string symbol_name;
|
|
|
|
|
string symbol_class;
|
|
|
|
|
double base_risk_percent;
|
|
|
|
|
double max_spread_points;
|
|
|
|
|
int min_stop_points;
|
|
|
|
|
string preferred_sessions;
|
|
|
|
|
double news_sensitivity;
|
|
|
|
|
double lot_floor;
|
|
|
|
|
double lot_ceiling;
|
|
|
|
|
int max_concurrent_exposure;
|
|
|
|
|
bool continuation_differs;
|
|
|
|
|
double continuation_risk_mult;
|
|
|
|
|
double counter_risk_mult;
|
|
|
|
|
bool require_session_alignment;
|
|
|
|
|
double min_free_margin_pct;
|
|
|
|
|
double max_account_risk_pct;
|
|
|
|
|
double max_margin_pct;
|
|
|
|
|
string notes;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SymbolPolicyFeedbackState
|
|
|
|
|
{
|
|
|
|
|
string symbol_class;
|
|
|
|
|
int sample_count;
|
|
|
|
|
int win_count;
|
|
|
|
|
int loss_count;
|
|
|
|
|
int continuation_count;
|
|
|
|
|
int continuation_win_count;
|
|
|
|
|
int counter_count;
|
|
|
|
|
int counter_win_count;
|
|
|
|
|
double ema_profit;
|
|
|
|
|
double ema_spread_points;
|
|
|
|
|
double ema_margin_headroom_pct;
|
|
|
|
|
double ema_risk_amount_pct;
|
|
|
|
|
double ema_win_rate;
|
|
|
|
|
datetime last_update;
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-15 05:13:55 +00:00
|
|
|
int SetupCount[64];
|
|
|
|
|
datetime LastEntryTime[64];
|
|
|
|
|
|
|
|
|
|
datetime Last_Trade_Time = 0;
|
|
|
|
|
string LastTradeDirection = "";
|
|
|
|
|
|
|
|
|
|
datetime Last_MA_Retest_Trade = 0;
|
|
|
|
|
datetime Last_MA_Reject_Trade = 0;
|
|
|
|
|
|
|
|
|
|
int Active_Warnings = 0;
|
|
|
|
|
int Active_Praise_Signals = 0;
|
|
|
|
|
int Warning_Confluence_Count = 0;
|
|
|
|
|
bool Warning_Confluence_3Plus = false;
|
|
|
|
|
int Praise_Count = 0;
|
|
|
|
|
|
|
|
|
|
int PatternComboWarn = 0;
|
|
|
|
|
int PatternComboPraise = 0;
|
|
|
|
|
bool DoubleTopAtFib = false;
|
|
|
|
|
bool DoubleBottomAtFib = false;
|
|
|
|
|
|
|
|
|
|
int TodayTrades = 0;
|
|
|
|
|
int BuyTrades = 0;
|
|
|
|
|
int SellTrades = 0;
|
|
|
|
|
int ClosedByReversal = 0;
|
|
|
|
|
|
|
|
|
|
int Current_Mode = MODE_CHOP;
|
|
|
|
|
int Current_State = STATE_PULLBACK;
|
|
|
|
|
int Current_Bias_Direction = 0;
|
|
|
|
|
|
|
|
|
|
double State_Bias_Confidence = 0.0;
|
|
|
|
|
|
|
|
|
|
int Coordinator_Bias_Direction = 0;
|
|
|
|
|
double Coordinator_Cluster_Strength = 0.0;
|
|
|
|
|
double Coordinator_Conflict_Score = 100.0;
|
|
|
|
|
double Coordinator_Lot_Multiplier = 1.0;
|
|
|
|
|
bool Coordinator_AllowTrade = false;
|
|
|
|
|
|
|
|
|
|
int BullWarnCount = 0;
|
|
|
|
|
int BullPraiseCount = 0;
|
|
|
|
|
int BearWarnCount = 0;
|
|
|
|
|
int BearPraiseCount = 0;
|
|
|
|
|
|
|
|
|
|
string Symbol_Profile_Name = "MANUAL";
|
|
|
|
|
int Symbol_SL_Points = 800;
|
|
|
|
|
int Symbol_TP_Points = 5000;
|
|
|
|
|
bool Symbol_Profile_Initialized = false;
|
2026-03-31 02:57:33 +00:00
|
|
|
SymbolPolicy g_symbol_policy;
|
|
|
|
|
bool g_symbol_policy_ready = false;
|
|
|
|
|
SymbolPolicyFeedbackState g_symbol_feedback_states[8];
|
|
|
|
|
bool g_symbol_feedback_ready = false;
|
|
|
|
|
string g_symbol_session_name = "";
|
|
|
|
|
string g_symbol_session_phase = "A";
|
|
|
|
|
double g_symbol_spread_points = 0.0;
|
|
|
|
|
double g_symbol_balance = 0.0;
|
|
|
|
|
double g_symbol_equity = 0.0;
|
|
|
|
|
double g_symbol_free_margin = 0.0;
|
|
|
|
|
double g_symbol_margin_required = 0.0;
|
|
|
|
|
double g_symbol_risk_amount = 0.0;
|
|
|
|
|
string g_symbol_reject_reason = "";
|
|
|
|
|
double g_symbol_intended_lots = 0.0;
|
|
|
|
|
double g_symbol_final_lots = 0.0;
|
2026-02-15 05:13:55 +00:00
|
|
|
|
2026-02-27 21:49:28 -06:00
|
|
|
// ── Deployment profile (resolved at OnInit by AutoDetectDeployment) ──────────
|
|
|
|
|
string g_nn_url = ""; // active NN predict URL
|
|
|
|
|
string g_gw_url = ""; // active AI Gateway URL
|
|
|
|
|
bool g_is_container = false; // true = internal socat bridges; false = laptop HTTPS
|
|
|
|
|
|
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
|
|
|
// AI Gateway state
|
|
|
|
|
bool GW_Initialized = false;
|
|
|
|
|
string GW_Status = "NOT_INIT";
|
2026-02-15 05:13:55 +00:00
|
|
|
string Last_AI_Analysis = "";
|
|
|
|
|
int AI_Validation_Accepts = 0;
|
|
|
|
|
int AI_Validation_Rejects = 0;
|
|
|
|
|
|
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
|
|
|
// Multi-TF briefing cache
|
|
|
|
|
datetime Last_GW_Briefing_H1 = 0;
|
|
|
|
|
datetime Last_GW_Briefing_H4 = 0;
|
|
|
|
|
datetime Last_GW_Briefing_D1 = 0;
|
2026-03-31 02:57:33 +00:00
|
|
|
datetime Last_GW_Session_Update = 0;
|
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 GW_Brief_H1 = "";
|
|
|
|
|
string GW_Brief_H4 = "";
|
|
|
|
|
string GW_Brief_D1 = "";
|
|
|
|
|
|
|
|
|
|
// Session state
|
|
|
|
|
string GW_Session_Name = "";
|
|
|
|
|
string GW_Session_Phase = "";
|
|
|
|
|
double GW_Session_Confidence = 0.0;
|
|
|
|
|
|
|
|
|
|
// Live news from gateway
|
|
|
|
|
string GW_News_Headlines = "";
|
|
|
|
|
bool GW_News_Block_Flag = false;
|
|
|
|
|
|
|
|
|
|
// Watchlist
|
|
|
|
|
bool GW_Symbol_Active = true;
|
|
|
|
|
|
2026-02-15 05:13:55 +00:00
|
|
|
bool NN_Initialized = false;
|
|
|
|
|
int NN_Bias = 0;
|
|
|
|
|
double NN_Confidence = 0.0;
|
|
|
|
|
double NN_RiskScore = 50.0;
|
|
|
|
|
string NN_Explain = "";
|
|
|
|
|
datetime NN_LastRun = 0;
|
|
|
|
|
bool NN_UsedLastTick = false;
|
|
|
|
|
|
2026-02-27 21:49:28 -06:00
|
|
|
// ── News state ───────────────────────────────────────────────────────────────
|
|
|
|
|
int News_Bias_Direction = 0;
|
|
|
|
|
double News_Bias_Strength = 0.0;
|
|
|
|
|
bool News_Trade_Block_Active = false; // hard-block (no clear direction)
|
|
|
|
|
int News_Trade_Allowed_Direction = 0; // 1=buy-only, -1=sell-only, 0=unrestricted
|
|
|
|
|
string News_Last_Headline = "";
|
|
|
|
|
string News_Bias_Report = "";
|
|
|
|
|
datetime News_Last_Update = 0;
|
|
|
|
|
string News_Pending_Events_JSON = "[]"; // upcoming high-impact events → sent to AI gateway
|
2026-02-15 05:13:55 +00:00
|
|
|
|
|
|
|
|
// Warning flags
|
|
|
|
|
bool MA7_Cross_14_Warning = false;
|
|
|
|
|
bool MA7_Cross_21_Warning = false;
|
|
|
|
|
bool MA50_Break_Warning = false;
|
|
|
|
|
bool Fib_Reject_Warning = false;
|
|
|
|
|
bool MFIB_Reject_Warning = false;
|
|
|
|
|
bool Fib_Reclaim_Warning = false;
|
|
|
|
|
bool MFIB_Reclaim_Warning = false;
|
|
|
|
|
bool Fib_Break_Warning = false;
|
|
|
|
|
bool MFIB_Break_Warning = false;
|
|
|
|
|
bool MA_Reject_Warning = false;
|
|
|
|
|
bool MA_Reclaim_Warning = false;
|
|
|
|
|
bool MA_Break_Warning = false;
|
|
|
|
|
bool Stoch_Extreme_Warning = false;
|
|
|
|
|
bool Stoch_Reject_Warning = false;
|
|
|
|
|
bool Stoch_Level_Cross = false;
|
|
|
|
|
bool MA50_Warning = false;
|
|
|
|
|
bool MA140_Warning = false;
|
|
|
|
|
bool MA230_Warning = false;
|
|
|
|
|
bool MA500_Warning = false;
|
|
|
|
|
bool Pullback_Warning = false;
|
|
|
|
|
bool Retracement_Warning = false;
|
|
|
|
|
bool Band_Snap_Warning = false;
|
|
|
|
|
bool MA14_Magnet_Active = false;
|
|
|
|
|
bool Fib_Break_Confirmed = false;
|
|
|
|
|
bool MFIB_Break_Confirmed = false;
|
|
|
|
|
bool Strong_MA_Bounce = false;
|
|
|
|
|
bool Trend_Resumption = false;
|
|
|
|
|
|
|
|
|
|
// Praise flags
|
|
|
|
|
bool Praise_Triple_Magnet = false;
|
|
|
|
|
bool Praise_Power_Couple = false;
|
|
|
|
|
bool Praise_MFIB_Staircase = false;
|
|
|
|
|
bool Praise_MFIB_Express = false;
|
|
|
|
|
bool Praise_MFIB_Breakout = false;
|
|
|
|
|
bool Praise_MA_Stack = false;
|
|
|
|
|
bool Praise_Clean_Reclaim = false;
|
|
|
|
|
bool Praise_Multi_Breakout = false;
|
|
|
|
|
|
|
|
|
|
#endif
|