//+------------------------------------------------------------------+
//|                                                  CoreDefines.mqh |
//|                          Copyright 2026, Wanateki Solutions Ltd. |
//|                                         https://www.wanateki.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Wanateki Solutions Ltd."
#property link      "https://www.wanateki.com"

#ifndef SCALPER_GUARD_CORE_DEFINES_MQH
#define SCALPER_GUARD_CORE_DEFINES_MQH

//+------------------------------------------------------------------+
//| Global Constants & Defaults                                      |
//+------------------------------------------------------------------+
#define DEFAULT_BUFFER_CAPACITY        500
#define DEFAULT_VELOCITY_WINDOW_SEC    5.0
#define DEFAULT_MIN_VELOCITY_PTS_SEC   0.5
#define DEFAULT_SPREAD_ZSCORE_LIMIT    2.5
#define DEFAULT_HARD_SPREAD_MAX_PTS    30.0
#define DEFAULT_MAX_FRICTION_RATIO     0.65
#define DEFAULT_EXPECTED_HOLDING_SEC   10.0
#define DEFAULT_MIN_EXPECTED_MOVE_PTS  10.0
#define DEFAULT_SLIPPAGE_ESTIMATE_PTS  2.0
#define DEFAULT_WARMUP_TICKS           15
#define DEFAULT_EWMA_TRANSITION_TICKS  500

//+------------------------------------------------------------------+
//| Enum: ENUM_SPREAD_TYPE                                           |
//| Distinguishes broker spread mechanism (informational metadata)   |
//+------------------------------------------------------------------+
enum ENUM_SPREAD_TYPE
  {
   SPREAD_TYPE_FLOATING = 0,   // Dynamic/variable market spread (ECN, standard Forex)
   SPREAD_TYPE_FIXED    = 1    // Constant/fixed algorithmically or contractually (Synthetics, Fixed FX)
  };

//+------------------------------------------------------------------+
//| Enum: ENUM_MARKET_REGIME                                         |
//| Classifies market friction state into discrete execution regimes |
//+------------------------------------------------------------------+
enum ENUM_MARKET_REGIME
  {
   REGIME_OPTIMAL = 0,         // Tight spread, sufficient velocity (Trade Allowed)
   REGIME_MODERATE = 1,        // Normal spread, acceptable cost (Trade Allowed)
   REGIME_FRICTION_LOCKED = 2, // Low velocity or excessive friction ratio (Trade Blocked)
   REGIME_SPREAD_SPIKE = 3     // Statistical anomaly or hard threshold breach (Trade Blocked)
  };

//+------------------------------------------------------------------+
//| Enum: ENUM_REJECTION_REASON                                      |
//| Explicit categorization of why a pre-trade check was rejected    |
//+------------------------------------------------------------------+
enum ENUM_REJECTION_REASON
  {
   REASON_NONE = 0,             // Trade permitted
   REASON_SPREAD_SPIKE = 1,     // Z-Score exceeded threshold
   REASON_HARD_SPREAD_MAX = 2,  // Spread exceeded absolute maximum limit
   REASON_LOW_VELOCITY = 3,     // Market price velocity is too low
   REASON_HIGH_FRICTION = 4,    // Friction ratio exceeded threshold
   REASON_BUFFER_NOT_READY = 5, // Insufficient tick history in circular buffer
   REASON_SCALE_MISMATCH = 6,   // User inputs are out-of-scale for symbol digits/dynamics (Trading Paused)
   REASON_COMMISSION_HURDLE = 7, // Zero-spread commission hurdle exceeds expected price displacement
   REASON_ADVERSE_MOMENTUM = 8,  // Order direction opposes strong instantaneous market velocity
   REASON_INVALID_TICK = 9       // Corrupted, zero, or crossed quotes (ask <= bid or bid/ask <= 0)
  };

//+------------------------------------------------------------------+
//| Struct: SSymbolProfile                                           |
//| Encapsulates symbol precision, tick sizing, and broker execution |
//+------------------------------------------------------------------+
struct SSymbolProfile
  {
   string            mSymbol;             // Symbol name
   int               mDigits;             // Decimal digits (5, 3, 2, 1, 0)
   double            mPoint;              // Point unit size
   double            mTickSize;           // Minimum price change step
   double            mTickValue;          // Monetary value of 1 tick per 1 lot
   ENUM_SPREAD_TYPE  mSpreadType;         // Broker declared spread type (Floating vs Fixed)
   int               mStopsLevel;         // Broker minimum stops level in points
   int               mFreezeLevel;        // Broker freeze level in points
   double            mTypicalSpreadPts;   // Current observed spread in points
   bool              mIsZeroSpreadAccount;// Zero-spread or raw ECN account flag
   double            mCommissionPerLot;   // Detected round-turn commission per 1.0 lot in deposit currency
   double            mCommissionPoints;   // Commission converted to equivalent symbol points
  };

//+------------------------------------------------------------------+
//| Struct: STickSample                                              |
//| Compact representation of a millisecond-stamped tick record      |
//+------------------------------------------------------------------+
struct STickSample
  {
   ulong             mTimestampMs;      // Server or local tick timestamp in milliseconds
   double            mBid;              // Bid price
   double            mAsk;              // Ask price
   double            mMidPrice;         // (Bid + Ask) / 2.0
   double            mSpreadPoints;     // (Ask - Bid) / Point
   double            mVolume;           // Tick volume or real traded volume (supports fractional crypto/CFD sizes)
  };

//+------------------------------------------------------------------+
//| Struct: SFrictionMetrics                                         |
//| Consolidated snapshot of real-time analytical metrics            |
//+------------------------------------------------------------------+
struct SFrictionMetrics
  {
   ENUM_MARKET_REGIME    mRegime;                   // Current operational regime
   ENUM_REJECTION_REASON mReason;                   // Active rejection reason code
   ENUM_SPREAD_TYPE      mSpreadType;               // Symbol spread model (Floating vs Fixed)
   int                   mDigits;                   // Symbol decimal digits
   double                mPoint;                    // Symbol point size
   double                mCurrentSpreadPoints;      // Current spread in points
   double                mMeanSpreadPoints;         // Rolling baseline mean spread
   double                mStdDevSpreadPoints;       // Rolling spread standard deviation
   double                mSpreadZScore;             // Instantaneous spread Z-score
   double                mTickVelocityPointsPerSec; // Absolute price displacement speed
   double                mSignedVelocity;           // Directional price displacement speed
   double                mTickFrequency;            // Real-time tick arrival frequency in ticks per second
   double                mFrictionRatio;            // Current friction ratio
   bool                  mIsZeroSpreadAccount;      // Zero-spread account flag
   double                mCommissionPoints;         // Commission in equivalent symbol points
   double                mEffectiveFrictionPoints;  // Total friction (Spread + Commission + Slippage) in points
   bool                  mIsSafeToTrade;            // Pre-trade boolean evaluation result
   bool                  mIsScaleValid;             // Out-of-scale validation status
   string                mScaleWarningMessage;      // Diagnostic guidance message if out-of-scale
   ulong                 mTotalEvaluations;         // Total pre-trade evaluations requested
   ulong                 mApprovedEvaluations;      // Pre-trade evaluations that passed
   ulong                 mBlockedEvaluations;       // Pre-trade evaluations that failed
  };

#endif // SCALPER_GUARD_CORE_DEFINES_MQH
