//+------------------------------------------------------------------+
//|                                          TradeExcursionTypes.mqh |
//+------------------------------------------------------------------+
#ifndef TRADEEXCURSIONTYPES_MQH
#define TRADEEXCURSIONTYPES_MQH

//+-------------------------------------------------------------------+
//| CTradeExcursion                                                   |
//| Holds everything the pipeline needs for one closed position: the  |
//| identifying and entry information gathered from deal history, and |
//| the Maximum Adverse Excursion (MAE), Maximum Favorable Excursion  |
//| (MFE), and entry efficiency computed from tick data afterward.    |
//| The two stages are represented in the same record because every   |
//| downstream component, the scatter chart, the histogram, and the   |
//| summary printer, needs both the entry-side facts and the computed |
//| excursion figures together for a single position.                 |
//+-------------------------------------------------------------------+
class CTradeExcursion
  {
public:
   ulong             m_position_id;         // MQL5 position identifier grouping the deals
   string            m_symbol;              // symbol this position was traded on
   bool              m_is_long;             // true for a long position, false for a short
   datetime          m_entry_time;          // server-time open of the position
   datetime          m_close_time;          // server-time of the last closing deal
   double            m_entry_price;         // price at which the position was opened
   double            m_net_profit;          // realized profit + swap + commission
   double            m_mae;                 // Maximum Adverse Excursion, in price units, always >= 0
   double            m_mfe;                 // Maximum Favorable Excursion, in price units, always >= 0
   double            m_efficiency;          // MFE / (MFE + MAE), meaningful only when m_efficiency_defined
   bool              m_efficiency_defined;  // false when the trade showed no tick-level price movement
   int               m_tick_count;          // number of ticks used to compute m_mae and m_mfe
                     CTradeExcursion(void);
  };

//+-------------------------------------------------------------------+
//| Constructor                                                       |
//| Initializes every field to an explicit, unambiguous default so    |
//| that a record that has not yet been populated by the reader or the|
//| calculator can never be mistaken for a real, computed result.     |
//+-------------------------------------------------------------------+
CTradeExcursion::CTradeExcursion(void)
  {
   m_position_id        = 0;
   m_symbol             = "";
   m_is_long            = true;
   m_entry_time         = 0;
   m_close_time         = 0;
   m_entry_price        = 0.0;
   m_net_profit         = 0.0;
   m_mae                = 0.0;
   m_mfe                = 0.0;
   m_efficiency         = 0.0;
   m_efficiency_defined = false;
   m_tick_count         = 0;
  }

#endif // TRADEEXCURSIONTYPES_MQH
//+------------------------------------------------------------------+