Explorar el Código

新增1220的API

KarsusNeko hace 6 años
commit
2e794083ef

+ 1845 - 0
1220/ManagerAPI/MT4ManagerAPI.h

@@ -0,0 +1,1845 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 4 Manager API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+//|                   DO NOT EDIT THIS FILE!!!                       |
+//+------------------------------------------------------------------+
+// NoStyler
+#pragma once
+//+------------------------------------------------------------------+
+//|                        API Version                               |
+//+------------------------------------------------------------------+
+#define ManAPIProgramVersion  400
+#define ManAPIProgramBuild    1220
+#define ManAPIVersion         MAKELONG(ManAPIProgramBuild,ManAPIProgramVersion)
+//+------------------------------------------------------------------+
+//| MSVS6 Compatibility                                              |
+//+------------------------------------------------------------------+
+#if _MSC_VER <= 1200
+#define __time32_t time_t
+#define __ptr32
+#endif
+//+------------------------------------------------------------------+
+//|                   Server Configurations                          |
+//+------------------------------------------------------------------+
+//| Configuration types                                              |
+//+------------------------------------------------------------------+
+enum
+  {
+   CONFIG_ALL=0,                             // all configurations
+   CONFIG_COMMON,                            // common configuration
+   CONFIG_ACCESS,                            // IP access list configuration
+   CONFIG_SERVERS,                           // data servers
+   CONFIG_TIME,                              // working time configuration
+   CONFIG_HOLIDAYS,                          // holidays configuration
+   CONFIG_SYMBOLS,                           // symbols configuration
+   CONFIG_SYMB_GROUPS,                       // securities configuration
+   CONFIG_GROUPS,                            // groups configuration
+   CONFIG_MANAGERS,                          // manager's rights configuration
+   CONFIG_DATAFEEDS,                         // data feeds configuration
+   CONFIG_BACKUP,                            // backups configuration
+   CONFIG_LIVEUPDATE,                        // LiveUpdate configuration
+   CONFIG_SYNC,                              // synchronization configuration
+   CONFIG_PLUGINS,                           // plugins configuration
+   CONFIG_GATEWAY_ACCOUNTS,                  // gateway accounts
+   CONFIG_GATEWAY_MARKUPS,                   // gateway markups
+   CONFIG_GATEWAY_RULES,                     // gateway rules
+   CONFIG_END=255                            // last (unused)
+  };
+//+------------------------------------------------------------------+
+//| Configuration structures                                         |
+//+------------------------------------------------------------------+
+//| Common configuration                                             |
+//+------------------------------------------------------------------+
+struct ConCommon
+  {
+   char              owner[128];            // servers owner (include version & build)
+   char              name[32];              // server name
+   ULONG             address;               // IP address assigned to the server
+   int               port;                  // port
+   DWORD             timeout;               // sockets timeout
+   int               typeofdemo;            // demo-accounts type (DEMO_DISABLED, DEMO_PROLONG, DEMO_FIXED)
+   int               timeofdemo;            // demo-account living time
+   int               daylightcorrection;    // allow daylight correction
+   char              internal[60];          // reserved
+   int               timezone_real;         // time zone with day light mode
+   int               timezone;              // time zone 0-GMT;-1=GMT-1;1=GMT+1;
+   char              timesync[64];          // time synchronization server address
+   //---
+   int               minclient;             // minimal authorized client version
+   int               minapi;                // minimal authorized client version
+   DWORD             feeder_timeout;        // data feed switch timeout
+   int               keepemails;            // internal mail keep period
+   int               endhour,endminute;     // end of day time-hour & minute
+   //---
+   int               optimization_time;     // optimization start time (minutes)
+   int               optimization_lasttime; // optimization last time
+   int               optimization_counter;  // internal variable
+   int               optimization_unused[8];// reserved for future use
+   //---
+   int               antiflood;             // enable antiflood control
+   int               floodcontrol;          // max. antiflood connections
+   //---
+   int               liveupdate_mode;       // LiveUpdate mode (LIVE_UPDATE_NO,LIVE_UPDATE_ALL,LIVE_UPDATE_NO_SERVER)
+   //---
+   int               lastorder;             // last order's ticket     (read only)
+   int               lastlogin;             // last account's number   (read only)
+   int               lostlogin;             // lost commission's login (read only)
+   //---
+   int               rollovers_mode;        // rollover mode (ROLLOVER_NORMAL,ROLLOVER_REOPEN_BY_CLOSE_PRICE,ROLLOVER_REOPEN_BY_BID)
+   //---
+   char              path_database[256];    // path to databases
+   char              path_history[256];     // path to history bases
+   char              path_log[256];         // path to log
+   //--- overnigths
+   __time32_t        overnight_last_day;    // day of last overnight
+   __time32_t        overnight_last_time;   // time of last overnight
+   __time32_t        overnight_prev_time;   // time of next to last overnight
+   //--- month reports
+   __time32_t        overmonth_last_month;  // month of last report
+   //--- performance base
+   char              adapters[256];         // network adapters list (read-only)
+   ULONG             bind_adresses[8];      // array of avaible IP addresses
+   short             server_version;        // server version
+   short             server_build;          // server build
+   ULONG             web_adresses[8];       // web services access list (comma separated IP addresses)
+   int               statement_mode;        // statement generation time (STATEMENT_END_DAY,STATEMENT_START_DAY)
+   int               monthly_state_mode;    // monthly statement generation day (MONTHLY_STATEMENT_END_MONTH,MONTHLY_STATEMENT_START_MONTH)
+   int               keepticks;             // ticks keep period
+   int               statement_weekend;     // generate statements at weekends
+   __time32_t        last_activate;         // last activation datetime
+   __time32_t        stop_last;             // last stop datetime
+   int               stop_delay;            // last stop delay
+   int               stop_reason;           // last stop reason
+   char              account_url[128];      // account allocation URL
+   int               reserved[16];
+  };
+//--- deno-accounts type
+enum { DEMO_DISABLED, DEMO_PROLONG, DEMO_FIXED };
+//--- rollover mode
+enum { ROLLOVER_NORMAL, ROLLOVER_REOPEN_BY_CLOSE_PRICE, ROLLOVER_REOPEN_BY_BID };
+//--- LiveUpdate mode
+enum { LIVE_UPDATE_NO=0, LIVE_UPDATE_RELEASE=1, LIVE_UPDATE_NO_SERVER=2, LIVE_UPDATE_BETA=3 };
+//--- statement mode
+enum { STATEMENT_END_DAY, STATEMENT_START_DAY };
+//--- monthly statement mode
+enum { MONTHLY_STATEMENT_END_MONTH, MONTHLY_STATEMENT_START_MONTH };
+//--- server stop reason
+enum { STOP_REASON_NONE, STOP_REASON_RESTART, STOP_REASON_SHUTDOWN, STOP_REASON_LIVEUPDATE };
+//+------------------------------------------------------------------+
+//| Access configuration                                             |
+//+------------------------------------------------------------------+
+struct ConAccess
+  {
+   int               action;                // type of action (FW_BLOCK,FW_PERMIT)
+   unsigned long     from,to;               // from, to addresses
+   char              comment[64];           // comment
+   int               reserved[17];          // reserved
+  };
+//--- access action
+enum { FW_BLOCK,FW_PERMIT };
+//+------------------------------------------------------------------+
+//| Data Servers configuration                                       |
+//+------------------------------------------------------------------+
+struct ConDataServer
+  {
+   char              server[64];             // server address (server:ip)
+   ULONG             ip;                     // server IP
+   char              description[64];        // server description
+   int               isproxy;                // can server be proxy?
+   int               priority;               // priority: 0-7 base, 255-idle
+   UINT              loading;                // server loading (UINT_MAX-server does not inform its loading)
+   ULONG             ip_internal;            // internal IP address
+   int               reserved[2];            // reserved
+   ConDataServer* __ptr32 next;                   // internal (not used)
+  };
+//+------------------------------------------------------------------+
+//| Time configuration                                               |
+//+------------------------------------------------------------------+
+struct ConTime
+  {
+   int               days[7][24];           // server's accessebility (7 days-24 hours, 0-denied, 1-allowed)
+   int               dayscontrol;           // internal variable
+   int               reserved[3];           // reserved
+  };
+//+------------------------------------------------------------------+
+//| Backup configuration                                             |
+//+------------------------------------------------------------------+
+struct ConBackup
+  {
+   //---
+   char              fullbackup_path[256];   // path to backup
+   int               fullbackup_period;      // full backup's period-BACKUP_1HOUR, BACKUP_4HOURS, BACKUP_1DAY
+   int               fullbackup_store;       // full backup's store time-BU_STORE_1MONTH, BU_STORE_3MONTHS, BU_STORE_6MONTHS,BU_STORE_1YEAR
+   __time32_t        fullbackup_lasttime;    // full backup's last execution time
+   short             fullbackup_shift;       // full backup timeshift (minutes)
+   //---
+   char              external_path[256];     // path to external processing directory
+   //---
+   int               archive_period;         // period of archive backup-ARC_BACKUP_5MIN, ARC_BACKUP_15MIN, ARC_BACKUP_30MIN, ARC_BACKUP_1HOUR
+   int               archive_store;          // archive backup's store time-ARC_STORE_1WEEK, ARC_STORE_2WEEKS, ARC_STORE_1MONTH, ARC_STORE_3MONTH, ARC_STORE_6MONTH
+   __time32_t        archive_lasttime;       // archive backup's last execution time
+   //---
+   char              export_securities[512]; // comma separated list of exported securities
+   char              export_path[256];       // path to export script
+   int               export_period;          // export period-enumeration EXPORT_1MIN, EXPORT_5MIN, EXPORT_15MIN, EXPORT_30MIN,EXPORT_1HOUR
+   __time32_t        export_lasttime;        // export's last execution time
+   //--- watch dog
+   int               watch_role;             // server role { WATCH_STAND_ALONE, WATCH_MASTER, WATCH_SLAVE }
+   char              watch_password[16];     // slave server password
+   char              watch_opposite[24];     // opposite server IP address and port
+   int               watch_ip;               // opposite server IP
+   //--- 
+   char              archive_shift;          // shift of archive backup time (in minutes)
+   //---
+   char              watch_state;            // watch dog state
+   char              watch_failover;         // watch dog failover mode
+   unsigned char     watch_timeout;          // watch dog timeout
+   int               watch_login;            // watch dog login
+   __time32_t        watch_timestamp;        // watch dog timestamp
+  };
+//--- server role
+enum { WATCH_STAND_ALONE,WATCH_MASTER,WATCH_SLAVE };
+//--- full backup execution periods: 1 hour, 4 hours, 1 day
+enum { BACKUP_1HOUR,BACKUP_4HOURS,BACKUP_1DAY };
+//--- full backup store period: 1 month, 3 months, 6 months, 1 year
+enum { BU_STORE_1MONTH,BU_STORE_3MONTHS,BU_STORE_6MONTHS,BU_STORE_1YEAR };
+//--- arc. backup execution periods: 5 min, 15 min, 30 min, 1 hour
+enum { ARC_BACKUP_DISABLED,ARC_BACKUP_5MIN,ARC_BACKUP_15MIN,ARC_BACKUP_30MIN,ARC_BACKUP_1HOUR };
+//--- arc. backup store period: 1 day, 3 days, 1 week, 2 weeks, 1 month,3 months, 6 months,1 year
+enum { ARC_STORE_1DAY,ARC_STORE_3DAYS,ARC_STORE_1WEEK,ARC_STORE_2WEEKS,ARC_STORE_1MONTH,ARC_STORE_3MONTH,ARC_STORE_6MONTH };
+//--- export execution period: 1 min, 5 min, 15 min, 30 min, 1 hour
+enum { EXPORT_1MIN,EXPORT_5MIN,EXPORT_15MIN,EXPORT_30MIN,EXPORT_1HOUR };
+//--- watchdog state
+enum { WS_DISCONNECTED, WS_SYNCHRONIZING, WS_SYNCHRONIZED };
+//--- watchdog failover mode
+enum { FAILOVER_OFF, FAILOVER_MOST, FAILOVER_FULL };
+//+------------------------------------------------------------------+
+//| Datafeed configuration                                           |
+//+------------------------------------------------------------------+
+struct ConFeeder
+  {
+   char              name[64];              // name
+   char              file[256];             // datafeed filename
+   char              server[64];            // server address
+   char              login[32];             // datafeed login
+   char              pass[32];              // datafeed password
+   char              keywords[256];         // keywords (news filtration)
+   int               enable;                // enable feeder
+   int               mode;                  // datafeed mode-enumeration FEED_QUOTES, FEED_NEWS, FEED_QUOTESNEWS
+   int               timeout;               // max. freeze time (default ~120 sec.)
+   int               timeout_reconnect;     // reconnect timeout before attemps_sleep connect attempts (default ~ 5  sec)
+   int               timeout_sleep;         // reconnect timeout after attemps_sleep connect attempts  (default ~ 60 sec)
+   int               attemps_sleep;         // reconnect count (see timeout_reconnect & timeout_sleep)
+   int               news_langid;           // news language id
+   int               unused[33];            // reserved
+  };
+//--- datafeed modes-receive quotes, receive news, receive quotes and news
+enum { FEED_QUOTES=0, FEED_NEWS=1, FEED_QUOTESNEWS=2 };
+//+------------------------------------------------------------------+
+//| Security group configuration for client group                    |
+//+------------------------------------------------------------------+
+#define MAX_SEC_GROUPS       (32)
+#define MAX_SEC_GROPS_MARGIN (128)
+//---
+struct ConGroupSec
+  {
+   int               show,trade;            // enable show and trade for this group of securites
+   int               execution;             // dealing mode-EXECUTION_MANUAL,EXECUTION_AUTO,EXECUTION_ACTIVITY
+   //--- comission settings
+   double            comm_base;             // standart commission
+   int               comm_type;             // commission type-COMM_TYPE_MONEY,COMM_TYPE_PIPS,COMM_TYPE_PERCENT
+   int               comm_lots;             // commission lots mode-COMMISSION_PER_LOT,COMMISSION_PER_DEAL
+   double            comm_agent;            // agent commission
+   int               comm_agent_type;       // agent commission mode-COMM_TYPE_MONEY, COMM_TYPE_PIPS
+   //---
+   int               spread_diff;           // spread difference in compare with default security spread
+   //---
+   int               lot_min,lot_max;       // allowed minimal and maximal lot values
+   int               lot_step;              // allowed step value (10 lot-1000, 1 lot-100, 0.1 lot-10)
+   int               ie_deviation;          // maximum price deviation in Instant Execution mode
+   int               confirmation;          // use confirmation in Request mode
+   int               trade_rights;          // clients trade rights-bit mask see TRADE_DENY_NONE,TRADE_DENY_CLOSEBY,TRADE_DENY_MUCLOSEBY
+   int               ie_quick_mode;         // do not resend request to the dealer when client uses deviation
+   int               autocloseout_mode;     // auto close-out method { CLOSE_OUT_NONE, CLOSE_OUT_HIHI, CLOSE_OUT_LOLO, CLOSE_OUT_HILO, CLOSE_OUT_LOHI, CLOSE_OUT_LOHI, CLOSE_OUT_FIFO, CLOSE_OUT_LIFO, CLOSE_OUT_INTRDAY_FIFO }
+   double            comm_tax;              // commission taxes
+   int               comm_agent_lots;       // agent commission per lot/per deal { COMMISSION_PER_LOT,COMMISSION_PER_DEAL }
+   int               freemargin_mode;       // "soft" margin check
+   int               reserved[3];           // reserved
+  };
+//+------------------------------------------------------------------+
+//| Special securities configurations for client group               |
+//+------------------------------------------------------------------+
+struct ConGroupMargin
+  {
+   char              symbol[12];            // security
+   double            swap_long,swap_short;  // swap size for long and short positions
+   double            margin_divider;        // margin divider
+   int               reserved[7];
+  };
+//--- dealing mode
+enum { EXECUTION_MANUAL, EXECUTION_AUTO, EXECUTION_ACTIVITY };
+//--- commission type
+enum { COMM_TYPE_MONEY, COMM_TYPE_PIPS, COMM_TYPE_PERCENT };
+//--- comission lots mode
+enum { COMMISSION_PER_LOT, COMMISSION_PER_DEAL };
+//--- clients trade rights
+enum { TRADE_DENY_NONE=0, TRADE_DENY_CLOSEBY=1, TRADE_DENY_MUCLOSEBY=2 };
+//--- auto close-out method
+enum { CLOSE_OUT_NONE, CLOSE_OUT_HIHI, CLOSE_OUT_LOLO, CLOSE_OUT_HILO, CLOSE_OUT_LOHI, CLOSE_OUT_FIFO, CLOSE_OUT_LIFO, CLOSE_OUT_INTRDAY_FIFO };
+//+------------------------------------------------------------------+
+//| Client group configuration                                       |
+//+------------------------------------------------------------------+
+struct ConGroup
+  {
+   //--- common settings
+   char              group[16];                   // group name
+   int               enable;                      // enable group
+   int               timeout;                     // trade confirmation timeout (seconds)
+   int               otp_mode;                    // one-time password mode
+   //--- statements
+   char              company[128];                // company name
+   char              signature[128];              // statements signature
+   char              support_page[128];           // company support page
+   char              smtp_server[64];             // statements SMTP server
+   char              smtp_login[32];              // statements SMTP login
+   char              smtp_password[32];           // statements SMTP password
+   char              support_email[64];           // support email
+   char              templates[32];               // path to directory with custom templates
+   int               copies;                      // copy statements on support email
+   int               reports;                     // enable statements
+   //--- default settings
+   int               default_leverage;            // default leverage (user don't specify leverage himself)
+   double            default_deposit;             // default deposit  (user don't specify balance  himself)
+   //--- securities
+   int               maxsecurities;               // maximum simultaneous securities
+   ConGroupSec       secgroups[MAX_SEC_GROUPS];   // security group settings
+   ConGroupMargin    secmargins[MAX_SEC_GROPS_MARGIN]; // special securities settings
+   int               secmargins_total;            // count of special securities settings
+   //--- margin & interest
+   char              currency[12];                // deposit currency
+   double            credit;                      // virtual credit
+   int               margin_call;                 // margin call level (percents)
+   int               margin_mode;                 // margin mode-MARGIN_DONT_USE,MARGIN_USE_ALL,MARGIN_USE_PROFIT,MARGIN_USE_LOSS
+   int               margin_stopout;              // stop out level
+   double            interestrate;                // annual interest rate (percents)
+   int               use_swap;                    // use rollovers & interestrate
+   //--- rights
+   int               news;                        // news mode
+   int               rights;                      // rights bit mask-ALLOW_FLAG_EMAIL
+   int               check_ie_prices;             // check IE prices on requests
+   int               maxpositions;                // maximum orders and open positions
+   int               close_reopen;                // partial close mode (if !=0 original position will be fully closed and remain position will be fully reopened)
+   int               hedge_prohibited;            // hedge prohibition flag
+   int               close_fifo;                  // fifo rule 
+   int               hedge_largeleg;              // use large leg margin for hedged positions
+   int               unused_rights[2];            // reserved
+
+   char              securities_hash[16];         // internal data
+   //---
+   int               margin_type;                 // margin controlling type { MARGIN_TYPE_PERCENT,  MARGIN_TYPE_CURRENCY }
+   //--- archives
+   int               archive_period;              // inactivity period after which account moves to archive base (in days)
+   int               archive_max_balance;         // maxumum balance of accounts to move in archive base
+   //---
+   int               stopout_skip_hedged;         // skip fully hedged accounts when checking for stopout
+   int               archive_pending_period;      // pendings clean period
+   //--- allowed news languages
+   UINT              news_languages[8];           // LANGID array
+   UINT              news_languages_total;        // news languages total
+   //--- reserved
+   int               reserved[17];
+  };
+//--- margin calculation mode
+enum { MARGIN_MODE_DONT_USE,MARGIN_MODE_USE_ALL,MARGIN_MODE_USE_PROFIT,MARGIN_MODE_USE_LOSS };
+//--- margin controlling type
+enum { MARGIN_TYPE_PERCENT, MARGIN_TYPE_CURRENCY };
+//--- news mode-no news, only topics, full news (topic+body)
+enum { NEWS_NO, NEWS_TOPICS, NEWS_FULL  };
+//--- group rights
+enum 
+  { 
+   ALLOW_FLAG_EMAIL           =1,
+   ALLOW_FLAG_TRAILING        =2,
+   ALLOW_FLAG_ADVISOR         =4,
+   ALLOW_FLAG_EXPIRATION      =8,
+   ALLOW_FLAG_SIGNALS_ALL     =16,
+   ALLOW_FLAG_SIGNALS_OWN     =32,
+   ALLOW_FLAG_RISK_WARNING    =64,
+   ALLOW_FLAG_FORCED_OTP_USAGE=128,
+  };
+//--- group one-time password mode
+enum
+  {
+   OTP_MODE_DISABLED       =0,
+   OTP_MODE_TOTP_SHA256    =1,
+  };
+//+------------------------------------------------------------------+
+//| Hollidays configuration                                          |
+//+------------------------------------------------------------------+
+struct ConHoliday
+  {
+   int               year;                        // year
+   int               month;                       // month
+   int               day;                         // day
+   int               from,to;                     // work time-from & to (minutes)
+   char              symbol[32];                  // security name or symbol's group name or "All"
+   char              description[128];            // description
+   int               enable;                      // enable
+   int               reserved[13];                // reserved
+   ConHoliday * __ptr32 next;                     // internal data
+  };
+//+------------------------------------------------------------------+
+//| LiveUpdate configuration                                         |
+//+------------------------------------------------------------------+
+#define LIVE_FILES_MAX (128)
+//---
+struct LiveInfoFile
+  {
+   char              file[256];                   // file name
+   int               size;                        // file size
+   char              hash[36];                    // file hash
+   int               reserved[10];                // reserved
+  };
+//---
+struct ConLiveUpdate
+  {
+   char              company[128];                // company
+   char              path[256];                   // path to LiveUpdate
+   int               version;                     // version
+   int               build;                       // build
+   int               maxconnect;                  // max. simultaneous connections
+   int               connections;                 // current connections (read only)
+   int               type;                        // type LIVE_UPDATE_*
+   int               enable;                      // enable
+   int               totalfiles;                  // total files count
+   LiveInfoFile      files[LIVE_FILES_MAX];       // files' configurations
+   int               reserved[16];                // reserved
+   ConLiveUpdate * __ptr32 next;                        // internal data
+  };
+//--- LiveUpdate type
+enum
+  {
+   LIVE_UPDATE_CLIENT,
+   LIVE_UPDATE_MANAGER,
+   LIVE_UPDATE_ADMIN,
+   LIVE_UPDATE_DATACENTER,
+   LIVE_UPDATE_CLIENT_PPC2002,
+   LIVE_UPDATE_CLIENT_PPC2003,
+   LIVE_UPDATE_MULTI,
+   LIVE_UPDATE_WD,
+   LIVE_UPDATE_CLIENT_PHONE,
+   LIVE_UPDATE_LAST 
+  };
+//+------------------------------------------------------------------+
+//| Manager rights for security groups                               |
+//+------------------------------------------------------------------+
+struct ConManagerSec
+  {
+   int               internal;                    // internal data
+   int               enable;                      // enable
+   int               minimum_lots;                // min. lots
+   int               maximum_lots;                // max. lots
+   int               unused[16];                  // reserved
+  };
+//+------------------------------------------------------------------+
+//| Manager configuration                                            |
+//+------------------------------------------------------------------+
+struct ConManager
+  {
+   int               login;                       // login
+   //--- rights
+   int               manager;                     // right to add & change client records
+   int               money;                       // right to balance & credit management
+   int               online;                      // right to see online users
+   int               riskman;                     // right to use analyzer
+   int               broker;                      // right to deal
+   int               admin;                       // right to server administration
+   int               logs;                        // right to see logs
+   int               reports;                     // right to see reports
+   int               trades;                      // right to add/modify/delete trades
+   int               market_watch;                // right to change spread, spread balance, stop levels, execution mode and send quotes
+   int               email;                       // right to send internal mail
+   int               user_details;                // right to see clients private data-name,country,address,phone,email etc.
+   int               see_trades;                  // right to see trades
+   int               news;                        // right to send news
+   int               plugins;                     // right to configure plugins
+   int               server_reports;              // right to receive server reports
+   int               techsupport;                 // right to access to technical support page
+   int               market;                      // right to access server applications market
+   int               notifications;               // right to push notifications
+   int               unused[9];
+   //--- IP filtration
+   int               ipfilter;                    // enable IP control
+   unsigned long     ip_from,ip_to;               // range of allowed IPs
+   //---
+   char              mailbox[64];                 // name of mailbox for internal mail
+   char              groups[1024];                // comma separated list of managed groups (allowed '*' wildcard)
+   ConManagerSec     secgroups[MAX_SEC_GROUPS];   // manager rights for security groups
+   DWORD             exp_time;                    // internal data
+   char              name[32];                    // manager name (read only)
+   int               info_depth;                  // maximum available data (in days) 
+   //---
+   int               reserved[22];
+  };
+//+------------------------------------------------------------------+
+//| Symbol configurations                                            |
+//+------------------------------------------------------------------+
+//| Symbol sessions configurations                                   |
+//+------------------------------------------------------------------+
+struct ConSession
+  {
+   short             open_hour,open_min;          // session open  time: hour & minute
+   short             close_hour,close_min;        // session close time: hour & minute
+   int               open,close;                  // internal data
+   short             align[7];                    // internal data
+  };
+//---
+struct ConSessions
+  {
+   //---
+   ConSession        quote[3];                    // quote sessions
+   ConSession        trade[3];                    // trade sessions
+   //---
+   int               quote_overnight;             // internal data
+   int               trade_overnight;             // internal data
+   int               reserved[2];                 // reserved
+  };
+//+------------------------------------------------------------------+
+//| Symbol configuration                                             |
+//+------------------------------------------------------------------+
+#define MAX_SYMBOLS 1024
+//---
+struct ConSymbol
+  {
+   //--- common settings
+   char              symbol[12];                  // name
+   char              description[64];             // description
+   char              source[12];                  // synonym
+   char              currency[12];                // currency
+   int               type;                        // security group (see ConSymbolGroup)
+   int               digits;                      // security precision
+   int               trade;                       // trade mode
+   //--- external settings
+   COLORREF          background_color;            // background color
+   int               count;                       // symbols index
+   int               count_original;              // symbols index in market watch
+   int               external_unused[7];
+   //--- sessions
+   int               realtime;                    // allow real time quotes
+   __time32_t        starting;                    // trades starting date (UNIX time)
+   __time32_t        expiration;                  // trades end date      (UNIX time)
+   ConSessions       sessions[7];                 // quote & trade sessions
+   //--- profits
+   int               profit_mode;                 // profit calculation mode
+   int               profit_reserved;             // reserved
+   //--- filtration
+   int               filter;                      // filter value
+   int               filter_counter;              // filtration parameter
+   double            filter_limit;                // max. permissible deviation from last quote (percents)
+   int               filter_smoothing;            // smoothing
+   float             filter_reserved;             // reserved
+   int               logging;                     // enable to log quotes
+   //--- spread & swaps
+   int               spread;                      // spread
+   int               spread_balance;              // spread balance
+   int               exemode;                     // execution mode
+   int               swap_enable;                 // enable swaps
+   int               swap_type;                   // swap type
+   double            swap_long,swap_short;        // swaps values for long & short postions
+   int               swap_rollover3days;          // triple rollover day-0-Monday,1-Tuesday...4-Friday
+   double            contract_size;               // contract size
+   double            tick_value;                  // one tick value
+   double            tick_size;                   // one tick size
+   int               stops_level;                 // stops deviation value
+   int               gtc_pendings;                // GTC mode { ORDERS_DAILY, ORDERS_GTC, ORDERS_DAILY_NO_STOPS }
+   //--- margin calculation
+   int               margin_mode;                 // margin calculation mode
+   double            margin_initial;              // initial margin
+   double            margin_maintenance;          // margin maintenance
+   double            margin_hedged;               // hedged margin
+   double            margin_divider;              // margin divider
+   //--- calclulated variables (internal data)
+   double            point;                       // point size-(1/(10^digits)
+   double            multiply;                    // multiply 10^digits
+   double            bid_tickvalue;               // tickvalue for bid
+   double            ask_tickvalue;               // tickvalue for ask
+   //---
+   int               long_only;                   // allow only BUY positions
+   int               instant_max_volume;          // max. volume for Instant Execution
+   //---
+   char              margin_currency[12];         // currency of margin requirments
+   int               freeze_level;                // modification freeze level
+   int               margin_hedged_strong;        // strong hedged margin mode
+   __time32_t        value_date;                  // value date
+   int               quotes_delay;                // quotes delay after session start
+   int               swap_openprice;         	  // use open price at swaps calculation in SWAP_BY_INTEREST mode
+   int               swap_variation_margin;       // charge variation margin on rollover
+   //---
+   int               unused[21];             	  // reserved
+
+  };
+//+------------------------------------------------------------------+
+//| Symbols enumeration                                              |
+//+------------------------------------------------------------------+
+//--- symbol execution mode
+enum { EXE_REQUEST,EXE_INSTANT,EXE_MARKET };
+//--- trade mode
+enum { TRADE_NO,TRADE_CLOSE,TRADE_FULL };
+//--- swap type
+enum { SWAP_BY_POINTS,SWAP_BY_DOLLARS,SWAP_BY_INTEREST,SWAP_BY_MARGIN_CURRENCY };
+//--- profit calculation mode
+enum { PROFIT_CALC_FOREX,PROFIT_CALC_CFD,PROFIT_CALC_FUTURES };
+//--- margin calculation mode
+enum { MARGIN_CALC_FOREX,MARGIN_CALC_CFD,MARGIN_CALC_FUTURES,MARGIN_CALC_CFDINDEX,MARGIN_CALC_CFDLEVERAGE };
+//--- GTC mode
+enum { ORDERS_DAILY, ORDERS_GTC, ORDERS_DAILY_NO_STOPS };
+//+------------------------------------------------------------------+
+//| Symbol groups                                                    |
+//+------------------------------------------------------------------+
+#define MAX_SEC_GROUP (32)
+struct ConSymbolGroup
+  {
+   char              name[16];                     // group name
+   char              description[64];              // group description
+  };
+//+------------------------------------------------------------------+
+//| Synchronization configuration                                    |
+//+------------------------------------------------------------------+
+struct ConSync
+  {
+   char              server[64];                   // name (address
+   int               unusedport;                   // port
+   char              login[32];                    // for future use-login
+   char              password[32];                 // for future use=password
+   int               enable;                       // enable sychronization
+   int               mode;                         // synchronization mode: HB_ADD,HB_UPDATE,HB_INSERT
+   __time32_t        from,to;                      // synchronization range (<0-whole chart)
+   char              securities[1024];             // symbols list
+   int               timecorrection;               // time correction in minutes
+   int               reserved[13];                 // reserved
+   ConSync * __ptr32 next;                         // internal (do not use)
+  };
+//--- synchronization mode
+enum { HB_ADD,HB_UPDATE,HB_INSERT,HB_DELETE,HB_LAST };
+//+------------------------------------------------------------------+
+//| Plugin configuration                                             |
+//+------------------------------------------------------------------+
+//| Plugin description                                               |
+//+------------------------------------------------------------------+
+struct PluginInfo
+  {
+   char              name[128];                    // plugin name
+   unsigned int      version;                      // plugin version
+   char              copyright[128];               // plugin copyright
+   int               reserved[32];                 // reserved
+  };
+//+------------------------------------------------------------------+
+//| Plugin configuration parameter                                   |
+//+------------------------------------------------------------------+
+struct PluginCfg
+  {
+   char              name[32];                     // parameter name
+   char              value[128];                   // parameter value
+   int               reserved[16];                 // reserved
+  };
+//+------------------------------------------------------------------+
+//| Plugin configuration                                             |
+//+------------------------------------------------------------------+
+struct ConPlugin
+  {
+   char              file[256];                    // plugin file name
+   PluginInfo        info;                         // plugin description
+   int               enabled;                      // plugin enabled/disabled
+   int               configurable;                 // is plugin configurable
+   int               manager_access;               // plugin can be accessed from manager terminal
+   int               reserved[62];                 // reserved
+  };
+//--- plugin with parameters
+struct ConPluginParam
+  {
+   ConPlugin         plugin;                       // plugin configuration
+   PluginCfg* __ptr32 params;                      // plugin parameters
+   int               total;                        // total plugin parameters
+  };
+//+------------------------------------------------------------------+
+//| Gateway configuration                                            |
+//+------------------------------------------------------------------+
+//+------------------------------------------------------------------+
+//| Gateway account configuration                                    |
+//+------------------------------------------------------------------+
+struct ConGatewayAccount
+  {
+   int               enable;                       // enable flag 0 - disabled, 1 - enabled
+   char              name[64];                     // public name
+   int               id;                           // internal id
+   int               type;                         // type (obsolete)
+   int               login;                        // STP MT4 login
+   char              address[64];                  // MT4 server address
+   char              password[64];                 // STP MT4 password
+   int               notify_logins[8];             // list of logins for internal email notification
+   int               flags;                        // flag fields
+   int               reserved[23];                 // reserved
+  };
+//--- gateway account flags
+enum EnGatewayAccountFlags { GATEWAY_FLAG_NONE=0, GATEWAY_FLAG_QUOTES=1 };
+//+------------------------------------------------------------------+
+//| Gateway markup configuration                                     |
+//+------------------------------------------------------------------+
+struct ConGatewayMarkup
+  {
+   int               enable;                       // enable flag 0 - disabled, 1 - enabled
+   char              source[128];                  // source symbol\symbols mask\symbols group name
+   char              symbol[12];                   // local symbol name
+   char              account_name[64];             // account name (obsolete)
+   int               account_id;                   // account internal id (obsolete)
+   int               bid_markup;                   // bid markup in pips
+   int               ask_markup;                   // ask markup in pips
+   int               reserved[16];                 // reserved
+  };
+//+------------------------------------------------------------------+
+//| Gateway rules configuration                                     |
+//+------------------------------------------------------------------+
+struct ConGatewayRule
+  {
+   int               enable;                       // enable flag 0 - disabled, 1 - enabled
+   char              name[64];                     // public name
+   char              request_symbol[128];          // symbol\symbols mask\symbols group name
+   char              request_group[128];           // group name or group mask
+   int               request_reserved[32];         // reserved
+   char              exe_account_name[64];         // account name
+   int               exe_account_id;               // account internal id
+   int               exe_max_deviation;            // max. devation
+   int               exe_max_profit_slippage;      // max profit slippage in pips
+   int               exe_max_profit_slippage_lots; // max profit slippage volume in lots
+   int               exe_max_losing_slippage;      // max losing slippage in pips
+   int               exe_max_losing_slippage_lots; // max losing slippage volume in lots
+   int               exe_account_pos;              // account current position
+   int               exe_volume_percent;           // coverage percentage
+   int               exe_reserved[26];             // reserved
+  };
+//+------------------------------------------------------------------+
+//|                           Result codes                           |
+//+------------------------------------------------------------------+
+enum
+  {
+   //--- common errors
+   RET_OK                =0,        // all OK
+   RET_OK_NONE,                     // all OK-no operation
+   RET_ERROR,                       // general error
+   RET_INVALID_DATA,                // invalid data
+   RET_TECH_PROBLEM,                // server technical problem
+   RET_OLD_VERSION,                 // old client terminal
+   RET_NO_CONNECT,                  // no connection
+   RET_NOT_ENOUGH_RIGHTS,           // no enough rights
+   RET_TOO_FREQUENT,                // too frequently access to server
+   RET_MALFUNCTION,                 // mulfunctional operation
+   RET_GENERATE_KEY,                // need to send public key
+   RET_SECURITY_SESSION,            // security session start
+   //--- account status
+   RET_ACCOUNT_DISABLED  =64,       // account blocked
+   RET_BAD_ACCOUNT_INFO,            // bad account info
+   RET_PUBLIC_KEY_MISSING,          // no key
+   //--- trade
+   RET_TRADE_TIMEOUT     =128,      // trade transatcion timeou expired
+   RET_TRADE_BAD_PRICES,            // order has wrong prices
+   RET_TRADE_BAD_STOPS,             // wrong stops level
+   RET_TRADE_BAD_VOLUME,            // wrong lot size
+   RET_TRADE_MARKET_CLOSED,         // market closed
+   RET_TRADE_DISABLE,               // trade disabled
+   RET_TRADE_NO_MONEY,              // no enough money for order execution
+   RET_TRADE_PRICE_CHANGED,         // price changed
+   RET_TRADE_OFFQUOTES,             // no quotes
+   RET_TRADE_BROKER_BUSY,           // broker is busy
+   RET_TRADE_REQUOTE,               // requote
+   RET_TRADE_ORDER_LOCKED,          // order is proceed by dealer and cannot be changed
+   RET_TRADE_LONG_ONLY,             // allowed only BUY orders
+   RET_TRADE_TOO_MANY_REQ,          // too many requests from one client
+   //--- order status notification
+   RET_TRADE_ACCEPTED,              // trade request accepted by server and placed in request queue
+   RET_TRADE_PROCESS,               // trade request accepted by dealerd
+   RET_TRADE_USER_CANCEL,           // trade request canceled by client
+   //--- additional return codes
+   RET_TRADE_MODIFY_DENIED,         // trade modification denied
+   RET_TRADE_CONTEXT_BUSY,          // trade context is busy (used in client terminal)
+   RET_TRADE_EXPIRATION_DENIED,     // using expiration date denied
+   RET_TRADE_TOO_MANY_ORDERS,       // too many orders
+   RET_TRADE_HEDGE_PROHIBITED,      // hedge is prohibited
+   RET_TRADE_PROHIBITED_BY_FIFO     // prohibited by fifo rule
+  };
+//+------------------------------------------------------------------+
+//| Pumping mode flags                                               |
+//+------------------------------------------------------------------+
+enum
+  {
+   //--- user flags
+   CLIENT_FLAGS_HIDETICKS   =1,     // do not send ticks
+   CLIENT_FLAGS_HIDENEWS    =2,     // do not send news
+   CLIENT_FLAGS_HIDEMAIL    =4,     // do not send mails
+   CLIENT_FLAGS_SENDFULLNEWS=8,     // send news body with news header in pumping mode
+   CLIENT_FLAGS_RESERVED    =16,    // reserved
+   //--- manager flags
+   CLIENT_FLAGS_HIDEONLINE  =32,    // do not send online users table
+   CLIENT_FLAGS_HIDEUSERS   =64     // do not send users table
+  };
+//+------------------------------------------------------------------+
+//|  Server datafeed descritopn                                      |
+//+------------------------------------------------------------------+
+struct FeedDescription
+  {
+   int               version;                   // data source version
+   char              name[128];                 // data source name
+   char              copyright[128];            // copyright string
+   char              web[128];                  // data source web
+   char              email[128];                // data source email
+   char              server[128];               // feeder server
+   char              username[32];              // default feeder name
+   char              userpass[32];              // default feeder password
+   int               modes;                     // feeder modes (enum FeederModes)
+   char              description[512];          // feeder description
+   char              module[32];                // datafeed name in license
+   int               reserved[54];              // reserved
+  };
+//--- feeder modes
+enum FeederModes
+  {
+   modeOnlyQuotes    =0, // only quotes feeder
+   modeOnlyNews      =1, // only news feeder
+   modeQuotesAndNews =2, // quotes and news feeder
+   modeQuotesOrNews  =3  // quotes or news feeder
+  };
+//--- server datafeed
+struct ServerFeed
+  {
+   char              file[256];                 // feeder file name
+   FeedDescription   feed;                      // feeder description
+  };
+//+------------------------------------------------------------------+
+//|                           Charts                                 |
+//+------------------------------------------------------------------+
+//| Request chart history struct                                     |
+//+------------------------------------------------------------------+
+struct ChartInfo
+  {
+   char              symbol[12];          // symbol
+   int               period;              // period (PERIOD_*)
+   __time32_t        start;               // start of chart block
+   __time32_t        end;                 // end of chart block
+   __time32_t        timesign;            // timestamp of existing chart base
+   int               mode;                // request mode
+  };
+//--- chart period
+enum { PERIOD_M1=1,  PERIOD_M5=5,   PERIOD_M15=15,  PERIOD_M30=30,
+       PERIOD_H1=60, PERIOD_H4=240, PERIOD_D1=1440, PERIOD_W1=10080,
+       PERIOD_MN1=43200 };
+//--- request mode
+enum { CHART_RANGE_IN,CHART_RANGE_OUT,CHART_RANGE_LAST };
+//+------------------------------------------------------------------+
+//| Rate the in chart base                                           |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct RateInfoOld
+  {
+   __time32_t        ctm;                    // rate time
+   int               open;                   // open price: 11987=119.87
+   short             high,low,close;         // high,low,close shift from open
+   double            vol;                    // volume
+  };
+struct RateInfo
+  {
+   __time32_t        ctm;                    // rate time
+   int               open;                   // open price: 11987=119.87
+   int               high,low,close;         // high,low,close shift from open
+   double            vol;                    // volume
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Tick record in base                                              |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct TickRecord
+  {
+   __time32_t        ctm;                    // tick time
+   double            bid,ask;                // bid, ask
+   int               datafeed;               // index if datafeed
+   char              flags;                  // TICK_FLAG_* flags
+  };
+#pragma pack(pop)
+//---
+enum { TICK_FLAG_RAW=1, TICK_FLAG_NORMAL=2,TICK_FLAG_ALL=TICK_FLAG_RAW+TICK_FLAG_NORMAL };
+//+------------------------------------------------------------------+
+//| Tick request                                                     |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct TickRequest
+  {
+   char              symbol[12];             // symbol
+   __time32_t        from;                   // start of period
+   __time32_t        to;                     // end of period
+   char              flags;                  // TICK_FLAG_* flags
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Performance information                                          |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct PerformanceInfo
+  {
+   __time32_t        ctm;
+   short             users;                  // online users
+   short             cpu;                    // processor loading (%)
+   int               freemem;                // free memory (Kb)
+   int               network;                // network activity (Kb/s)
+   int               sockets;                // all open sockets in system
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Backup file information                                          |
+//+------------------------------------------------------------------+
+struct BackupInfo
+  {
+   char              file[256];              // file name
+   int               size;                   // file size
+   __time32_t        time;                   // file time
+   int               reserved[6];            // reserved
+  };
+//--- backup mode
+enum
+  {
+   BACKUPS_ALL,             // all backup
+   BACKUPS_PERIODICAL,      // periodical backups
+   BACKUPS_STARTUP,         // backups on startup
+   BACKUPS_DELETE           // backups on delete
+  };
+//+------------------------------------------------------------------+
+//|                        Databases                                 |
+//+------------------------------------------------------------------+
+//| Transaction types                                                |
+//+------------------------------------------------------------------+
+enum { TRANS_ADD, TRANS_DELETE, TRANS_UPDATE, TRANS_CHANGE_GRP };
+//+------------------------------------------------------------------+
+//| User Record                                                      |
+//+------------------------------------------------------------------+
+#define PUBLIC_KEY_SIZE    272                  // RSA key size // (((1024+64)/32)*4*2)
+#define USER_COLOR_NONE    (0xFF000000)         // default user color
+//---
+struct UserRecord
+  {
+   //--- common settings
+   int               login;                      // login
+   char              group[16];                  // group
+   char              password[16];               // password
+   //--- access flags
+   int               enable;                     // enable
+   int               enable_change_password;     // allow to change password
+   int               enable_read_only;           // allow to open/positions (TRUE-may not trade)
+   int               enable_otp;                 // allow to use one-time password
+   int               enable_reserved[2];         // for future use
+   //---
+   char              password_investor[16];      // read-only mode password
+   char              password_phone[32];         // phone password
+   char              name[128];                  // name
+   char              country[32];                // country
+   char              city[32];                   // city
+   char              state[32];                  // state
+   char              zipcode[16];                // zipcode
+   char              address[96];                // address
+   char              lead_source[32];            // lead source
+   char              phone[32];                  // phone
+   char              email[48];                  // email
+   char              comment[64];                // comment
+   char              id[32];                     // SSN (IRD)
+   char              status[16];                 // status
+   __time32_t        regdate;                    // registration date
+   __time32_t        lastdate;                   // last coonection time
+   //--- trade settings
+   int               leverage;                   // leverage
+   int               agent_account;              // agent account
+   __time32_t        timestamp;                  // timestamp
+   int               last_ip;                    // last visit ip
+   double            balance;                    // balance
+   double            prevmonthbalance;           // previous month balance
+   double            prevbalance;                // previous day balance
+   double            credit;                     // credit
+   double            interestrate;               // accumulated interest rate
+   double            taxes;                      // taxes
+   double            prevmonthequity;            // previous month equity
+   double            prevequity;                 // previous day equity
+   double            reserved2[2];               // for future use
+   //---
+   char              otp_secret[32];             // one-time password secret
+   char              secure_reserved[240];       // secure data reserved
+   int               send_reports;               // enable send reports by email
+   unsigned int      mqid;                       // MQ client identificator
+   COLORREF          user_color;                 // color got to client (used by MT Manager)
+   //---
+   char              unused[40];                 // for future use
+   char              api_data[16];               // for API usage
+  };
+//+------------------------------------------------------------------+
+//| Users group operation                                            |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct GroupCommandInfo
+  {
+   int               len;              // length of users list
+   char              command;          // group coommand
+   char              newgroup[16];     // new group
+   int               leverage;         // new leverage
+   int               reserved[8];      // reserved
+  };
+#pragma pack(pop)
+//--- group commands
+enum { GROUP_DELETE,GROUP_ENABLE,GROUP_DISABLE,GROUP_LEVERAGE,GROUP_SETGROUP };
+//+------------------------------------------------------------------+
+//| Online user description                                          |
+//+------------------------------------------------------------------+
+struct OnlineRecord
+  {
+   int               counter;       // connections counter
+   int               reserved;      // reserved
+   int               login;         // user login
+   UINT              ip;            // connection ip address
+   char              group[16];     // user group
+  };
+//+------------------------------------------------------------------+
+//| Trade Record                                                     |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct TradeRecord
+  {
+   int               order;            // order ticket
+   int               login;            // owner's login
+   char              symbol[12];       // security
+   int               digits;           // security precision
+   int               cmd;              // trade command
+   int               volume;           // volume
+   //---
+   __time32_t        open_time;        // open time
+   int               state;            // reserved
+   double            open_price;       // open price
+   double            sl,tp;            // stop loss & take profit
+   __time32_t        close_time;       // close time
+   int               gw_volume;        // gateway order volume
+   __time32_t        expiration;       // pending order's expiration time
+   char              reason;           // trade reason
+   char              conv_reserv[3];   // reserved fields
+   double            conv_rates[2];    // convertation rates from profit currency to group deposit currency
+                                       // (first element-for open time, second element-for close time)
+   double            commission;       // commission
+   double            commission_agent; // agent commission
+   double            storage;          // order swaps
+   double            close_price;      // close price
+   double            profit;           // profit
+   double            taxes;            // taxes
+   int               magic;            // special value used by client experts
+   char              comment[32];      // comment
+   int               gw_order;         // gateway order ticket
+   int               activation;       // used by MT Manager
+   short             gw_open_price;    // gateway order price deviation (pips) from order open price
+   short             gw_close_price;   // gateway order price deviation (pips) from order close price
+   double            margin_rate;      // margin convertation rate (rate of convertation from margin currency to deposit one)
+   __time32_t        timestamp;        // timestamp
+   int               api_data[4];      // for api usage
+   TradeRecord *__ptr32 next;          // internal data
+  };
+#pragma pack(pop)
+//--- trade commands
+enum { OP_BUY=0,OP_SELL,OP_BUY_LIMIT,OP_SELL_LIMIT,OP_BUY_STOP,OP_SELL_STOP,OP_BALANCE,OP_CREDIT };
+//--- trade record state
+enum { TS_OPEN_NORMAL, TS_OPEN_REMAND, TS_OPEN_RESTORED, TS_CLOSED_NORMAL, TS_CLOSED_PART, TS_CLOSED_BY, TS_DELETED };
+//--- trade record reasons
+enum
+  {
+   TR_REASON_CLIENT =0,  // client terminal
+   TR_REASON_EXPERT =1,  // expert
+   TR_REASON_DEALER =2,  // dealer
+   TR_REASON_SIGNAL =3,  // signal
+   TR_REASON_GATEWAY=4,  // gateway
+   TR_REASON_MOBILE =5,  // mobile terminal
+   TR_REASON_WEB    =6,  // Web terminal
+   TR_REASON_API    =7,  // API
+  };
+//--- activation types
+//--- *_ROLLBACK=current price roll back from activation price level
+enum
+  {
+   //--- no activation
+   ACTIVATION_NONE=0,
+   //--- stoploss, takeprofit, pendings
+   ACTIVATION_SL,ACTIVATION_TP,ACTIVATION_PENDING,
+   //--- stopout
+   ACTIVATION_STOPOUT,
+   //--- rollbacks
+   ACTIVATION_SL_ROLLBACK     =-ACTIVATION_SL,
+   ACTIVATION_TP_ROLLBACK     =-ACTIVATION_TP,
+   ACTIVATION_PENDING_ROLLBACK=-ACTIVATION_PENDING,
+   ACTIVATION_STOPOUT_ROLLBACK=-ACTIVATION_STOPOUT
+  };
+//+------------------------------------------------------------------+
+//| TradeRecord restoring from backup result                         |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct TradeRestoreResult
+  {
+   int               order;            // order
+   UCHAR             res;              // RET_OK    - order restored
+                                       // RET_ERROR - error restoring order
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Trade transaction                                                |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct TradeTransInfo
+  {
+   UCHAR             type;             // trade transaction type
+   char              flags;            // flags
+   short             cmd;              // trade command
+   int               order,orderby;    // order, order by
+   char              symbol[12];       // trade symbol
+   int               volume;           // trade volume
+   double            price;            // trade price
+   double            sl,tp;            // stoploss, takeprofit
+   int               ie_deviation;     // deviation on IE
+   char              comment[32];      // comment
+   __time32_t        expiration;       // pending order expiration time
+   int               crc;              // crc
+  };
+#pragma pack(pop)
+//--- trade transaction types
+enum
+  {
+   //---
+   TT_PRICES_GET,                      // prices requets
+   TT_PRICES_REQUOTE,                  // requote
+   //--- client trade transaction
+   TT_ORDER_IE_OPEN=64,                // open order (Instant Execution)
+   TT_ORDER_REQ_OPEN,                  // open order (Request Execution)
+   TT_ORDER_MK_OPEN,                   // open order (Market Execution)
+   TT_ORDER_PENDING_OPEN,              // open pending order
+   //---
+   TT_ORDER_IE_CLOSE,                  // close order (Instant Execution)
+   TT_ORDER_REQ_CLOSE,                 // close order (Request Execution)
+   TT_ORDER_MK_CLOSE,                  // close order (Market Execution)
+   //---
+   TT_ORDER_MODIFY,                    // modify pending order
+   TT_ORDER_DELETE,                    // delete pending order
+   TT_ORDER_CLOSE_BY,                  // close order by order
+   TT_ORDER_CLOSE_ALL,                 // close all orders by symbol
+   //--- broker trade transactions
+   TT_BR_ORDER_OPEN,                   // open order
+   TT_BR_ORDER_CLOSE,                  // close order
+   TT_BR_ORDER_DELETE,                 // delete order (ANY OPEN ORDER!!!)
+   TT_BR_ORDER_CLOSE_BY,               // close order by order
+   TT_BR_ORDER_CLOSE_ALL,              // close all orders by symbol
+   TT_BR_ORDER_MODIFY,                 // modify open price, stoploss, takeprofit etc. of order
+   TT_BR_ORDER_ACTIVATE,               // activate pending order
+   TT_BR_ORDER_COMMENT,                // modify comment of order
+   TT_BR_BALANCE                       // balance/credit
+  };
+//--- trade request flags
+enum EnReqFlags
+  {
+   TT_FLAG_NONE   =0x00000000,         // flags none
+   TT_FLAG_SIGNAL =0x00000001,         // placed by signal
+   TT_FLAG_EXPERT =0x00000002,         // placed by expert
+   TT_FLAG_GATEWAY=0x00000004,         // placed by gateway
+   TT_FLAG_MOBILE =0x00000008,         // placed by mobile terminal
+   TT_FLAG_WEB    =0x00000010,         // placed by web terminal
+   TT_FLAG_API    =0x00000020,         // placed by api
+  };
+//+------------------------------------------------------------------+
+//| Margin level of the user                                         |
+//+------------------------------------------------------------------+
+struct MarginLevel
+  {
+   int               login;            // user login
+   char              group[16];        // user group
+   int               leverage;         // user leverage
+   int               updated;          // (internal)
+   double            balance;          // balance+credit
+   double            equity;           // equity
+   int               volume;           // lots
+   double            margin;           // margin requirements
+   double            margin_free;      // free margin
+   double            margin_level;     // margin level
+   int               margin_type;      // margin controlling type (percent/currency)
+   int               level_type;       // level type(ok/margincall/stopout)
+  };
+//--- margin level type
+enum { MARGINLEVEL_OK=0, MARGINLEVEL_MARGINCALL, MARGINLEVEL_STOPOUT };
+//+------------------------------------------------------------------+
+//| Trade request                                                    |
+//+------------------------------------------------------------------+
+struct RequestInfo
+  {
+   //--- general props
+   int               id;                  // request id
+   char              status;              // request status
+   DWORD             time;                // request time
+   int               manager;             // manager processing request (if any)
+   //--- user info
+   int               login;               // user login
+   char              group[16];           // user group
+   double            balance;             // user balance
+   double            credit;              // user credit
+   //--- processing trade transaction
+   double            prices[2];           // bid/ask
+   TradeTransInfo    trade;               // trade transaction
+   int               gw_volume;           // gateway order volume
+   int               gw_order;            // gateway order ticket
+   short             gw_price;            // gateway order price deviation (pips) from request price
+   //---
+   RequestInfo* __ptr32 prev;
+   RequestInfo* __ptr32 next;             // (internal use)
+  };
+//--- trade request status
+enum { DC_EMPTY,DC_REQUEST,DC_LOCKED,DC_ANSWERED,DC_RESETED,DC_CANCELED };
+//--- time conversion ratio
+#define TIME_RATE         ((double)1.6777216)
+//--- conversion from our time to standard __time32_t
+#define STDTIME(custom_time) ((DWORD)((double)(custom_time)*TIME_RATE))
+//--- conversion from standard __time32_t to our time
+#define OURTIME(stdtime)     ((DWORD)((double)(stdtime)/TIME_RATE))
+//--- request confirmation modes
+enum EnConfirmModes
+  {
+   CONFIRM_MODE_ADD_PRICES=0x00000001,    // throw in prices
+   CONFIRM_MODE_PACKET    =0x00000002     // multiple execution
+  };
+//+------------------------------------------------------------------+
+//| Daily report                                                     |
+//+------------------------------------------------------------------+
+struct DailyReport
+  {
+   int               login;                // login
+   __time32_t        ctm;                  // time
+   char              group[16];            // group
+   char              bank[64];             // bank
+   double            balance_prev;         // previous balance
+   double            balance;              // balance
+   double            deposit;              // deposit
+   double            credit;               // credit
+   double            profit_closed;        // closed profit/loss
+   double            profit;               // floating profit/loss
+   double            equity;               // equity
+   double            margin;               // used margin
+   double            margin_free;          // free margin
+   //---
+   int               next;                 // (internal)
+   int               reserved[3];          // reserved
+  };
+//+------------------------------------------------------------------+
+//| Reports request                                                  |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct ReportGroupRequest
+  {
+   char              name[32];            // request group name
+   __time32_t        from;                // from
+   __time32_t        to;                  // to
+   int               total;               // total logins in request group
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Daily reports request                                            |
+//+------------------------------------------------------------------+
+struct DailyGroupRequest
+  {
+   char              name[32];            // group name
+   __time32_t        from;                // from
+   __time32_t        to;                  // to
+   int               total;               // total logins in request group
+   int               reserved;            // reserved
+  };
+//+------------------------------------------------------------------+
+//| Selected symbol information                                      |
+//+------------------------------------------------------------------+
+struct SymbolInfo
+  {
+   char              symbol[12];            // symbol name
+   int               digits;                // floating point digits
+   int               count;                 // symbol counter
+   int               visible;               // visibility
+   int               type;                  // symbol type (symbols group index)
+   double            point;                 // symbol point=1/pow(10,digits)
+   int               spread;                // symbol spread
+   int               spread_balance;        // spread balance
+   //---
+   int               direction;             // direction
+   int               updateflag;            // update flag
+   __time32_t        lasttime;              // last tick time
+   double            bid,ask;               // bid, ask
+   double            high,low;              // high, low
+   double            commission;            // commission
+   int               comm_type;             // commission type
+  };
+//--- symbol price direction
+enum { SDIR_UP,SDIR_DOWN,SDIR_NONE };
+//+------------------------------------------------------------------+
+//| Symbol summary                                                   |
+//+------------------------------------------------------------------+
+struct SymbolSummary
+  {
+   char              symbol[12];          // symbol
+   int               count;               // symbol counter
+   int               digits;              // floating point digits
+   int               type;                // symbol type (symbol group index)
+   //--- clients summary
+   int               orders;              // number of client orders
+   __int64           buylots;             // buy volume
+   __int64           selllots;            // sell volume
+   double            buyprice;            // average buy price
+   double            sellprice;           // average sell price
+   double            profit;              // clients profit
+   //--- coverage summary
+   int               covorders;           // number of coverage orders
+   __int64           covbuylots;          // buy volume
+   __int64           covselllots;         // sell volume
+   double            covbuyprice;         // average buy price
+   double            covsellprice;        // average sell price
+   double            covprofit;           // coverage profit
+  };
+//+------------------------------------------------------------------+
+//| Currence exposure                                                |
+//+------------------------------------------------------------------+
+struct ExposureValue
+  {
+   char              currency[4];         // currency
+   double            clients;             // clients volume
+   double            coverage;            // coverage volume
+  };
+//+------------------------------------------------------------------+
+//| Symbol properties                                                |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct SymbolPropertiesOld
+  {
+   char              symbol[12];             // symbol
+   COLORREF          color;                  // symbol color
+   int               spread;                 // symbol spread
+   int               spread_balance;         // spread balance
+   int               stops_level;            // stops level
+   int               exemode;                // execution mode
+  };
+#pragma pack(pop)
+//---
+#pragma pack(push,1)
+struct SymbolProperties
+  {
+   char              symbol[12];            // symbol
+   COLORREF          color;                 // symbol color
+   int               spread;                // symbol spread
+   int               spread_balance;        // spread balance
+   int               stops_level;           // stops level
+   int               smoothing;             // smoothing
+   int               exemode;               // execution mode
+   int               reserved[8];           // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Symbol tick                                                      |
+//+------------------------------------------------------------------+
+struct TickInfo
+  {
+   char              symbol[12];             // symbol
+   __time32_t        ctm;                    // tick time
+   double            bid;                    // bid
+   double            ask;                    // ask
+  };
+//+------------------------------------------------------------------+
+//| Mail                                                             |
+//+------------------------------------------------------------------+
+struct MailBox
+  {
+   __time32_t        time;                   // receive time
+   int               sender;                 // mail sender (login)
+   char              from[64];               // mail sender (name)
+   int               to;                     // mail recipient
+   char              subject[128];           // mail sumbect
+   int               readed;                 // readed flag
+   char* __ptr32     body;                   // pointer to mail body
+   int               bodylen;                // mail body length
+   short             build_min;              // minimum build
+   short             build_max;              // maximum build
+   int               reserved;               // reserved
+  };
+//+------------------------------------------------------------------+
+//| News topic                                                       |
+//+------------------------------------------------------------------+
+struct NewsTopic
+  {
+   ULONG             key;                    // news key
+   __time32_t        time;                   // news time
+   char              ctm[32];                // news source time ("yyyy/mm/dd hh:mm:ss")
+   char              topic[256];             // news topic
+   char              category[64];           // news category
+   char              keywords[256];          // news keywords
+   char* __ptr32     body;                   // body (if present)
+   int               bodylen;                // body length
+   int               readed;                 // readed flag
+   int               priority;               // news priority: 0-general, 1-high
+   int               langid;                 // news LANGID
+   int               reserved[1];
+  };
+//+------------------------------------------------------------------+
+//| Extended news structure                                          |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct NewsTopicNew
+  {
+   //--- constants
+   enum constants
+     {
+      MAX_NEWS_BODY_LEN=15*1024*1024         // max. body len
+     };
+   //--- news topic flags
+   enum EnNewsFlags
+     {
+      FLAG_PRIORITY    =1,                   // priority flag
+      FLAG_CALENDAR    =2,                   // calendar item flag
+      FLAG_MIME        =4,                   // MIME news content
+      FLAG_ALLOW_DEMO  =8                    // allow body for demo accounts
+     };
+   ULONG             key;                    // news key
+   UINT              language;               // news language (WinAPI LANGID)
+   wchar_t           subject[256];           // news subject
+   wchar_t           category[256];          // news category
+   UINT              flags;                  // EnNewsFlags
+   wchar_t* __ptr32  body;                   // body
+   UINT              body_len;               // body length
+   UINT              languages_list[32];     // list of languages available for news
+   INT64             datetime;               // news time
+   UINT              reserved[30];           // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Server journal record                                            |
+//+------------------------------------------------------------------+
+struct ServerLog
+  {
+   int               code;                   // code
+   char              time[24];               // time
+   char              ip[256];                // ip
+   char              message[512];           // message
+  };
+//--- log record codes
+enum EnErrLogTypes { 
+                    CmdOK,                  // OK
+                    CmdTrade,               // trades only
+                    CmdLogin,               // logins only
+                    CmdWarn,                // warnings
+                    CmdErr,                 // errors
+                    CmdAtt                  // attention, important errors
+                   };
+//--- request logs type
+enum EnLogType     { 
+                    LOG_TYPE_STANDARD=0,    // all except logins
+                    LOG_TYPE_LOGINS  =1,    // logins only
+                    LOG_TYPE_TRADES  =2,    // trades only
+                    LOG_TYPE_ERRORS  =3,    // errors
+                    LOG_TYPE_FULL    =4,    // full log
+                    //---
+                    LOG_TYPE_UPDATER =16,   // live update
+                    LOG_TYPE_SENDMAIL=17,   // send mail
+                    LOG_TYPE_FAILOVER=18    // failover
+                   };
+//--- request logs type
+enum EnLogMode     { 
+                    LOG_MODE_ENABLED,       // manager api logs enabled
+                    LOG_MODE_DISABLED,      // manager api logs disabled
+                   };
+//+------------------------------------------------------------------+
+//| Balance check                                                    |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct BalanceDiff
+  {
+   int               login;
+   double            diff;
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Pumping notification codes                                       |
+//+------------------------------------------------------------------+
+enum
+  {
+   PUMP_START_PUMPING=0,      // pumping started
+   PUMP_UPDATE_SYMBOLS,       // update symbols
+   PUMP_UPDATE_GROUPS,        // update groups
+   PUMP_UPDATE_USERS,         // update users
+   PUMP_UPDATE_ONLINE,        // update online users
+   PUMP_UPDATE_BIDASK,        // update bid/ask
+   PUMP_UPDATE_NEWS,          // update news
+   PUMP_UPDATE_NEWS_BODY,     // update news body
+   PUMP_UPDATE_MAIL,          // update news
+   PUMP_UPDATE_TRADES,        // update trades
+   PUMP_UPDATE_REQUESTS,      // update trade requests
+   PUMP_UPDATE_PLUGINS,       // update server plugins
+   PUMP_UPDATE_ACTIVATION,    // new order for activation (sl/sp/stopout)
+   PUMP_UPDATE_MARGINCALL,    // new margin calls
+   PUMP_STOP_PUMPING,         // pumping stopped
+   PUMP_PING,                 // ping
+   PUMP_UPDATE_NEWS_NEW,      // update news in new format (NewsTopicNew structure)
+  };
+//+------------------------------------------------------------------+
+//| Dealing notification codes                                       |
+//+------------------------------------------------------------------+
+enum
+  {
+   DEAL_START_DEALING=0,      // dealing dispatcher started
+   DEAL_REQUEST_NEW,          // new request
+   DEAL_STOP_DEALING          // dealing dispatcher stopped
+  };
+//+------------------------------------------------------------------+
+//| Notification callback function                                   |
+//+------------------------------------------------------------------+
+typedef void (__stdcall *MTAPI_NOTIFY_FUNC)(int code);
+//+------------------------------------------------------------------+
+//| Notification callback function                                   |
+//+------------------------------------------------------------------+
+typedef void (__stdcall *MTAPI_NOTIFY_FUNC_EX)(int code,int type,void * data,void *param);
+//+------------------------------------------------------------------+
+//| MetaTrader Manager Interface                                     |
+//+------------------------------------------------------------------+
+class CManagerInterface
+  {
+public:
+//--- dummy methods for delphi
+   virtual int    __stdcall QueryInterface(REFIID riid,LPVOID* obj)=0;
+   virtual int    __stdcall AddRef() =0;
+//--- release
+   virtual int    __stdcall Release()=0;
+//--- service methods
+   virtual void   __stdcall MemFree(void* ptr)              =0;
+   virtual LPCSTR __stdcall ErrorDescription(const int code)=0;
+   virtual void   __stdcall WorkingDirectory(LPCSTR path)   =0;
+//--- connection
+   virtual int  __stdcall Connect(LPCSTR server)                =0;
+   virtual int  __stdcall Disconnect()                          =0;
+   virtual int  __stdcall IsConnected()                         =0;
+   virtual int  __stdcall Login(const int login,LPCSTR password)=0;
+   virtual int  __stdcall LoginSecured(LPCSTR key_path)         =0;
+   virtual int  __stdcall KeysSend(LPCSTR key_path)             =0;
+   virtual int  __stdcall Ping()                                =0;
+   virtual int  __stdcall PasswordChange(LPCSTR pass,const int is_investor)=0;
+   virtual int  __stdcall ManagerRights(ConManager *man)        =0;
+//--- server administration commands
+   virtual int  __stdcall SrvRestart()        =0;
+   virtual int  __stdcall SrvChartsSync()     =0;
+   virtual int  __stdcall SrvLiveUpdateStart()=0;
+   virtual int  __stdcall SrvFeedsRestart()   =0;
+//--- server configuration
+   //--- configuration request
+   virtual int  __stdcall CfgRequestCommon(ConCommon *cfg)=0;
+   virtual int  __stdcall CfgRequestTime(ConTime *cfg)    =0;
+   virtual int  __stdcall CfgRequestBackup(ConBackup *cfg)=0;
+   virtual int  __stdcall CfgRequestSymbolGroup(ConSymbolGroup *cfg)=0;
+   virtual ConAccess*      __stdcall CfgRequestAccess(int *total)    =0;
+   virtual ConDataServer*  __stdcall CfgRequestDataServer(int *total)=0;
+   virtual ConHoliday*     __stdcall CfgRequestHoliday(int *total)   =0;
+   virtual ConSymbol*      __stdcall CfgRequestSymbol(int *total)    =0;
+   virtual ConGroup*       __stdcall CfgRequestGroup(int *total)     =0;
+   virtual ConManager*     __stdcall CfgRequestManager(int *total)   =0;
+   virtual ConFeeder*      __stdcall CfgRequestFeeder(int *total)    =0;
+   virtual ConLiveUpdate*  __stdcall CfgRequestLiveUpdate(int *total)=0;
+   virtual ConSync*        __stdcall CfgRequestSync(int *total)      =0;
+   virtual ConPluginParam* __stdcall CfgRequestPlugin(int *total)    =0;
+   //--- configuration update
+   virtual int  __stdcall CfgUpdateCommon(const ConCommon* cfg)                        =0;
+   virtual int  __stdcall CfgUpdateAccess(const ConAccess* cfg,const int pos)          =0;
+   virtual int  __stdcall CfgUpdateDataServer(const ConDataServer *cfg,const int pos)  =0;
+   virtual int  __stdcall CfgUpdateTime(const ConTime *cfg)                            =0;
+   virtual int  __stdcall CfgUpdateHoliday(const ConHoliday *cfg,const int pos)        =0;
+   virtual int  __stdcall CfgUpdateSymbol(const ConSymbol *cfg)                        =0;
+   virtual int  __stdcall CfgUpdateSymbolGroup(const ConSymbolGroup *cfg,const int pos)=0;
+   virtual int  __stdcall CfgUpdateGroup(const ConGroup *cfg)                          =0;
+   virtual int  __stdcall CfgUpdateManager(const ConManager *cfg)                      =0;
+   virtual int  __stdcall CfgUpdateFeeder(const ConFeeder *cfg)                        =0;
+   virtual int  __stdcall CfgUpdateBackup(const ConBackup *cfg)                        =0;
+   virtual int  __stdcall CfgUpdateLiveUpdate(const ConLiveUpdate *cfg)                =0;
+   virtual int  __stdcall CfgUpdateSync(const ConSync *cfg)                            =0;
+   virtual int  __stdcall CfgUpdatePlugin(const ConPlugin *cfg,const PluginCfg *parupd,const int total)=0;
+   //--- configuration delete
+   virtual int  __stdcall CfgDeleteAccess(const int pos)    =0;
+   virtual int  __stdcall CfgDeleteDataServer(const int pos)=0;
+   virtual int  __stdcall CfgDeleteHoliday(const int pos)   =0;
+   virtual int  __stdcall CfgDeleteSymbol(const int pos)    =0;
+   virtual int  __stdcall CfgDeleteGroup(const int pos)     =0;
+   virtual int  __stdcall CfgDeleteManager(const int pos)   =0;
+   virtual int  __stdcall CfgDeleteFeeder(const int pos)    =0;
+   virtual int  __stdcall CfgDeleteLiveUpdate(const int pos)=0;
+   virtual int  __stdcall CfgDeleteSync(const int pos)      =0;
+   //--- configuration shift
+   virtual int  __stdcall CfgShiftAccess(const int pos,const int shift)    =0;
+   virtual int  __stdcall CfgShiftDataServer(const int pos,const int shift)=0;
+   virtual int  __stdcall CfgShiftHoliday(const int pos,const int shift)   =0;
+   virtual int  __stdcall CfgShiftSymbol(const int pos,const int shift)    =0;
+   virtual int  __stdcall CfgShiftGroup(const int pos,const int shift)     =0;
+   virtual int  __stdcall CfgShiftManager(const int pos,const int shift)   =0;
+   virtual int  __stdcall CfgShiftFeeder(const int pos,const int shift)    =0;
+   virtual int  __stdcall CfgShiftLiveUpdate(const int pos,const int shift)=0;
+   virtual int  __stdcall CfgShiftSync(const int pos,const int shift)      =0;
+   virtual int  __stdcall CfgShiftPlugin(const int pos,const int shift)    =0;
+//--- server feeders
+   virtual ServerFeed* __stdcall SrvFeeders(int *total)            =0;
+   virtual LPSTR       __stdcall SrvFeederLog(LPCSTR name,int *len)=0;
+//--- chart bases
+   virtual RateInfoOld* __stdcall ChartRequestObsolete(const ChartInfo *chart,__time32_t *timesign,int *total)           =0;
+   virtual int          __stdcall ChartAddObsolete(LPCSTR symbol,const int period,const RateInfoOld* rates,int *count)   =0;
+   virtual int          __stdcall ChartUpdateObsolete(LPCSTR symbol,const int period,const RateInfoOld* rates,int *count)=0;
+   virtual int          __stdcall ChartDeleteObsolete(LPCSTR symbol,const int period,const RateInfoOld* rates,int *count)=0;
+//--- performance info
+   virtual PerformanceInfo* __stdcall PerformanceRequest(__time32_t from,int *total)=0;
+//--- users/trades backups
+   virtual BackupInfo*  __stdcall BackupInfoUsers(const int mode,int *total) =0;
+   virtual BackupInfo*  __stdcall BackupInfoOrders(const int mode,int *total)=0;
+   virtual UserRecord*  __stdcall BackupRequestUsers(LPCSTR file,LPCSTR request,int *total) =0;
+   virtual TradeRecord* __stdcall BackupRequestOrders(LPCSTR file,LPCSTR request,int *total)=0;
+   virtual int          __stdcall BackupRestoreUsers(const UserRecord *users,const int total)     =0;
+   virtual TradeRestoreResult* __stdcall BackupRestoreOrders(const TradeRecord *trades,int *total)=0;
+//--- administrator databases commands
+   virtual UserRecord*  __stdcall AdmUsersRequest(LPCSTR group,int *total)          =0;
+   virtual TradeRecord* __stdcall AdmTradesRequest(LPCSTR group,const int open_only,int *total)=0;
+   virtual int          __stdcall AdmBalanceCheckObsolete(int *logins,int *total)   =0;
+   virtual int          __stdcall AdmBalanceFix(const int *logins,const int total)  =0;
+   virtual int          __stdcall AdmTradesDelete(const int *orders,const int total)=0;
+   virtual int          __stdcall AdmTradeRecordModify(const TradeRecord *trade)    =0;
+//--- symbols
+   virtual int          __stdcall SymbolsRefresh()                           =0;
+   virtual ConSymbol*   __stdcall SymbolsGetAll(int *total)                  =0;
+   virtual int          __stdcall SymbolGet(LPCSTR symbol,ConSymbol *cs)     =0;
+   virtual int          __stdcall SymbolInfoGet(LPCSTR symbol,SymbolInfo *si)=0;
+   virtual int          __stdcall SymbolAdd(LPCSTR symbol)                   =0;
+   virtual int          __stdcall SymbolHide(LPCSTR symbol)                  =0;
+//--- symbol commands
+   virtual int          __stdcall SymbolChangeObsolete(const SymbolPropertiesOld *prop)=0;
+   virtual int          __stdcall SymbolSendTick(LPCSTR symbol,const double bid,const double ask)=0;
+//--- manager commands
+   virtual ConGroup*    __stdcall GroupsRequest(int *total)                      =0;
+   virtual int          __stdcall MailSend(const MailBox* mail,const int *logins)=0;
+   virtual int          __stdcall NewsSend(const NewsTopic *news)                =0;
+//--- journal
+   virtual ServerLog*   __stdcall JournalRequest(const int mode,const __time32_t from,const __time32_t to,LPCSTR filter,int *total)=0;
+//--- databases: direct request to the server
+//--- users
+   virtual UserRecord*  __stdcall UsersRequest(int *total)                        =0;
+   virtual UserRecord*  __stdcall UserRecordsRequest(const int *logins,int *total)=0;
+   virtual int          __stdcall UserRecordNew(UserRecord *user)                 =0;
+   virtual int          __stdcall UserRecordUpdate(const UserRecord *user)        =0;
+   virtual int          __stdcall UsersGroupOp(const GroupCommandInfo *info,const int *logins)=0;
+   virtual int          __stdcall UserPasswordCheck(const int login,LPCSTR password)=0;
+   virtual int          __stdcall UserPasswordSet(const int login,LPCSTR password,const int change_investor,const int clean_pubkey)=0;
+   virtual OnlineRecord* __stdcall OnlineRequest(int *total)              =0;
+//--- orders
+   virtual int          __stdcall TradeTransaction(TradeTransInfo *info)           =0;
+   virtual TradeRecord* __stdcall TradesRequest(int *total)                        =0;
+   virtual TradeRecord* __stdcall TradeRecordsRequest(const int *orders,int *total)=0;
+   virtual TradeRecord* __stdcall TradesUserHistory(const int login,const __time32_t from,const __time32_t to,int *total)=0;
+   virtual int          __stdcall TradeCheckStops(const TradeTransInfo *trade,const double price)=0;
+//--- reports
+   virtual TradeRecord* __stdcall ReportsRequest(const ReportGroupRequest *req,const int *logins,int *total)    =0;
+   virtual DailyReport* __stdcall DailyReportsRequest(const DailyGroupRequest *req,const int *logins,int *total)=0;
+//--- external command
+   virtual int          __stdcall ExternalCommand(LPCSTR data_in,const int size_in,LPSTR *data_out,int *size_out)=0;
+//--- plugins
+   virtual int          __stdcall PluginUpdate(const ConPluginParam *plugin)=0;
+//--- pumping
+   virtual int          __stdcall PumpingSwitch(MTAPI_NOTIFY_FUNC pfnFunc,const HWND destwnd,const UINT eventmsg,const int flags)=0;
+   virtual ConGroup*    __stdcall GroupsGet(int *total)                                    =0;
+   virtual int          __stdcall GroupRecordGet(LPCSTR name,ConGroup *group)              =0;
+   virtual int          __stdcall SymbolInfoUpdated(SymbolInfo *si,const int max_info)     =0;
+   virtual UserRecord*  __stdcall UsersGet(int *total)                                     =0;
+   virtual int          __stdcall UserRecordGet(const int login,UserRecord *user)          =0;
+   virtual OnlineRecord* __stdcall OnlineGet(int *total)                                   =0;
+   virtual int          __stdcall OnlineRecordGet(const int login,OnlineRecord *user)      =0;
+   virtual TradeRecord* __stdcall TradesGet(int *total)                                    =0;
+   virtual TradeRecord* __stdcall TradesGetBySymbol(LPCSTR symbol,int *total)              =0;
+   virtual TradeRecord* __stdcall TradesGetByLogin(const int login,LPCSTR group,int *total)=0;
+   virtual TradeRecord* __stdcall TradesGetByMarket(int *total)                            =0;
+   virtual int          __stdcall TradeRecordGet(const int order,TradeRecord *trade)       =0;
+   virtual int          __stdcall TradeClearRollback(const int order)                      =0;
+   virtual MarginLevel* __stdcall MarginsGet(int *total)                                   =0;
+   virtual int          __stdcall MarginLevelGet(const int login,LPCSTR group,MarginLevel *margin)=0;
+   virtual RequestInfo* __stdcall RequestsGet(int *total)                                  =0;
+   virtual int          __stdcall RequestInfoGet(const int pos,RequestInfo *info)          =0;
+   virtual ConPlugin*   __stdcall PluginsGet(int *total)                                   =0;
+   virtual int          __stdcall PluginParamGet(const int pos,ConPluginParam *plugin)     =0;
+   virtual int          __stdcall MailLast(LPSTR path,int *length)                         =0;
+   virtual NewsTopic*   __stdcall NewsGet(int *total)                                      =0;
+   virtual int          __stdcall NewsTotal()                                              =0;
+   virtual int          __stdcall NewsTopicGet(const int pos,NewsTopic *news)              =0;
+   virtual void         __stdcall NewsBodyRequest(const int key)                           =0;
+   virtual LPSTR        __stdcall NewsBodyGet(const int key)                               =0;
+//--- dealing
+   virtual int          __stdcall DealerSwitch(MTAPI_NOTIFY_FUNC pfnFunc,const HWND destwnd,const UINT eventmsg)=0;
+   virtual int          __stdcall DealerRequestGet(RequestInfo *info)   =0;
+   virtual int          __stdcall DealerSend(const RequestInfo *info,const int requote,const int mode)=0;
+   virtual int          __stdcall DealerReject(const int id)            =0;
+   virtual int          __stdcall DealerReset(const int id)             =0;
+//---
+   virtual TickInfo*    __stdcall TickInfoLast(LPCSTR symbol,int *total)=0;
+   virtual int          __stdcall SymbolsGroupsGet(ConSymbolGroup *grp) =0;
+   virtual __time32_t   __stdcall ServerTime()                          =0;
+   virtual MailBox*     __stdcall MailsRequest(int *total)              =0;
+//--- risk management
+   virtual SymbolSummary* __stdcall SummaryGetAll(int *total)                            =0;
+   virtual int          __stdcall SummaryGet(LPCSTR symbol,SymbolSummary *info)          =0;
+   virtual int          __stdcall SummaryGetByCount(const int symbol,SymbolSummary *info)=0;
+   virtual int          __stdcall SummaryGetByType(const int sectype,SymbolSummary *info)=0;
+   virtual int          __stdcall SummaryCurrency(LPSTR cur,const int maxchars)          =0;
+   virtual ExposureValue* __stdcall ExposureGet(int *total)                              =0;
+   virtual int          __stdcall ExposureValueGet(LPCSTR cur,ExposureValue *info)       =0;
+//---
+   virtual int          __stdcall MarginLevelRequest(const int login,MarginLevel *level) =0;
+   virtual int          __stdcall HistoryCorrect(LPCSTR symbol,int *updated)             =0;
+//--- new chart bases
+   virtual RateInfo *   __stdcall ChartRequest(const ChartInfo *chart,__time32_t *timesign,int *total)            =0;
+   virtual int          __stdcall ChartAdd(LPCSTR symbol,const int period,const RateInfo *rates,int *count)   =0;
+   virtual int          __stdcall ChartUpdate(LPCSTR symbol,const int period,const RateInfo *rates,int *count)=0;
+   virtual int          __stdcall ChartDelete(LPCSTR symbol,const int period,const RateInfo *rates,int *count)=0;
+//--- ticks base
+   virtual TickRecord*  __stdcall TicksRequest(const TickRequest *request,int *total)=0;
+//--- internal methods
+   virtual int          __stdcall PumpingSwitchEx(MTAPI_NOTIFY_FUNC_EX pfnFunc,const int flags,void *param)=0;
+   virtual int          __stdcall UsersSyncStart(const __time32_t timestamp)=0;
+   virtual UserRecord*  __stdcall UsersSyncRead(int* users_total)=0;
+   virtual int*         __stdcall UsersSnapshot(int* users_total)=0;
+   virtual int          __stdcall TradesSyncStart(const __time32_t timestamp)=0;
+   virtual TradeRecord* __stdcall TradesSyncRead(int* trades_total)=0;
+   virtual int*         __stdcall TradesSnapshot(int* trades_total)=0;
+   virtual int          __stdcall DailySyncStart(const __time32_t timestamp)=0;
+   virtual DailyReport* __stdcall DailySyncRead(int* daily_total)=0;
+//--- profit recalculation
+   virtual int          __stdcall TradeCalcProfit(TradeRecord *trade)=0;
+//--- new symbol commands
+   virtual int          __stdcall SymbolChange(const SymbolProperties *prop) =0;
+//--- network statistics
+   virtual int          __stdcall BytesSent()=0;
+   virtual int          __stdcall BytesReceived()=0;
+//---
+   virtual int          __stdcall ManagerCommon(ConCommon *common)=0;
+//--- log access
+   virtual void         __stdcall LogsOut(const int code,LPCSTR source,LPCSTR msg)=0;
+   virtual void         __stdcall LogsMode(const int mode)=0;
+//--- check license
+   virtual int         __stdcall  LicenseCheck(LPCSTR license_name)=0;
+//--- gateway configs
+   virtual ConGatewayAccount* __stdcall CfgRequestGatewayAccount(int *total)=0;
+   virtual ConGatewayMarkup*  __stdcall CfgRequestGatewayMarkup(int *total)=0;
+   virtual ConGatewayRule*    __stdcall CfgRequestGatewayRule(int *total)=0;
+   //--- configuration update
+   virtual int          __stdcall CfgUpdateGatewayAccount(const ConGatewayAccount* cfg)=0;
+   virtual int          __stdcall CfgUpdateGatewayMarkup(const ConGatewayMarkup* cfg)=0;
+   virtual int          __stdcall CfgUpdateGatewayRule(const ConGatewayRule *cfg)=0;
+   //--- configuration delete
+   virtual int          __stdcall CfgDeleteGatewayAccount(const int pos)=0;
+   virtual int          __stdcall CfgDeleteGatewayMarkup(const int pos)=0;
+   virtual int          __stdcall CfgDeleteGatewayRule(const int pos)=0;
+   //--- configuration shift
+   virtual int          __stdcall CfgShiftGatewayAccount(const int pos,const int shift)=0;
+   virtual int          __stdcall CfgShiftGatewayMarkup(const int pos,const int shift)=0;
+   virtual int          __stdcall CfgShiftGatewayRule(const int pos,const int shift)=0;
+//--- administrator databases commands
+   virtual BalanceDiff* __stdcall AdmBalanceCheck(int *logins,int *total)=0;
+//--- notifications
+   virtual int          __stdcall NotificationsSend(LPWSTR metaquotes_ids,LPCWSTR message)=0;
+   virtual int          __stdcall NotificationsSend(const int* logins,const UINT logins_total,LPCWSTR message)=0;
+  };
+//+------------------------------------------------------------------+
+//| Functions                                                        |
+//+------------------------------------------------------------------+
+typedef int (*MtManVersion_t)(void);
+typedef int (*MtManCreate_t)(int version,CManagerInterface **man);
+//+------------------------------------------------------------------+
+//| Factory                                                          |
+//+------------------------------------------------------------------+
+#ifndef _MT4MANDLL
+class CManagerFactory
+  {
+private:
+   HMODULE           m_lib;
+   MtManVersion_t    m_pfnManVersion;
+   MtManCreate_t     m_pfnManCreate;
+public:
+   //--- constructor
+   CManagerFactory(LPCSTR lib_path=NULL):m_lib(NULL) 
+     {
+      Init(lib_path);
+     }
+   //--- destructor
+  ~CManagerFactory()
+     {
+      if(m_lib)
+        {
+         m_pfnManVersion=NULL;
+         m_pfnManCreate =NULL;
+         ::FreeLibrary(m_lib); 
+         m_lib=NULL;
+        }
+     }
+   //--- initialization
+   inline void Init(LPCSTR lib_path=NULL)
+     {
+      char path[256]="";
+      //---
+      if(lib_path!=NULL) 
+        {
+         strcpy_s(path,lib_path);
+         path[sizeof(path)-1]=0;
+        }
+      else               
+        { 
+         #ifndef _WIN64
+         strcpy_s(path,"mtmanapi.dll"); 
+         path[sizeof(path)-1]=0; 
+         #else
+         strcpy_s(path,"mtmanapi64.dll"); 
+         path[sizeof(path)-1]=0; 
+         #endif
+        }
+      //---
+      if(m_lib) 
+         ::FreeLibrary(m_lib);
+      if((m_lib=::LoadLibraryA(path))!=NULL)
+        {
+         m_pfnManVersion=reinterpret_cast<MtManVersion_t>(::GetProcAddress(m_lib,"MtManVersion"));
+         m_pfnManCreate =reinterpret_cast<MtManCreate_t>(::GetProcAddress(m_lib,"MtManCreate"));
+        }
+      else
+        {
+         m_pfnManVersion=NULL;
+         m_pfnManCreate =NULL;
+        }
+      //---
+     }
+   //--- winsock startup/cleanup
+   inline int WinsockStartup() const
+     {
+      WSADATA wsa;
+      return(WSAStartup(0x0202,&wsa)!=0 ? RET_ERROR:RET_OK);
+     }
+   inline void WinsockCleanup() const 
+     {
+      WSACleanup();
+     }
+   //---
+   inline int IsValid() const 
+     {
+      return(m_lib!=NULL && m_pfnManVersion!=NULL && m_pfnManCreate!=NULL) ? TRUE:FALSE;
+     }
+   inline int Version() const 
+     {
+      return(m_pfnManVersion?(*m_pfnManVersion)():0);
+     }
+   inline CManagerInterface* Create(const int version) const
+     {
+      CManagerInterface *man=NULL;
+      if(m_pfnManCreate) (*m_pfnManCreate)(version,&man);
+      return(man);
+     }
+  };
+#endif
+//+------------------------------------------------------------------+

BIN
1220/ManagerAPI/mtmanapi.dll


BIN
1220/ManagerAPI/mtmanapi64.dll


+ 1452 - 0
1220/ServerAPI/MT4ServerAPI.h

@@ -0,0 +1,1452 @@
+//+------------------------------------------------------------------+
+//|                                      MetaTrader Server Interface |
+//|                   Copyright 2001-2015, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+//|                   DO NOT EDIT THIS FILE!                         |
+//+------------------------------------------------------------------+
+#pragma once
+
+#define ServerApiVersion                5
+
+//+------------------------------------------------------------------+
+//| Memory allocation macro                                          |
+//+------------------------------------------------------------------+
+#define HEAP_ALLOC(size) HeapAlloc(GetProcessHeap(),0,size)
+#define HEAP_FREE(mem)   HeapFree(GetProcessHeap(),0,mem)
+//+------------------------------------------------------------------+
+//| Structures                                                       |
+//+------------------------------------------------------------------+
+//| Information about plugin                                         |
+//+------------------------------------------------------------------+
+struct PluginInfo
+  {
+   char              name[128];             // plugin name
+   unsigned int      version;               // plugin version
+   char              copyright[128];        // plugin copyright
+   int               reserved[32];          // reserved
+  };
+//+------------------------------------------------------------------+
+//| Plugin configuration structure                                   |
+//+------------------------------------------------------------------+
+struct PluginCfg
+  {
+   char              name[32];
+   char              value[128];
+   int               reserved[16];
+  };
+//+------------------------------------------------------------------+
+//| Server config structures                                         |
+//+------------------------------------------------------------------+
+//| Access configuration                                             |
+//+------------------------------------------------------------------+
+struct ConAccess
+  {
+   int               action;                // type of action (FW_BLOCK,FW_PERMIT)
+   unsigned long     from,to;               // from, to addresses
+   char              comment[64];           // comment
+   int               reserved[17];          // reserved
+  };
+//--- 
+enum { FW_BLOCK, FW_PERMIT, FW_WHITELIST };
+//+------------------------------------------------------------------+
+//| Common configuration                                             |
+//+------------------------------------------------------------------+
+struct ConCommon
+  {
+   char              owner[128];            // servers owner (include version & build)
+   char              name[32];              // server name
+   ULONG             address;               // IP address assigned to the server
+   int               port;                  // port
+   DWORD             timeout;               // sockets timeout
+   int               enable_demo;           // enable demo DEMO_DISABLED, DEMO_PROLONG, DEMO_FIXED
+   int               timeofdemo;            // demo-account living time (days since last connect)
+   int               daylightcorrection;    // allow daylight correction
+   char              internal[60];          // reserved
+   int               timezone_real;         // time zone with day light mode
+   int               timezone;              // time zone 0-GMT;-1=GMT-1;1=GMT+1;
+   char              timesync[64];          // time synchronization server address
+   //---
+   int               minclient;             // minimal authorized client version
+   int               minapi;                // minimal authorized client version
+   DWORD             feeder_timeout;        // data feed switch timeout
+   int               keepemails;            // internal mail keep period
+   int               endhour,endminute;     // end of day time-hour & minute
+   //---
+   int               optimization_time;     // optimization start time (minutes)
+   int               optimization_lasttime; // optimization last time
+   int               optimization_counter;  // internal variable
+   int               optimization_unused[8];// reserved for future use
+   //---
+   int               antiflood;             // enable antiflood control
+   int               floodcontrol;          // max. antiflood connections
+   //---
+   int               liveupdate_mode;       // LiveUpdate mode LIVE_UPDATE_NO,LIVE_UPDATE_ALL,LIVE_UPDATE_NO_SERVER
+   //---
+   int               lastorder;             // last order's ticket     (read only)
+   int               lastlogin;             // last account's number   (read only)
+   int               lostlogin;             // lost commission's login (read only)
+   //---
+   int               rollovers_mode;        // rollover mode (ROLLOVER_NORMAL,ROLLOVER_REOPEN_BY_CLOSE_PRICE,ROLLOVER_REOPEN_BY_BID)
+   //---
+   char              path_database[256];    // path to databases
+   char              path_history[256];     // path to history bases
+   char              path_log[256];         // path to log
+   //--- overnigths
+   time_t            overnight_last_day;    // day of last overnight
+   time_t            overnight_last_time;   // time of last overnight
+   time_t            overnight_prev_time;   // time of previous overnight
+   //--- month reports
+   time_t            overmonth_last_month;  // time of last report
+   //--- performance base
+   char              adapters[256];         // network adapters list (read-only)
+   ULONG             bind_adresses[8];      // array of available IP addresses
+   short             server_version;        // server version (filled by server)
+   short             server_build;          // server build (filled by server)
+   ULONG             web_adresses[8];       // array of IP addresses available for Web services
+   int               statement_mode;        // statements generation mode STATEMENT_END_DAY, STATEMENT_START_DAY
+   int               monthly_state_mode;    // monthly generation enumeration MONTHLY_STATEMENT_END_MONTH, MONTHLY_STATEMENT_START_MONTH
+   int               keepticks;             // ticks keep period
+   int               statement_weekend;     // generate statements at weekends
+   time_t            last_activate;         // last activation datetime
+   time_t            stop_last;             // last stop datetime
+   int               stop_delay;            // last stop delay
+   int               stop_reason;           // last stop reason STOP_REASON_NONE, STOP_REASON_RESTART, STOP_REASON_SHUTDOWN, STOP_REASON_LIVEUPDATE
+   char              account_url[128];      // account allocation URL
+   int               reserved[16];
+  };
+//+------------------------------------------------------------------+
+//| Time config                                                      |
+//+------------------------------------------------------------------+
+struct ConTime
+  {
+   int               days[7][24];           // server's accessebility(7 days-24 hours, 0-denied, 1-allowed)
+   int               dayscontrol;           // internal variable
+   int               reserved[3];           // reserved
+  };
+//+------------------------------------------------------------------+
+//| Backup configuration                                             |
+//+------------------------------------------------------------------+
+struct ConBackup
+  {
+   //---
+   char              fullbackup_path[256];  // path to backup
+   int               fullbackup_period;     // full backup's period-BACKUP_1HOUR, BACKUP_4HOURS, BACKUP_1DAY
+   int               fullbackup_store;      // full backup's store time-BU_STORE_1MONTH, BU_STORE_3MONTHS, BU_STORE_6MONTHS,BU_STORE_1YEAR
+   time_t            fullbackup_lasttime;   // full backup's last execution time
+   short             fullbackup_shift;      // full backup timeshift (minutes)
+   //---
+   char              external_path[256];    // path to external processing directory
+   //---
+   int               archive_period;        // period of archive backup-ARC_BACKUP_5MIN, ARC_BACKUP_15MIN, ARC_BACKUP_30MIN, ARC_BACKUP_1HOUR
+   int               archive_store;         // archive backup's store time-ARC_STORE_1WEEK, ARC_STORE_2WEEKS, ARC_STORE_1MONTH, ARC_STORE_3MONTH, ARC_STORE_6MONTH
+   time_t            archive_lasttime;      // archive backup's last execution time
+   //---
+   char              export_securities[512];// comma separated list of exported securities
+   char              export_path[256];      // path to export script
+   int               export_period;         // export period-enumeration EXPORT_1MIN, EXPORT_5MIN, EXPORT_15MIN, EXPORT_30MIN,EXPORT_1HOUR
+   time_t            export_lasttime;       // export's last execution time
+   //--- watch dog
+   int               watch_role;            // server role WATCH_STAND_ALONE, WATCH_MASTER, WATCH_SLAVE
+   char              watch_password[16];    // watch dog password
+   char              watch_opposite[24];    // opposite server address
+   unsigned long     watch_ip;              // opposite server IP
+   //---
+   char              archive_shift;         // shift of archive backup time (in minutes)
+   //---
+   char              watch_state;            // watch dog state WS_DISCONNECTED, WS_SYNCHRONIZING, WS_SYNCHRONIZED
+   char              watch_failover;         // watch dog failover mode
+   unsigned char     watch_timeout;          // watch dog timeout
+   int               watch_login;            // watch dog login
+   time_t            watch_timestamp;        // watch dog timestamp
+  };
+//--- full backup execution periods: 1 hour, 4 hours, 1 day
+enum { BACKUP_1HOUR, BACKUP_4HOURS, BACKUP_1DAY };
+//--- arc. backup execution periods: 5 min, 15 min, 30 min, 1 hour
+enum { ARC_BACKUP_DISABLED, ARC_BACKUP_5MIN, ARC_BACKUP_15MIN, ARC_BACKUP_30MIN, ARC_BACKUP_1HOUR };
+//--- arc. backup store period: 1 month,3 months, 6 months,1 year
+enum { ARC_STORE_1DAY, ARC_STORE_3DAYS, ARC_STORE_1WEEK, ARC_STORE_2WEEKS, ARC_STORE_1MONTH, ARC_STORE_3MONTH, ARC_STORE_6MONTH };
+//--- export execution period: 1 min, 5 min, 15 min, 30 min, 1 hour
+enum { EXPORT_1MIN, EXPORT_5MIN, EXPORT_15MIN, EXPORT_30MIN,EXPORT_1HOUR };
+//--- rollover mode
+enum { ROLLOVER_NORMAL, ROLLOVER_REOPEN_BY_CLOSE_PRICE, ROLLOVER_REOPEN_BY_BID };
+//--- statement generate mode
+enum { STATEMENT_END_DAY, STATEMENT_START_DAY };
+//--- server role
+enum { WATCH_STAND_ALONE, WATCH_MASTER, WATCH_SLAVE };
+//--- live update modes
+enum { LIVE_UPDATE_NO, LIVE_UPDATE_RELEASE, LIVE_UPDATE_NO_SERVER, LIVE_UPDATE_BETA };
+//--- demo modes
+enum { DEMO_DISABLED, DEMO_PROLONG, DEMO_FIXED };
+//--- monthly statement mode
+enum { MONTHLY_STATEMENT_END_MONTH, MONTHLY_STATEMENT_START_MONTH };
+//--- watchdog state
+enum { WS_DISCONNECTED, WS_SYNCHRONIZING, WS_SYNCHRONIZED };
+//--- watchdog failover mode
+enum { FAILOVER_OFF, FAILOVER_MOST, FAILOVER_FULL };
+//--- server stop reason
+enum { STOP_REASON_NONE, STOP_REASON_RESTART, STOP_REASON_SHUTDOWN, STOP_REASON_LIVEUPDATE };
+//+------------------------------------------------------------------+
+//| Datafeed configuration                                           |
+//+------------------------------------------------------------------+
+struct ConFeeder
+  {
+   char              name[64];              // name
+   char              file[256];             // datafeed filename
+   char              server[64];            // server address
+   char              login[32];             // datafeed login
+   char              pass[32];              // datafeed password
+   char              keywords[256];         // keywords (news filtration)
+   int               enable;                // enable feeder
+   int               mode;                  // datafeed mode-enumeration FEED_QUOTES, FEED_NEWS, FEED_QUOTESNEWS
+   int               timeout;               // max. freeze time (default ~120 sec.)
+   int               timeout_reconnect;     // reconnect timeout before attemps_sleep connect attempts (default ~ 5  sec)
+   int               timeout_sleep;         // reconnect timeout after attemps_sleep connect attempts  (default ~ 60 sec)
+   int               attemps_sleep;         // reconnect count (see timeout_reconnect & timeout_sleep)
+   int               news_langid;           // news language id
+   int               unused[33];            // reserved
+  };
+//--- datafeed modes-receive quotes, receive news, receive quotes and news
+enum { FEED_QUOTES=0, FEED_NEWS=1, FEED_QUOTESNEWS=2 };
+//+------------------------------------------------------------------+
+//| Security group configuration for  client group                   |
+//+------------------------------------------------------------------+
+#define MAX_SEC_GROUPS       (32)
+#define MAX_SEC_GROPS_MARGIN (128)
+//---
+struct ConGroupSec
+  {
+   int               show,trade;            // enable show and trade for this group of securites
+   int               execution;             // dealing mode-EXECUTION_MANUAL,EXECUTION_AUTO,EXECUTION_ACTIVITY
+   //--- comission settings
+   double            comm_base;             // standart commission
+   int               comm_type;             // commission type-COMM_TYPE_MONEY,COMM_TYPE_PIPS,COMM_TYPE_PERCENT
+   int               comm_lots;             // commission lots mode-COMMISSION_PER_LOT,COMMISSION_PER_DEAL
+   double            comm_agent;            // agent commission
+   int               comm_agent_type;       // agent commission mode-COMM_TYPE_MONEY, COMM_TYPE_PIPS
+   //---
+   int               spread_diff;           // spread difference in compare with default security spread
+   //---
+   int               lot_min,lot_max;       // allowed minimal and maximal lot values
+   int               lot_step;              // allowed step value (10 lot-1000, 1 lot-100, 0.1 lot-10)
+   int               ie_deviation;          // maximum price deviation in Instant Execution mode
+   int               confirmation;          // use confirmation in Request mode
+   int               trade_rights;          // clients trade rights-bit mask see TRADE_DENY_NONE,TRADE_DENY_CLOSEBY,TRADE_DENY_MUCLOSEBY
+   int               ie_quick_mode;         // 
+   int               autocloseout_mode;     // auto close-out modes see CLOSE_OUT_NONE,CLOSE_OUT_HIHI, CLOSE_OUT_LOLO, CLOSE_OUT_HILO, CLOSE_OUT_LOHI,CLOSE_OUT_LOHI,CLOSE_OUT_FIFO,CLOSE_OUT_LIFO,CLOSE_OUT_INTRDAY_FIFO
+   double            comm_tax;              // commission taxes
+   int               comm_agent_lots;       // agent commission lots mode-COMMISSION_PER_LOT,COMMISSION_PER_DEAL
+   int               freemargin_mode;       // free margin check mode
+   //--- ðåçåðâ
+   int               reserved[3];
+
+  };
+//+------------------------------------------------------------------+
+//| Special securities configurations                                |
+//+------------------------------------------------------------------+
+struct ConGroupMargin
+  {
+   char              symbol[12];            // security
+   double            swap_long,swap_short;  // swap size for long and short positions
+   double            margin_divider;        // margin divider
+   int               reserved[7];
+  };
+//--- dealing mode
+enum  { EXECUTION_MANUAL, EXECUTION_AUTO, EXECUTION_ACTIVITY };
+//--- commission type
+enum  { COMM_TYPE_MONEY, COMM_TYPE_PIPS, COMM_TYPE_PERCENT };
+//--- comission lots mode
+enum  { COMMISSION_PER_LOT, COMMISSION_PER_DEAL };
+//--- clients trade rights
+enum  { TRADE_DENY_NONE=0, TRADE_DENY_CLOSEBY=1, TRADE_DENY_MUCLOSEBY=2 };
+//--- auto close-out modes
+enum  { CLOSE_OUT_NONE, CLOSE_OUT_HIHI, CLOSE_OUT_LOLO, CLOSE_OUT_HILO, CLOSE_OUT_LOHI, CLOSE_OUT_FIFO, CLOSE_OUT_LIFO, CLOSE_OUT_INTRDAY_FIFO };
+//+------------------------------------------------------------------+
+//| Client group configuration                                       |
+//+------------------------------------------------------------------+
+struct ConGroup
+  {
+   //--- common settings
+   char              group[16];                   // group name
+   int               enable;                      // enable group
+   int               timeout;                     // trade confirmation timeout (seconds)
+   int               otp_mode;                    // one-time password mode
+   //--- statements
+   char              company[128];                // company name
+   char              signature[128];              // statements signature
+   char              support_page[128];           // company support page
+   char              smtp_server[64];             // statements SMTP server
+   char              smtp_login[32];              // statements SMTP login
+   char              smtp_password[32];           // statements SMTP password
+   char              support_email[64];           // support email
+   char              templates[32];               // path to directory with custom templates
+   int               copies;                      // copy statements on support email
+   int               reports;                     // enable statements
+   //--- default settings
+   int               default_leverage;            // default leverage (user don't specify leverage himself)
+   double            default_deposit;             // default deposit  (user don't specify balance  himself)
+   //--- securities
+   int               maxsecurities;               // maximum simultaneous securities
+   ConGroupSec       secgroups[MAX_SEC_GROUPS];   // security group settings
+   ConGroupMargin    secmargins[MAX_SEC_GROPS_MARGIN]; // special securities settings
+   int               secmargins_total;            // count of special securities settings
+   //--- margin & interest
+   char              currency[12];                // deposit currency
+   double            credit;                      // virtual credit
+   int               margin_call;                 // margin call level (percents)
+   int               margin_mode;                 // margin mode-MARGIN_DONT_USE,MARGIN_USE_ALL,MARGIN_USE_PROFIT,MARGIN_USE_LOSS
+   int               margin_stopout;              // stop out level
+   double            interestrate;                // annual interest rate (percents)
+   int               use_swap;                    // use rollovers & interestrate
+   //--- rights
+   int               news;                        // news mode
+   int               rights;                      // rights bit mask-ALLOW_FLAG_EMAIL
+   int               check_ie_prices;             // check by stream prices on IE
+   int               maxpositions;                // open positions limit (0 - unlimited)
+   int               close_reopen;                // partial close mode (if !=0 original position will be fully closed and remain position will be fully reopened)
+   int               hedge_prohibited;            // hedge prohibition flag
+   int               close_fifo;                  // fifo rule 
+   int               hedge_largeleg;              // calculate hedged margin using larger leg
+   int               unused_rights[2];            // reserverd
+   char              securities_hash[16];         // internal data
+   //---
+   int               margin_type;                 // stop out calculation mode { MARGIN_TYPE_PERCENT,  MARGIN_TYPE_CURRENCY }
+   //--- archive parameters
+   int               archive_period;              
+   int               archive_max_balance;         
+   //--- stopout mode
+   int               stopout_skip_hedged;         
+   int               archive_pending_period;      // pendings clean period
+   //--- allowed news languages
+   UINT              news_languages[8];           // LANGID array
+   UINT              news_languages_total;        // news languages total
+   //--- reserved
+   int               reserved[17];
+  };
+//--- margin mode
+enum  { MARGIN_MODE_DONT_USE,MARGIN_MODE_USE_ALL,MARGIN_MODE_USE_PROFIT,MARGIN_MODE_USE_LOSS };
+//--- stop out calculation mode
+enum  { MARGIN_TYPE_PERCENT,  MARGIN_TYPE_CURRENCY };
+//--- news mode-no news, only topics, full news (topic+body)
+enum  { NEWS_NO, NEWS_TOPICS, NEWS_FULL  };
+//--- group rights
+enum 
+  { 
+   ALLOW_FLAG_EMAIL           =1,
+   ALLOW_FLAG_TRAILING        =2,
+   ALLOW_FLAG_ADVISOR         =4,
+   ALLOW_FLAG_EXPIRATION      =8,
+   ALLOW_FLAG_SIGNALS_ALL     =16,
+   ALLOW_FLAG_SIGNALS_OWN     =32,
+   ALLOW_FLAG_RISK_WARNING    =64,
+   ALLOW_FLAG_FORCED_OTP_USAGE=128,
+  };
+//--- group one-time password mode
+enum
+  {
+   OTP_MODE_DISABLED       =0,
+   OTP_MODE_TOTP_SHA256    =1,
+  };
+//+------------------------------------------------------------------+
+//| Hollidays configuration                                          |
+//+------------------------------------------------------------------+
+struct ConHoliday
+  {
+   int               year;                        // year
+   int               month;                       // month
+   int               day;                         // day
+   int               from,to;                     // work time-from & to (minutes)
+   char              symbol[32];                  // security name or symbol's group name or "All"
+   char              description[128];            // description
+   int               enable;                      // enable
+   int               reserved[13];                // reserved
+   ConHoliday       *next;                        // internal data
+  };
+//+------------------------------------------------------------------+
+//| LiveUpdate configuration                                         |
+//+------------------------------------------------------------------+
+#define LIVE_FILES_MAX 64
+//---
+struct LiveInfoFile
+  {
+   char              file[256];                   // file name
+   int               size;                        // file size
+   char              hash[36];                    // file hash
+   int               reserved[10];                // reserved
+  };
+//---
+struct ConLiveUpdate
+  {
+   char              company[128];                // company
+   char              path[256];                   // path to LiveUpdate
+   int               version;                     // version
+   int               build;                       // build
+   int               maxconnect;                  // max. simultaneous connections
+   int               connections;                 // current connections (read only)
+   int               type;                        // type LIVE_UPDATE_CLIENT, LIVE_UPDATE_MANAGER, LIVE_UPDATE_ADMIN
+   int               enable;                      // enable
+   int               totalfiles;                  // total files count
+   LiveInfoFile      files[LIVE_FILES_MAX];       // files' configurations
+   int               reserved[16];                // reserved
+   ConLiveUpdate    *next;                        // internal data
+  };
+//--- LiveUpdate type
+enum { LIVE_UPDATE_CLIENT,         LIVE_UPDATE_MANAGER,         LIVE_UPDATE_ADMIN, LIVE_UPDATE_DATACENTER, 
+       LIVE_UPDATE_CLIENT_PPC2002, LIVE_UPDATE_CLIENT_PPC2003,  LIVE_UPDATE_MULTI, LIVE_UPDATE_WD,
+       LIVE_UPDATE_CLIENT_PHONE,   LIVE_UPDATE_LAST };
+//+------------------------------------------------------------------+
+//| Manager rights for security groups                               |
+//+------------------------------------------------------------------+
+struct ConManagerSec
+  {
+   int               internal;                    // internal data
+   int               enable;                      // enable
+   int               minimum_lots;                // min. lots
+   int               maximum_lots;                // max. lots
+   int               unused[16];                  // reserved
+  };
+//+------------------------------------------------------------------+
+//| Manager configuration                                            |
+//+------------------------------------------------------------------+
+struct ConManager
+  {
+   int               login;                       // login
+   //--- rights
+   int               manager;                     // right to add & change client records
+   int               money;                       // right to balance & credit management
+   int               online;                      // right to see online users
+   int               riskman;                     // right to use analyzer
+   int               broker;                      // right to deal
+   int               admin;                       // right to server administration
+   int               logs;                        // right to see logs
+   int               reports;                     // right to see reports
+   int               trades;                      // right to add/modify/delete trades
+   int               market_watch;                // right to change spread, spread balance, stop levels, execution mode and send quotes
+   int               email;                       // right to send internal mail
+   int               user_details;                // right to see clients private data-name,country,address,phone,email etc.
+   int               see_trades;                  // right to see the trading acitivity
+   int               news;                        // right to send news
+   int               plugins;                     // right to control server plugins
+   int               server_reports;              // right to receive server reports
+   int               techsupport;                 // right to access to technical support page
+   int               market;                      // right to access server applications market
+   int               notifications;               // right to push notifications
+   int               unused[9];
+   //--- IP filtration
+   int               ipfilter;                    // enable IP control
+   unsigned long     ip_from,ip_to;               // range of allowed IPs
+   //---
+   char              mailbox[64];                 // name of mailbof for internal mail
+   char              groups[1024];                // comma separated list of managed groups (allowed '*' wildcard)
+   ConManagerSec     secgroups[MAX_SEC_GROUPS];   // manager rights for security groups
+   DWORD             exp_time;                    // internal data
+   char              name[32];                    // manager name (filled from the corresponding UserRecord)
+   int               info_depth;                  // depth of avalaible information
+   //---
+   int               reserved[22];
+  };
+//+------------------------------------------------------------------+
+//| Security configurations                                          |
+//+------------------------------------------------------------------+
+//+------------------------------------------------------------------+
+//| Security sessions configurations                                 |
+//+------------------------------------------------------------------+
+struct ConSession
+  {
+   short             open_hour,open_min;          // session open  time: hour & minute
+   short             close_hour,close_min;        // session close time: hour & minute
+   int               open,close;                  // internal data
+   short             align[7];                    // internal data
+  };
+//---
+struct ConSessions
+  {
+   //---
+   ConSession        quote[3];                    // quote sessions
+   ConSession        trade[3];                    // trade sessions
+   //---
+   int               quote_overnight;             // internal data
+   int               trade_overnight;             // internal data
+   int               reserved[2];                 // reserved
+  };
+//+------------------------------------------------------------------+
+//| Security config                                                  |
+//+------------------------------------------------------------------+
+#define MAX_SYMBOLS 1024
+//---
+struct ConSymbol
+  {
+   //--- common settings
+   char              symbol[12];                  // name
+   char              description[64];             // description
+   char              source[12];                  // synonym
+   char              currency[12];                // currency
+   int               type;                        // security group (see ConSymbolGroup)
+   int               digits;                      // security precision
+   int               trade;                       // trade mode
+   //--- external settings
+   COLORREF          background_color;            // background color
+   int               count;                       // symbols index
+   int               count_original;              // symbols index in market watch
+   int               external_unused[7];
+   //--- sessions
+   int               realtime;                    // allow real time quotes
+   time_t            starting;                    // trades starting date (UNIX time)
+   time_t            expiration;                  // trades end date      (UNIX time)
+   ConSessions       sessions[7];                 // quote & trade sessions
+   //--- profits
+   int               profit_mode;                 // profit calculation mode
+   int               profit_reserved;             // reserved
+   //--- filtration
+   int               filter;                      // filter value
+   int               filter_counter;              // filtration parameter
+   double            filter_limit;                // max. permissible deviation from last quote (percents)
+   int               filter_smoothing;            // smoothing
+   float             filter_reserved;             // reserved
+   int               logging;                     // enable to log quotes
+   //--- spread & swaps
+   int               spread;                      // spread
+   int               spread_balance;              // spread balance
+   int               exemode;                     // execution mode
+   int               swap_enable;                 // enable swaps
+   int               swap_type;                   // swap type
+   double            swap_long,swap_short;        // swaps values for long & short postions
+   int               swap_rollover3days;          // triple rollover day 0-Sunday,1-Monday,2-Tuesday...
+   double            contract_size;               // contract size
+   double            tick_value;                  // one tick value
+   double            tick_size;                   // one tick size
+   int               stops_level;                 // stops deviation value
+   int               gtc_pendings;                // GTC mode ORDERS_DAILY, ORDERS_GTC, ORDERS_DAILY_NO_STOPS
+   //--- margin calculation
+   int               margin_mode;                 // margin calculation mode
+   double            margin_initial;              // initial margin
+   double            margin_maintenance;          // margin maintenance
+   double            margin_hedged;               // hedged margin
+   double            margin_divider;              // margin divider
+   //--- calclulated variables (internal data)
+   double            point;                       // point size-(1/(10^digits)
+   double            multiply;                    // multiply 10^digits
+   double            bid_tickvalue;               // tickvalue for bid
+   double            ask_tickvalue;               // tickvalue for ask
+   //---
+   int               long_only;                   // allow only BUY positions
+   int               instant_max_volume;          // max. volume for Instant Execution
+   //---
+   char              margin_currency[12];         // currency of margin requirments
+   int               freeze_level;                // modification freeze level (from market price)
+   int               margin_hedged_strong;        // lock open checking mode
+   time_t            value_date;                  // value date for this security
+   int               quotes_delay;                // quotes delay
+   int               swap_openprice;         	  // use open price at swaps calculation in SWAP_BY_INTEREST mode
+   int               swap_variation_margin;       // charge variation margin on rollover
+   //---
+   int               unused[21];             	  // reserved
+
+  };
+//+------------------------------------------------------------------+
+//| Symbols enumeration                                              |
+//+------------------------------------------------------------------+
+//--- symbol execution mode
+enum  { EXE_REQUEST,EXE_INSTANT,EXE_MARKET };
+//--- trade mode
+enum  { TRADE_NO,TRADE_CLOSE,TRADE_FULL };
+//--- swap type
+enum  { SWAP_BY_POINTS,SWAP_BY_DOLLARS, SWAP_BY_INTEREST, SWAP_BY_MARGIN_CURRENCY };
+//--- profit calculation mode
+enum  { PROFIT_CALC_FOREX,PROFIT_CALC_CFD,PROFIT_CALC_FUTURES };
+//--- margin calculation mode
+enum  { MARGIN_CALC_FOREX,MARGIN_CALC_CFD,MARGIN_CALC_FUTURES,MARGIN_CALC_CFDINDEX,MARGIN_CALC_CFDLEVERAGE };
+//--- GTC mode
+enum  { ORDERS_DAILY, ORDERS_GTC, ORDERS_DAILY_NO_STOPS };
+//+------------------------------------------------------------------+
+//| Symbol groups                                                    |
+//+------------------------------------------------------------------+
+struct ConSymbolGroup
+  {
+   char              name[16];                    // group name
+   char              description[64];             // group description
+  };
+//+------------------------------------------------------------------+
+//| Gateway configuration                                            |
+//+------------------------------------------------------------------+
+//+------------------------------------------------------------------+
+//| Gateway account configuration                                    |
+//+------------------------------------------------------------------+
+struct ConGatewayAccount
+  {
+   int               enable;                       // enable flag 0 - disabled, 1 - enabled
+   char              name[64];                     // public name
+   int               id;                           // internal id
+   int               type;                         // type (obsolete)
+   int               login;                        // STP MT4 login
+   char              address[64];                  // MT4 server address
+   char              password[64];                 // STP MT4 password
+   int               notify_logins[8];             // list of logins for internal email notification
+   int               flags;                        // flag fields
+   int               reserved[23];                 // reserved
+  };
+//--- gateway account flags
+enum EnGatewayAccountFlags { GATEWAY_FLAG_NONE=0, GATEWAY_FLAG_QUOTES=1 };
+//+------------------------------------------------------------------+
+//| Gateway markup configuration                                     |
+//+------------------------------------------------------------------+
+struct ConGatewayMarkup
+  {
+   int               enable;                       // enable flag 0 - disabled, 1 - enabled
+   char              source[128];                  // source symbol\symbols mask\symbols group name
+   char              symbol[12];                   // local symbol name
+   char              account_name[64];             // account name (obsolete)
+   int               account_id;                   // account internal id (obsolete)
+   int               bid_markup;                   // bid markup in pips
+   int               ask_markup;                   // ask markup in pips
+   int               reserved[16];                 // reserved
+  };
+//+------------------------------------------------------------------+
+//| Gateway rules configuration                                     |
+//+------------------------------------------------------------------+
+struct ConGatewayRule
+  {
+   int               enable;                       // enable flag 0 - disabled, 1 - enabled
+   char              name[64];                     // public name
+   char              request_symbol[128];          // symbol\symbols mask\symbols group name
+   char              request_group[128];           // group name or group mask
+   int               request_reserved[32];         // reserved
+   char              exe_account_name[64];         // account name
+   int               exe_account_id;               // account internal id
+   int               exe_max_deviation;            // max. devation
+   int               exe_max_profit_slippage;      // max profit slippage in pips
+   int               exe_max_profit_slippage_lots; // max profit slippage volume in lots
+   int               exe_max_losing_slippage;      // max losing slippage in pips
+   int               exe_max_losing_slippage_lots; // max losing slippage volume in lots
+   int               exe_account_pos;              // account current position
+   int               exe_volume_percent;           // coverage percentage
+   int               exe_flags;                    // execution flags
+   int               exe_reserved[25];             // reserved
+  };
+//+------------------------------------------------------------------+
+//| Gateway rules flags                                              |
+//+------------------------------------------------------------------+
+enum EnGatewayRuleFlags
+  {
+   GATEWAY_RULE_FLAG_NONE  =0,                     // none
+   GATEWAY_RULE_FLAG_DEALER=1                      // process dealer's trades
+  };
+//+------------------------------------------------------------------+
+//| Feeder quote structure                                           |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct FeedTick
+  {
+   char              symbol[16];                 // security
+   time_t            ctm;                        // time (UNIX time)
+   char              bank[32];                   // source bank
+   double            bid,ask;                    // bid/ask
+   int               feeder;                     // feeder index
+   char              reverved[8];                // reserved
+  };
+//+------------------------------------------------------------------+
+//| Tick source constants for FeedTick::feeder                       |
+//+------------------------------------------------------------------+
+enum EnTickSources  
+  { 
+   TICK_SRC_DEALER_AUTO  =-1,			 // tick placed as result of request confirmation with in_stream flag
+   TICK_SRC_DEALER_MANUAL=-2,                    // tick placed manually by dealer
+   TICK_SRC_GATEWAY      =-128                   // base value for gateway ticks 
+                                                 // gateway index calculated like abs(TICK_SRC_GATEWAY-FeedTick::feeder)
+  };
+//+------------------------------------------------------------------+
+//| Feeder data quote                                                |
+//+------------------------------------------------------------------+
+struct FeedData
+  {
+   //--- quotes data
+   FeedTick          ticks[32];                  // quotes array
+   int               ticks_count;                // quotes count
+   //--- news data
+   char              news_time[32];              // news time description
+   char              subject[256];               // news subject
+   char              category[64];               // news category
+   char              keywords[256];              // news keywords
+   char             *body;                       // news body
+   int               body_len;                   // news body len
+   int               body_maxlen;                // max. body len
+   //--- ðåçóëüòàòû îïåðàöèé
+   int               result;                     // work result
+   char              result_string[256];         // error description
+   int               feeder;                     // datafeed index
+   int               mode;                       // internal data
+   int               langid;                     // news LANGID
+   char              reserved[64];               // reserved
+  };
+//+------------------------------------------------------------------+
+//| Extended news structure                                          |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct FeedNews
+  {
+   //--- constants
+   enum constants
+     {
+      MAX_NEWS_BODY_LEN=15*1024*1024             // max. body len
+     };
+   //--- news topic flags
+   enum EnNewsFlags
+     {
+      FLAG_PRIORITY    =1,                       // priority flag
+      FLAG_CALENDAR    =2,                       // calendar item flag
+      FLAG_MIME        =4,                       // MIME news content
+      FLAG_ALLOW_DEMO  =8                        // allow body for demo accounts
+     };
+   UINT              language;                   // news language (WinAPI LANGID)
+   wchar_t           subject[256];               // news subject
+   wchar_t           category[256];              // news category
+   UINT              flags;                      // EnNewsFlags
+   wchar_t          *body;                       // body
+   UINT              body_len;                   // body length
+   UINT              languages_list[32];         // list of languages available for news
+   INT64             datetime;                   // news time
+   UINT              reserved[30];               // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Log record structure                                             |
+//+------------------------------------------------------------------+
+struct LogInfo
+  {
+   int               code;                       // error code-CmdOK,CmdTrade,CmdLogin,CmdWarn,CmdErr,CmdAtt
+   char              ip[64];                     // IP address
+   char              msg[512];                   // error description
+   tm                ctm;                        // time
+   int               unused[2];                  // reserved
+  };
+//---
+#pragma pack(pop)
+//--- error code
+enum { CmdOK,CmdTrade,CmdLogin,CmdWarn,CmdErr,CmdAtt };
+//+------------------------------------------------------------------+
+//| Log request record structure                                     |
+//+------------------------------------------------------------------+
+struct LogRequest
+  {
+   char              mode;                       // request mode
+   time_t            from;                       // from time
+   time_t            to;                         // to time
+   char              filter[64];                 // filter
+  };
+//--- log request type
+enum EnLogType { LOG_TYPE_STANDARD, LOG_TYPE_LOGINS, LOG_TYPE_TRADES, LOG_TYPE_ERRORS, LOG_TYPE_FULL };
+//+------------------------------------------------------------------+
+//| Perfomance database record                                       |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct PerformanceInfo
+  {
+   time_t            ctm;                        // time
+   short             users;                      // connections count
+   short             cpu;                        // cpu usage
+   int               freemem;                    // free memory
+   int               network;                    // network usage byte per.sec.
+   int               sockets;                    // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Client full description                                          |
+//+------------------------------------------------------------------+
+struct UserRecord
+  {
+   //--- common settings
+   int               login;                      // login
+   char              group[16];                  // group
+   char              password[16];               // password
+   //--- access flags
+   int               enable;                     // enable
+   int               enable_change_password;     // allow to change password
+   int               enable_read_only;           // allow to open/positions (TRUE-may not trade)
+   int               enable_otp;                 // allow to use one-time password
+   int               enable_reserved[2];         // for future use
+   //---
+   char              password_investor[16];      // read-only mode password
+   char              password_phone[32];         // phone password
+   char              name[128];                  // name
+   char              country[32];                // country
+   char              city[32];                   // city
+   char              state[32];                  // state
+   char              zipcode[16];                // zipcode
+   char              address[96];                // address
+   char              lead_source[32];            // lead source
+   char              phone[32];                  // phone
+   char              email[48];                  // email
+   char              comment[64];                // comment
+   char              id[32];                     // SSN (IRD)
+   char              status[16];                 // status
+   time_t            regdate;                    // registration date
+   time_t            lastdate;                   // last coonection time
+   //--- trade settings
+   int               leverage;                   // leverage
+   int               agent_account;              // agent account
+   time_t            timestamp;                  // timestamp
+   int               last_ip;                    // last visit ip
+   //---            òîðãîâûå äàííûå
+   double            balance;                    // balance
+   double            prevmonthbalance;           // previous month balance
+   double            prevbalance;                // previous day balance
+   double            credit;                     // credit
+   double            interestrate;               // accumulated interest rate
+   double            taxes;                      // taxes
+   double            prevmonthequity;            // previous month equity
+   double            prevequity;                 // previous day equity
+   double            reserved2[2];               // for future use
+   //---
+   char              otp_secret[32];             // one-time password secret
+   char              secure_reserved[240];       // secure data reserved
+   int               send_reports;               // enable send reports by email
+   unsigned int      mqid;                       // MQ client identificator
+   COLORREF          user_color;                 // color got to client (used by MT Manager)
+   //---
+   char              unused[40];                 // for future use
+   char              api_data[16];               // for APIs usage
+  };
+//+------------------------------------------------------------------+
+//| Client short description                                         |
+//+------------------------------------------------------------------+
+struct UserInfo
+  {
+   //--- common settings
+   int               login;                      // login
+   char              group[16];                  // group
+   char              password[16];               // password
+   char              name[128];                  // name
+   char              ip[16];                     // IP address
+   //--- access flags
+   int               enable;                     // enable
+   int               enable_change_password;     // allow to change password
+   int               enable_read_only;           // allow to open/positions (TRUE-may not trade)
+   int               flags;                      // internal data
+   //--- trade parameters
+   int               leverage;                   // leverage
+   int               agent_account;              // agent account
+   //--- trade data
+   double            balance;                    // balance
+   double            credit;                     // credit
+   double            prevbalance;                // previous day balance
+   ConGroup          grp;                        // client group
+  };
+//+------------------------------------------------------------------+
+//| Rate history record                                              |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct RateInfo
+  {
+   time_t            ctm;                       // time (UNIX)
+   int               open;                      // open price: 11987 => 119.87 (2 digits), 11987 => 1.1987 (4 digits)
+   int               high,low,close;            // prices shift in points: open=11987 => open is 119.87; high=5 => open is 119.92
+   double            vol;                       // volume
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Tick structure                                                   |
+//+------------------------------------------------------------------+
+struct TickAPI
+  {
+   time_t            ctm;                        // time
+   double            bid,ask;                    // normalized bid & ask
+  };
+//+------------------------------------------------------------------+
+//| Internal mail record                                             |
+//+------------------------------------------------------------------+
+struct MailBoxHeader
+  {
+   time_t            time;                       // receive time
+   int               sender;                     // sender login
+   char              from[64];                   // sender description
+   int               to;                         // addressee login
+   char              subject[128];               // subject
+   int               read;                       // read flag
+   char             *body;                       // body
+   int               bodylen;                    // body len
+   unsigned short    min_build,max_build;        // build limitations
+   int               reserved[1];                // reserved
+  };
+//+------------------------------------------------------------------+
+//| Trade transaction structures                                     |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct TradeTransInfo
+  {
+   UCHAR             type;                       // trade transaction
+   char              flags;                      // flags
+   short             cmd;                        // trade command
+   int               order,orderby;              // order ticket,"order by" ticket
+   char              symbol[12];                 // security
+   int               volume;                     // volume
+   double            price;                      // prices
+   double            sl,tp;                      // stop loss & take profit
+   int               ie_deviation;               // deviation on Instant Execution
+   char              comment[32];                // comment
+   time_t            expiration;                 // expiration time (server time in UNIX format)
+   int               crc;                        // CRC
+  };
+#pragma pack(pop)
+//--- trade transactions type
+enum
+  {
+   //---
+   TT_PRICES_GET,                                // prices request
+   TT_PRICES_REQUOTE,                            // prices requote (for internal usage)
+   //--- client activity
+   TT_ORDER_IE_OPEN=64,                          // open position at Instant Execution
+   TT_ORDER_REQ_OPEN,                            // open position at Request Execution
+   TT_ORDER_MK_OPEN,                             // open position at Market Execution
+   TT_ORDER_PENDING_OPEN,                        // open pending order
+   //---
+   TT_ORDER_IE_CLOSE,                            // close position at  Instant Execution
+   TT_ORDER_REQ_CLOSE,                           // close position at  Request Execution
+   TT_ORDER_MK_CLOSE,                            // close position at  Market Execution
+   //---
+   TT_ORDER_MODIFY,                              // modify position or pending order
+   TT_ORDER_DELETE,                              // delete pending order
+   TT_ORDER_CLOSE_BY,                            // close hedged positions
+   TT_ORDER_CLOSE_ALL,                           // close all hedged positions for same security
+   //--- manager activity
+   TT_BR_ORDER_OPEN,                             // open order (by manager)
+   TT_BR_ORDER_CLOSE,                            // close order (by manager)
+   TT_BR_ORDER_DELETE,                           // delete ANY open position
+   TT_BR_ORDER_CLOSE_BY,                         // close hedged positions (by manager)
+   TT_BR_ORDER_CLOSE_ALL,                        // close all hedged positions for same security (by manager)
+   TT_BR_ORDER_MODIFY,                           // modify position or pending order (by manager)
+   TT_BR_ORDER_ACTIVATE,                         // activate pending order (by manager)
+   TT_BR_ORDER_COMMENT,                          // comment order (by manager)
+   TT_BR_BALANCE                                 // change balance & credit (by manager)
+   };
+//--- trade request flags
+enum EnReqFlags
+  {
+   TT_FLAG_NONE   =0x00000000,                   // flags none
+   TT_FLAG_SIGNAL =0x00000001,                   // placed by signal
+   TT_FLAG_EXPERT =0x00000002,                   // placed by expert
+   TT_FLAG_GATEWAY=0x00000004,                   // placed by gateway
+   TT_FLAG_MOBILE =0x00000008,                   // placed by mobile terminal
+   TT_FLAG_WEB    =0x00000010,                   // placed by web terminal
+   TT_FLAG_API    =0x00000020,                   // placed by api
+  };
+//--- trade commands
+enum { OP_BUY=0,OP_SELL,OP_BUY_LIMIT,OP_SELL_LIMIT,OP_BUY_STOP,OP_SELL_STOP,OP_BALANCE,OP_CREDIT };
+//+------------------------------------------------------------------+
+//| Request queue record                                             |
+//+------------------------------------------------------------------+
+struct RequestInfo
+  {
+   //--- common info
+   int               id;                         // request id
+   int               status;                     // request status DC_EMPTY,DC_REQUEST,DC_LOCKED,DC_ANSWERED,DC_RESETED,DC_CANCELED
+   DWORD             time;                       // request time
+   int               manager;                    // login of manager who takes this request
+   //--- client info
+   int               login;                      // client login
+   char              group[16];                  // client group
+   double            balance;                    // client balance
+   double            credit;                     // client credit
+   //--- processed trade transaction
+   double            prices[2];                  // prices
+   TradeTransInfo    trade;                      // trade transaction
+   int               gw_volume;                  // gateway order volume
+   int               gw_order;                   // gateway order ticket
+   short             gw_price;                   // gateway order price deviation (pips) from request price
+   short             reserved;
+   //--- internal data
+   RequestInfo      *prev,*next;                 // internal data
+  };
+//--- request status
+enum { DC_EMPTY,DC_REQUEST,DC_LOCKED,DC_ANSWERED,DC_RESETED,DC_CANCELED };
+//+------------------------------------------------------------------+
+//| Trade record                                                     |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct TradeRecord
+  {
+   int               order;                      // order ticket
+   int               login;                      // owner's login
+   char              symbol[12];                 // security
+   int               digits;                     // security precision
+   int               cmd;                        // trade command
+   int               volume;                     // volume
+   time_t            open_time;                  // open time
+   int               state;                      // trade record state
+   double            open_price;                 // open price
+   double            sl,tp;                      // stop loss & take profit
+   time_t            close_time;                 // close time
+   int               gw_volume;                  // gateway order volume
+   time_t            expiration;                 // pending order's expiration time
+   char              reason;                     // trade reason
+   char              conv_reserv[3];             // reserved fields
+   double            conv_rates[2];              // convertation rates from profit currency to group deposit currency
+                                                 // (first element-for open time, second element-for close time)
+   double            commission;                 // commission
+   double            commission_agent;           // agent commission
+   double            storage;                    // order swaps
+   double            close_price;                // close price
+   double            profit;                     // profit
+   double            taxes;                      // taxes value
+   int               magic;                      // special value used by client experts
+   char              comment[32];                // comment
+   int               gw_order;                   // gateway order ticket
+   int               activation;                 // used by MT Manager
+   short             gw_open_price;              // gateway order price deviation (pips) from order open price
+   short             gw_close_price;             // gateway order price deviation (pips) from order close price
+   double            margin_rate;                // margin cinvertation rate (rate of convertation from margin currency to deposit one)
+   time_t            timestamp;                  // timestamp
+   int               api_data[4];                // for api usage
+   TradeRecord      *next;                       // internal data
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Margin status structure                                          |
+//+------------------------------------------------------------------+
+struct MarginLevel
+  {
+   int               login;                      // login
+   int               leverage;                   // leverage
+   int               updated;                    // internal data
+   double            balance;                    // balance+credit value
+   double            margin;                     // margin requirments
+   double            equity;                     // equity
+  };
+//+------------------------------------------------------------------+
+//| Overnight calculation data                                       |
+//+------------------------------------------------------------------+
+struct OverNightData
+  {
+   ConSymbol         symbol;                     // symbol
+   double            point;                      // internal data
+   TradeRecord     **trades;                     // internal data
+   int               trades_total;               // internal data
+   int               trades_max;                 // internal data
+  };
+//+------------------------------------------------------------------+
+//| Daily report structure                                           |
+//+------------------------------------------------------------------+
+struct DailyReport
+  {
+   int               login;                      // login
+   time_t            ctm;                        // daily report time
+   char              group[16];                  // user group
+   char              bank[64];                   // bank info (from UserRecord::Comment)
+   double            balance_prev;               // balance for previous day
+   double            balance;                    // balance to the end for this day
+   double            deposit;                    // sum of balance operations for this day
+   double            credit;                     // sum of credit operations for this day
+   double            profit_closed;              // profit of the today closed positions (including swaps & commissions)
+   double            profit;                     // floating profit/loss
+   double            equity;                     // equity
+   double            margin;                     // margin
+   double            margin_free;                // free margin
+   //--- internal data
+   int               next;
+   int               reserved[3];
+  };
+//+------------------------------------------------------------------+
+//| Client statement summary                                         |
+//+------------------------------------------------------------------+
+struct StateReport
+  {
+   //--- closed positions info
+   double            deposit;                    // Deposit/Withdrawal result
+   double            credit;                     // Credit In/Out      result
+   double            closed_profit;              // closed positions total profit
+   double            closed_commission;          // closed positions total commission
+   double            closed_swap;                // closed positions total swap
+   double            closed_taxes;               // closed positions total taxes
+   //--- open positions info
+   double            profit;                     // profit
+   double            commission;                 // commission
+   double            swap;                       // swap
+   double            equity;                     // Equity
+   double            taxes;                      // taxes
+   double            margin;                     // margin
+   double            margin_free;                // free margin
+  };
+//+------------------------------------------------------------------+
+//| Clients group info for statement				     |
+//+------------------------------------------------------------------+
+struct GroupState
+  {
+   ConGroup          group;
+   UserRecord       *users;
+   int               users_total;
+   TradeRecord      *trades;
+   int               trades_total;
+   MarginLevel      *margins;
+   int               margins_total;
+  };
+//+------------------------------------------------------------------+
+//| Server access class                                              |
+//+------------------------------------------------------------------+
+struct CServerInterface
+  {
+   virtual int         __stdcall Version(void);
+   //---            common functions
+   virtual time_t      __stdcall TradeTime(void);
+   //--- firewall config access
+   virtual int         __stdcall AccessAdd(const int pos,const ConAccess *acc);
+   virtual int         __stdcall AccessDelete(const int pos);
+   virtual int         __stdcall AccessNext(const int pos,ConAccess *acc);
+   virtual int         __stdcall AccessShift(const int pos,const int shift);
+   //--- common config access
+   virtual void        __stdcall CommonGet(ConCommon *info);
+   virtual void        __stdcall CommonSet(const ConCommon *info);
+   //--- time config access
+   virtual void        __stdcall TimeGet(ConTime *info);
+   virtual void        __stdcall TimeSet(const ConTime *info);
+   //--- backup config access
+   virtual void        __stdcall BackupGet(ConBackup *info);
+   virtual int         __stdcall BackupSet(const ConBackup *info);
+   //--- feeders config access
+   virtual int         __stdcall FeedersAdd(const ConFeeder *feeder);
+   virtual int         __stdcall FeedersDelete(const int pos);
+   virtual int         __stdcall FeedersNext(const int pos,ConFeeder *feeder);
+   virtual int         __stdcall FeedersGet(LPCSTR name,ConFeeder *feeder);
+   virtual int         __stdcall FeedersShift(const int pos,const int shift);
+   virtual int         __stdcall FeedersEnable(LPCSTR name,const int mode);
+   //--- groups config access
+   virtual int         __stdcall GroupsAdd(ConGroup *group);
+   virtual int         __stdcall GroupsDelete(const int pos);
+   virtual int         __stdcall GroupsNext(const int pos,ConGroup *group);
+   virtual int         __stdcall GroupsGet(LPCSTR name,ConGroup *group);
+   virtual int         __stdcall GroupsShift(const int pos,const int shift);
+   //--- holidays config access
+   virtual int         __stdcall HolidaysAdd(const int pos,ConHoliday *day);
+   virtual int         __stdcall HolidaysDelete(const int pos);
+   virtual int         __stdcall HolidaysNext(const int pos,ConHoliday *day);
+   virtual int         __stdcall HolidaysShift(const int pos,const int shift);
+   //--- live update config access
+   virtual int         __stdcall LiveUpdateAdd(ConLiveUpdate *live);
+   virtual int         __stdcall LiveUpdateDelete(const int pos);
+   virtual int         __stdcall LiveUpdateNext(const int pos,ConLiveUpdate *live);
+   virtual int         __stdcall LiveUpdateGet(LPCSTR server,const int type,ConLiveUpdate *live);
+   //--- managers config access
+   virtual int         __stdcall ManagersAdd(ConManager *man);
+   virtual int         __stdcall ManagersDelete(const int pos);
+   virtual int         __stdcall ManagersNext(const int pos,ConManager *manager);
+   virtual int         __stdcall ManagersGet(const int login,ConManager *manager);
+   virtual int         __stdcall ManagersShift(const int pos,const int shift);
+   virtual int         __stdcall ManagersIsDemo(LPCSTR group,LPCSTR sec,const int volume);
+   //--- symbols config access
+   virtual int         __stdcall SymbolsAdd(ConSymbol *sec);
+   virtual int         __stdcall SymbolsDelete(const int pos);
+   virtual int         __stdcall SymbolsNext(const int pos, ConSymbol *sec);
+   virtual int         __stdcall SymbolsGet(LPCSTR symbol,ConSymbol *security);
+   virtual int         __stdcall SymbolsShift(const int pos,const int shift);
+   virtual int         __stdcall SymbolsGroupsGet(const int index, ConSymbolGroup* group);
+   virtual int         __stdcall SymbolsGroupsSet(const int index, ConSymbolGroup* group);
+   //--- log access
+   virtual void        __stdcall LogsOut(const int code,LPCSTR ip,LPCSTR msg);
+   //--- client base access-you should use HEAP_FREE on resulted arrays
+   virtual int         __stdcall ClientsTotal(void);
+   virtual int         __stdcall ClientsAddUser(UserRecord *inf);
+   virtual int         __stdcall ClientsDeleteUser(const int login);
+   virtual int         __stdcall ClientsUserInfo(const int login,UserRecord *inf);
+   virtual int         __stdcall ClientsUserUpdate(const UserRecord *inf);
+   virtual int         __stdcall ClientsCheckPass(const int login,LPCSTR password,const int investor);
+   virtual int         __stdcall ClientsChangePass(const int login,LPCSTR password,const int change_investor,const int drop_key);
+   virtual int         __stdcall ClientsChangeBalance(const int login,const ConGroup *grp,const double value,LPCSTR comment);
+   virtual int         __stdcall ClientsChangeCredit(const int login,const ConGroup *grp,const double value,const time_t date,LPCSTR comment);
+   virtual UserRecord* __stdcall ClientsAllUsers(int *totalusers);
+   virtual UserRecord* __stdcall ClientsGroupsUsers(int *totalusers,LPCSTR groups);
+   //--- request base access
+   virtual int         __stdcall RequestsAdd(RequestInfo *request,const int isdemo,int *request_id);
+   virtual int         __stdcall RequestsGet(int *key,RequestInfo *req,const int maxreq);
+   virtual int         __stdcall RequestsFindObsolete(const int login,LPCSTR symbol,const int volume,double *prices,DWORD *ctm,int *manager);
+   virtual int         __stdcall RequestsPrices(const int id,const UserInfo *us,double *prices,const int in_stream);
+   virtual int         __stdcall RequestsConfirm(const int id,const UserInfo *us,double *prices);
+   virtual int         __stdcall RequestsRequote(const int id,const UserInfo *us,double *prices,const int in_stream);
+   virtual int         __stdcall RequestsReset(const int id,const UserInfo *us,const char flag);
+   //--- orders base access-you should use HEAP_FREE on resulted arrays
+   virtual int         __stdcall OrdersAdd(const TradeRecord *start,UserInfo* user,const ConSymbol *symb);
+   virtual int         __stdcall OrdersUpdate(TradeRecord *order,UserInfo* user,const int mode);
+   //---
+   virtual int         __stdcall OrdersGet(const int ticket,TradeRecord *order);
+   virtual TradeRecord*__stdcall OrdersGet(const time_t from,const time_t to,const int *logins,const int count,int* total);
+   virtual TradeRecord*__stdcall OrdersGetOpen(const UserInfo* user,int* total);
+   virtual TradeRecord*__stdcall OrdersGetClosed(const time_t from,const time_t to,const int *logins,const int count,int* total);
+   //--- trade info access
+   virtual int         __stdcall TradesCalcProfit(LPCSTR group,TradeRecord *tpi);
+   virtual int         __stdcall TradesMarginInfo(UserInfo *user,double *margin,double *freemargin,double *equity);
+   //--- history center access-you should use HEAP_FREE on resulted arrays
+   virtual void        __stdcall HistoryAddTick(FeedData *tick);
+   virtual int         __stdcall HistoryLastTicks(LPCSTR symbol,TickAPI *ticks,const int ticks_max);
+   virtual int         __stdcall HistoryPrices(LPCSTR symbol,double *prices,time_t *ctm,int *dir);
+   virtual int         __stdcall HistoryPricesGroup(LPCSTR symbol,const ConGroup *grp,double *prices);
+   virtual int         __stdcall HistoryPricesGroup(RequestInfo *request,double *prices);
+   virtual int         __stdcall HistoryUpdateObsolete(LPCSTR symbol,const int period,void *rt,const int total,const int updatemode);
+   virtual void*       __stdcall HistoryQuotesObsolete(LPCSTR symbol,const int period,int *count);
+   virtual void        __stdcall HistorySync(void);
+   //--- mail&news base access
+   virtual int          __stdcall MailSend(MailBoxHeader *mail,int *logins,const int total);
+   virtual int          __stdcall NewsSend(FeedData *feeddata);
+   //--- main server access
+   virtual void         __stdcall ServerRestart(void);
+   //--- daily base access-you should use HEAP_FREE on resulted arrays!
+   virtual DailyReport* __stdcall DailyGet(LPCSTR group,const time_t from,const time_t to,int* logins,const int logins_total,int *daily_total);
+   //--- select & free request from request queue
+   virtual int          __stdcall RequestsLock(const int id,const int manager);
+   virtual int          __stdcall RequestsFree(const int id,const int manager);
+   //--- check available margin
+   virtual double       __stdcall TradesMarginCheck(const UserInfo *user,const TradeTransInfo *trade,double *profit,double *freemargin,double *prev_margin);
+   //--- high level order operations
+   virtual int          __stdcall OrdersOpen(const TradeTransInfo *trans,UserInfo *user);
+   virtual int          __stdcall OrdersClose(const TradeTransInfo *trans,UserInfo *user);
+   virtual int          __stdcall OrdersCloseBy(const TradeTransInfo *trans,UserInfo *user);
+   //--- additional trade functions
+   virtual double       __stdcall TradesCalcRates(LPCSTR group,LPCSTR from,LPCSTR to);
+   virtual double       __stdcall TradesCalcConvertation(LPCSTR group,const int margin_mode,const double price,const ConSymbol *symbol);
+   virtual double       __stdcall TradesCommissionAgent(TradeRecord *trade,const ConSymbol *symbol,const UserInfo *user);
+   virtual void         __stdcall TradesCommission(TradeRecord *trade,LPCSTR group,const ConSymbol *symbol);
+   virtual int          __stdcall TradesFindLogin(const int order);
+   //--- special checks
+   virtual int          __stdcall TradesCheckSessions(const ConSymbol *symbol,const time_t ctm);
+   virtual int          __stdcall TradesCheckStops(const TradeTransInfo *trans,const ConSymbol *symbol,const ConGroup *group,const TradeRecord *trade);
+   virtual int          __stdcall TradesCheckFreezed(const ConSymbol *symbol,const ConGroup *group,const TradeRecord *trade);
+   virtual int          __stdcall TradesCheckSecurity(const ConSymbol *symbol,const ConGroup *group);
+   virtual int          __stdcall TradesCheckVolume(const TradeTransInfo *trans,const ConSymbol *symbol,const ConGroup *group,const int check_min);
+   virtual int          __stdcall TradesCheckTickSize(const double price,const ConSymbol *symbol);
+   //--- extension
+   virtual int         __stdcall  RequestsFind(const int login,LPCSTR symbol,const int volume,const UCHAR type,const UCHAR cmd,double *prices,DWORD *ctm,int *manager);
+   virtual int         __stdcall  HistoryUpdate(LPCSTR symbol,const int period,RateInfo *rt,const int total,const int updatemode);
+   virtual RateInfo*   __stdcall  HistoryQuotes(LPCSTR symbol,const int period,int *count);
+   //--- tick database access
+   virtual TickAPI*    __stdcall  HistoryTicksGet(LPCSTR symbol,const time_t from,const time_t to,const char ticks_flags,int* total);
+   //--- request server logs
+   virtual char*       __stdcall  LogsRequest(const LogRequest *request,int *size);
+   //--- check account's balance
+   virtual int         __stdcall  ClientsCheckBalance(const int login,int fix_flag,double* difference);
+   //--- request base access
+   virtual int         __stdcall  RequestsConfirmPrice(const int id,const UserInfo *us,double price,double *prices);
+   //--- check plugin license
+   virtual int         __stdcall  LicenseCheck(LPCSTR license_name);
+   //--- gateway account config access
+   virtual int         __stdcall GatewayAccountsAdd(ConGatewayAccount *cfg);
+   virtual int         __stdcall GatewayAccountsDelete(const int pos);
+   virtual int         __stdcall GatewayAccountsNext(const int pos, ConGatewayAccount *cfg);
+   virtual int         __stdcall GatewayAccountsShift(const int pos,const int shift);
+   //--- gateway account config markups
+   virtual int         __stdcall GatewayMarkupsAdd(ConGatewayMarkup *cfg);
+   virtual int         __stdcall GatewayMarkupsDelete(const int pos);
+   virtual int         __stdcall GatewayMarkupsNext(const int pos, ConGatewayMarkup *cfg);
+   virtual int         __stdcall GatewayMarkupsShift(const int pos,const int shift);
+   //--- gateway account config rules
+   virtual int         __stdcall GatewayRulesAdd(ConGatewayRule *cfg);
+   virtual int         __stdcall GatewayRulesDelete(const int pos);
+   virtual int         __stdcall GatewayRulesNext(const int pos, ConGatewayRule *cfg);
+   virtual int         __stdcall GatewayRulesShift(const int pos,const int shift);
+   //--- notifications
+   virtual int         __stdcall NotificationsSend(LPCWSTR metaquotes_ids,LPCWSTR message);
+   virtual int         __stdcall NotificationsSend(const int* logins,const UINT logins_total,LPCWSTR message);
+   //--- request base - delete request from queue by ID
+   virtual int         __stdcall RequestsDelete(const int id);
+   //--- trade info access with userinfo request
+   virtual int         __stdcall TradesMarginGet(const int login,UserInfo* user,double *margin,double *freemargin,double *equity);
+  };
+//+------------------------------------------------------------------+
+//| Function parameters enumerations                                 |
+//+------------------------------------------------------------------+
+//--- login types
+enum 
+  { 
+   LOGIN_FLAG_CLIENT  =0,
+   LOGIN_FLAG_MOBILE  =1,
+   LOGIN_FLAG_MULTI   =2,
+   LOGIN_FLAG_DC      =3, 
+   LOGIN_FLAG_ADMIN   =4, 
+   LOGIN_FLAG_MANAGER =5, 
+   LOGIN_FLAG_MANAPI  =6, 
+   LOGIN_FLAG_WD      =7, 
+   LOGIN_FLAG_PHONE   =8,
+   LOGIN_FLAG_WEB     =9,
+   LOGIN_FLAG_IPHONE  =10,
+   LOGIN_FLAG_ANDROID =11
+  };
+//--- avaible history periods enumeration
+enum { PERIOD_M1=1,PERIOD_M5=5,PERIOD_M15=15,PERIOD_M30=30,PERIOD_H1=60,PERIOD_H4=240,PERIOD_D1=1440,PERIOD_W1=10080,PERIOD_MN1=43200 };
+//--- history updating modes
+enum { HB_ADD,HB_UPDATE,HB_INSERT,HB_DELETE };
+//--- trade add modes
+enum { OPEN_NEW, OPEN_CLOSE, OPEN_RESTORE, OPEN_API, OPEN_ROLLOVER };
+//--- trade update modes
+enum { UPDATE_NORMAL, UPDATE_ACTIVATE, UPDATE_CLOSE, UPDATE_DELETE };
+//--- trade record state
+enum { TS_OPEN_NORMAL, TS_OPEN_REMAND, TS_OPEN_RESTORED, TS_CLOSED_NORMAL, TS_CLOSED_PART, TS_CLOSED_BY, TS_DELETED };
+//--- trade record reasons
+enum { TR_REASON_CLIENT, TR_REASON_EXPERT, TR_REASON_DEALER,TR_REASON_SIGNAL, TR_REASON_GATEWAY, TR_REASON_MOBILE, TR_REASON_WEB, TR_REASON_API };
+//--- ticks record flags
+enum { TICK_FLAG_RAW=1, TICK_FLAG_NORMAL=2 };
+//+------------------------------------------------------------------+
+//| MT Server API Hook Functions                                     |
+//+------------------------------------------------------------------+
+//+------------------------------------------------------------------+
+//| Plugin information                                               |
+//+------------------------------------------------------------------+
+void APIENTRY        MtSrvAbout(PluginInfo* info);
+int  APIENTRY        MtSrvStartup(CServerInterface *server);
+void APIENTRY        MtSrvCleanup(void);
+//+------------------------------------------------------------------+
+//| Plugin configuration                                             |
+//+------------------------------------------------------------------+
+int  APIENTRY        MtSrvPluginCfgSet(const PluginCfg *values,const int total);
+int  APIENTRY        MtSrvPluginCfgNext(const int index,PluginCfg *value);
+int  APIENTRY        MtSrvPluginCfgTotal();
+//+------------------------------------------------------------------+
+//| Auxiliary Server Hook Functions                                  |
+//+------------------------------------------------------------------+
+void APIENTRY        MtSrvLog(const LogInfo *info);
+void APIENTRY        MtSrvScheduler(const time_t curtime);
+void APIENTRY        MtSrvPerformance(const PerformanceInfo *inf);
+void APIENTRY        MtSrvService(const DWORD curtime);
+//+------------------------------------------------------------------+
+//| Client base Hook Functions                                       |
+//+------------------------------------------------------------------+
+int  APIENTRY        MtSrvUserConnect(const unsigned long ip,LPCSTR ipstring);
+int  APIENTRY        MtSrvUserLogin(const UserInfo *info);
+void APIENTRY        MtSrvUserLogout(const UserInfo *info,const UCHAR type);
+int  APIENTRY        MtSrvUserLoginExt(const UserInfo *info,const UCHAR type);
+int  APIENTRY        MtSrvUserDemo(UserRecord *info);
+int  APIENTRY        MtSrvUserCommand(const UserInfo *info,ULONG ip,const unsigned char command);
+int  APIENTRY        MtSrvUserChangePass(const UserInfo *info,LPCSTR password,const int change_investor);
+int  APIENTRY        MtSrvUserChangePassExt(const UserInfo *info,LPCSTR password,const int change_investor);
+void APIENTRY        MtSrvUserAdd(const    UserRecord *info);
+void APIENTRY        MtSrvUserUpdate(const UserRecord *info);
+void APIENTRY        MtSrvUserDelete(const UserRecord *info);
+int  APIENTRY        MtSrvUserArchive(const UserRecord *info,const ConGroup *group);
+void APIENTRY        MtSrvUserCompactDemo(const UserRecord *info);
+void APIENTRY        MtSrvUserCompactArchive(const UserRecord *info);
+void APIENTRY        MtSrvUserRestore(const UserRecord *info);
+int  APIENTRY        MtSrvUserInterestDaily(UserRecord *user,const ConGroup *group,const double freemargin);
+int  APIENTRY        MtSrvUserInterestMonth(UserRecord *user,const ConGroup *group);
+void APIENTRY        MtSrvUserFixBalance(const UserRecord  *user,const double prev_balance,const double new_balance);
+//+------------------------------------------------------------------+
+//| Datafeed Hook Functions                                          |
+//+------------------------------------------------------------------+
+void APIENTRY        MtSrvFeederData(const  ConFeeder *feed,FeedData *inf);
+int  APIENTRY        MtSrvFeederStart(const ConFeeder *feed);
+int  APIENTRY        MtSrvFeederCheck(const ConFeeder *feed,const DWORD curtime,const DWORD lasttime);
+void APIENTRY        MtSrvFeederStop(const  ConFeeder *feed);
+//+------------------------------------------------------------------+
+//| Configuration Hook Functions                                     |
+//+------------------------------------------------------------------+
+int  APIENTRY        MtSrvGroupsAdd(const ConGroup *group);
+int  APIENTRY        MtSrvGroupsDelete(const ConGroup *group);
+int  APIENTRY        MtSrvSymbolsAdd(const ConSymbol *symb);
+int  APIENTRY        MtSrvSymbolsDelete(const ConSymbol *symb);
+int  APIENTRY        MtSrvManagersAdd(const ConManager *man);
+int  APIENTRY        MtSrvManagersDelete(const ConManager *man);
+//+------------------------------------------------------------------+
+//| Trade activitiy Hook Functions                                   |
+//+------------------------------------------------------------------+
+int  APIENTRY        MtSrvTradeRequestFilter(RequestInfo *request,const int isdemo);
+void APIENTRY        MtSrvTradeRequestApply(RequestInfo *request,const int isdemo);
+void APIENTRY        MtSrvTradeRequestRestore(RequestInfo *request);
+int  APIENTRY        MtSrvTradeTransaction(TradeTransInfo* trans,const UserInfo *user,int *request_id);
+int  APIENTRY        MtSrvTradeCheckIE(TradeTransInfo* trans,const UserInfo *user,const ConSymbol *symbol,double *prices);
+int  APIENTRY        MtSrvTradeStopsFilter(const ConGroup *group,const ConSymbol *symbol,const TradeRecord *trade);
+int  APIENTRY        MtSrvTradeStopsApply(const UserInfo *user,const ConGroup *group,const ConSymbol *symbol,TradeRecord *trade,const int isTP);
+int  APIENTRY        MtSrvTradePendingsFilter(const ConGroup *group,const ConSymbol *symbol,const TradeRecord *trade);
+int  APIENTRY        MtSrvTradePendingsApply(const UserInfo *user,const ConGroup *group,const ConSymbol *symbol,const TradeRecord *pending,TradeRecord *trade);
+int  APIENTRY        MtSrvTradeStopoutsFilter(const ConGroup *group,const ConSymbol *symbol,const int login,const double equity,const double margin);
+int  APIENTRY        MtSrvTradeStopoutsApply(const UserInfo *user,const ConGroup *group,const ConSymbol *symbol,TradeRecord *stopout);
+void APIENTRY        MtSrvTradesAdd(TradeRecord *trade,const UserInfo *user,const ConSymbol *symb);
+void APIENTRY        MtSrvTradesAddExt(TradeRecord *trade,const UserInfo *user,const ConSymbol *symb,const int mode);
+void APIENTRY        MtSrvTradesAddRequest(TradeRecord *trade,const RequestInfo* request,const UserInfo *user,const ConSymbol *symb,const int mode);
+void APIENTRY        MtSrvTradesUpdate(TradeRecord *trade,UserInfo *user,const int mode);
+void APIENTRY        MtSrvTradesRestore(const TradeRecord *trade);
+void APIENTRY        MtSrvTradesCloseBy(TradeRecord *ftrade,TradeRecord *strade,TradeRecord *remaind,ConSymbol *sec,UserInfo *user);
+//+------------------------------------------------------------------+
+//| Commissions & rollover calculation Hook Functions                |
+//+------------------------------------------------------------------+
+void APIENTRY        MtSrvTradeCommission(TradeRecord *trade,const ConSymbol *sec,const ConGroup *grp);
+int  APIENTRY        MtSrvTradeCommissionAgent(TradeRecord *trade,const ConSymbol *sec,const UserInfo* user);
+int  APIENTRY        MtSrvTradeRollover(TradeRecord *trade,const double value,const OverNightData *data);
+//+------------------------------------------------------------------+
+//| Statements generation Hook Functions                             |
+//+------------------------------------------------------------------+
+void APIENTRY        MtSrvStatementsBaseAll(const int month_state,const GroupState *groups,const int groups_total,const DailyReport *reports,const int reports_total);
+void APIENTRY        MtSrvStatementsUser(const int month_state,const UserRecord *user,const ConGroup *group,TradeRecord *first_trade,TradeRecord *last_trade,StateReport *state);
+void APIENTRY        MtSrvStatementsRollovers(const int month_state,const time_t ctm,const tm *ttm);
+//+------------------------------------------------------------------+
+//| Dealer activity Hook Functions                                   |
+//+------------------------------------------------------------------+
+int  APIENTRY        MtSrvDealerConnect(const ConManager *manager);
+void APIENTRY        MtSrvDealerDisconnect(const ConManager *manager);
+int  APIENTRY        MtSrvDealerGet(const ConManager *manager,const RequestInfo *request);
+int  APIENTRY        MtSrvDealerPrice(const int id,const UserInfo *us,double *prices,const int in_stream);
+int  APIENTRY        MtSrvDealerConfirm(const int id,const UserInfo *us,double *prices);
+int  APIENTRY        MtSrvDealerRequote(const int id,const UserInfo *us,double *prices,const int in_stream);
+int  APIENTRY        MtSrvDealerReset(const int id,const UserInfo *us,const char flag);
+int  APIENTRY        MtSrvDealerClientReject(const int id,const UserInfo *us);
+//+------------------------------------------------------------------+
+//| Chart history, ticks filtration                                  |
+//+------------------------------------------------------------------+
+int  APIENTRY        MtSrvHistoryTickFilter(const ConSymbol *symbol,FeedTick *inf);
+void APIENTRY        MtSrvHistoryTickApply(const ConSymbol *symbol,FeedTick *inf);
+int  APIENTRY        MtSrvHistoryCheck(const ConSymbol *symbol,RateInfo *rates,int *total);
+//+------------------------------------------------------------------+
+//| Internal mail & News Hook Functions                              |
+//+------------------------------------------------------------------+
+int  APIENTRY        MtSrvNewsCheck(FeedData *inf);
+int  APIENTRY        MtSrvNewsCheckNew(const int feeder,FeedNews *inf);
+int  APIENTRY        MtSrvMailCheck(MailBoxHeader *mail,int *logins,const int total);
+//+------------------------------------------------------------------+
+//| Protocol extension Hook functions                                |
+//+------------------------------------------------------------------+
+int   APIENTRY       MtSrvTelnet(const ULONG ip,char *buf,const int maxlen);
+char* APIENTRY       MtSrvTelnetExt(const ULONG ip,char *buf,int* data_len);
+int   APIENTRY       MtSrvManagerProtocol(const ULONG ip,const UserInfo *us,const unsigned char *in_data,const int in_size,unsigned char **out_data,int *out_size);
+//+------------------------------------------------------------------+
+//| Result codes                                                     |
+//+------------------------------------------------------------------+
+enum
+  {
+   //--- common errors
+   RET_OK                =0,    // all OK
+   RET_OK_NONE,                 // all OK-no operation
+   RET_ERROR,                   // general error
+   RET_INVALID_DATA,            // invalid data
+   RET_TECH_PROBLEM,            // server technical problem
+   RET_OLD_VERSION,             // old client terminal
+   RET_NO_CONNECT,              // no connection
+   RET_NOT_ENOUGH_RIGHTS,       // no enough rights
+   RET_TOO_FREQUENT,            // too frequently access to server
+   RET_MALFUNCTION,             // mulfunctional operation
+   RET_GENERATE_KEY,            // need key generation
+   RET_SECURITY_SESSION,        // securied session authorization
+
+   //--- account status
+   RET_ACCOUNT_DISABLED  =64,   // account blocked
+   RET_BAD_ACCOUNT_INFO,        // bad account info
+   RET_PUBLIC_KEY_MISSING,      // need public key
+   //--- trade
+   RET_TRADE_TIMEOUT     =128,  // trade transatcion timeou expired
+   RET_TRADE_BAD_PRICES,        // order has wrong prices
+   RET_TRADE_BAD_STOPS,         // wrong stops level
+   RET_TRADE_BAD_VOLUME,        // wrong lot size
+   RET_TRADE_MARKET_CLOSED,     // market closed
+   RET_TRADE_DISABLE,           // trade disabled
+   RET_TRADE_NO_MONEY,          // no enough money for order execution
+   RET_TRADE_PRICE_CHANGED,     // price changed
+   RET_TRADE_OFFQUOTES,         // no quotes
+   RET_TRADE_BROKER_BUSY,       // broker is busy
+   RET_TRADE_REQUOTE,           // requote
+   RET_TRADE_ORDER_LOCKED,      // order is proceed by dealer and cannot be changed
+   RET_TRADE_LONG_ONLY,         // allowed only BUY orders
+   RET_TRADE_TOO_MANY_REQ,      // too many requests from one client
+   //--- order status notification
+   RET_TRADE_ACCEPTED,          // trade request accepted by server and placed in request queue
+   RET_TRADE_PROCESS,           // trade request accepted by dealerd
+   RET_TRADE_USER_CANCEL,       // trade request canceled by client
+   //---                       
+   RET_TRADE_MODIFY_DENIED,     // modification denied because order too close to market
+   RET_TRADE_CONTEXT_BUSY,      // trade context busy (for client terminal only)
+   RET_TRADE_EXPIRATION_DENIED, // expiration specifieng is denied
+   RET_TRADE_TOO_MANY_ORDERS,   // too many orders
+   RET_TRADE_HEDGE_PROHIBITED,  // hedge is prohibited
+   RET_TRADE_PROHIBITED_BY_FIFO // prohibited by fifo rule
+  };
+//+------------------------------------------------------------------+