//+------------------------------------------------------------------+
//|                                                 StopOutTypes.mqh |
//|                                       Copyright 2026, Ali Rajput |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Ali Rajput"
//+------------------------------------------------------------------+
//| Result of a stop-out price search for one symbol                 |
//+------------------------------------------------------------------+
enum ENUM_SOG_STATUS
  {
   SOG_OK=0,            // a threshold price was found inside the search range
   SOG_NO_POSITIONS,    // no open positions on the symbol
   SOG_OUT_OF_RANGE,    // no threshold inside the search range in that direction, no price given
   SOG_ALREADY_BELOW,   // the account is at or below the level already
   SOG_NO_MARGIN,       // the account uses no margin, so there is no stop-out
   SOG_CALC_FAILED      // OrderCalcProfit() or OrderCalcMargin() failed
  };
//+------------------------------------------------------------------+
//| Price at which the model charges the margin of open positions    |
//+------------------------------------------------------------------+
enum ENUM_SOG_MARGIN_BASIS
  {
   SOG_MARGIN_AT_OPEN=0,  // each side at its volume-weighted open price, as the tester kept it
   SOG_MARGIN_AT_PRICE    // each side at the moved price
  };
//+------------------------------------------------------------------+
//| Account settings that decide when the server closes positions    |
//+------------------------------------------------------------------+
struct SStopOutRules
  {
   bool              percent;  // true: level in percent of margin, false: equity in money
   double            call;     // margin call level
   double            stop_out; // stop-out level
  };
//+------------------------------------------------------------------+
//| Threshold price of one symbol, all other prices held still       |
//+------------------------------------------------------------------+
struct SStopOutPoint
  {
   string            symbol;       // symbol that was moved
   ENUM_SOG_STATUS   status;       // outcome of the search
   double            bid_now;      // bid when the search ran
   double            bid_at;       // first bid on the tick grid where the model reaches the level
   double            points;       // distance from bid_now, in points (signed)
   double            percent;      // distance from bid_now, in percent of bid_now (signed)
   double            equity;       // model equity at bid_at
   double            margin;       // model margin at bid_at
   double            margin_check; // account margin minus model margin at bid_now, % (EMPTY_VALUE: not checked)
  };
//+------------------------------------------------------------------+
//| Text for a status code                                           |
//+------------------------------------------------------------------+
string SogStatusText(const ENUM_SOG_STATUS status)
  {
   switch(status)
     {
      case SOG_OK:            return("ok");
      case SOG_NO_POSITIONS:  return("no positions");
      case SOG_OUT_OF_RANGE:  return("out of range");
      case SOG_ALREADY_BELOW: return("already below");
      case SOG_NO_MARGIN:     return("no margin");
      case SOG_CALC_FAILED:   return("calc failed");
     }
   return("unknown");
  }
//+------------------------------------------------------------------+
