204 lines
14 KiB
MQL5
204 lines
14 KiB
MQL5
|
#ifndef LIB_MQLPLUS_MQL4_COMPATIBILITY_MQL5_BACKPORT_MQH_INCLUDED
|
||
|
#define LIB_MQLPLUS_MQL4_COMPATIBILITY_MQL5_BACKPORT_MQH_INCLUDED
|
||
|
#property version "1.0";
|
||
|
#property strict
|
||
|
/**********************************************************************************
|
||
|
* Copyright (C) 2010-2022 Dominik Egert <info@freie-netze.de>
|
||
|
*
|
||
|
* This file is the MQL4 backward compatibility include file.
|
||
|
*
|
||
|
* MQLplus, including this file may not be copied and/or distributed
|
||
|
* without explecit permit by the author.
|
||
|
* Author Dominik Egert / Freie Netze UG.
|
||
|
**********************************************************************************
|
||
|
*
|
||
|
* Version: 1.0
|
||
|
* State: development
|
||
|
*
|
||
|
* File information
|
||
|
* ================
|
||
|
*
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
#ifdef DBG_MSG_TRACE_FILE_LOADER
|
||
|
DBG_MSG_TRACE_FILE_LOADER;
|
||
|
|
||
|
#endif
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
//*********************************************************************************************************************************************************/
|
||
|
//
|
||
|
// BEGIN MQL4 compatibility MQL5 Calendar Backport
|
||
|
//
|
||
|
|
||
|
/////////////////////////////////////////////////
|
||
|
//
|
||
|
// MQL5 Economic calendar definitions
|
||
|
//
|
||
|
|
||
|
#define ENUM_CALENDAR_EVENT_FREQUENCY mql4_backport_ENUM_CALENDAR_EVENT_FREQUENCY
|
||
|
#define ENUM_CALENDAR_EVENT_TYPE mql4_backport_ENUM_CALENDAR_EVENT_TYPE
|
||
|
#define ENUM_CALENDAR_EVENT_SECTOR mql4_backport_ENUM_CALENDAR_EVENT_SECTOR
|
||
|
#define ENUM_CALENDAR_EVENT_IMPORTANCE mql4_backport_ENUM_CALENDAR_EVENT_IMPORTANCE
|
||
|
#define ENUM_CALENDAR_EVENT_UNIT mql4_backport_ENUM_CALENDAR_EVENT_UNIT
|
||
|
#define ENUM_CALENDAR_EVENT_MULTIPLIER mql4_backport_ENUM_CALENDAR_EVENT_MULTIPLIER
|
||
|
#define ENUM_CALENDAR_EVENT_IMPACT mql4_backport_ENUM_CALENDAR_EVENT_IMPACT
|
||
|
#define ENUM_CALENDAR_EVENT_TIMEMODE mql4_backport_ENUM_CALENDAR_EVENT_TIMEMODE
|
||
|
|
||
|
|
||
|
// Enumerations
|
||
|
enum ENUM_CALENDAR_EVENT_FREQUENCY
|
||
|
{
|
||
|
CALENDAR_FREQUENCY_NONE = 0x00, // Release frequency is not set
|
||
|
CALENDAR_FREQUENCY_WEEK = 0x01, // Released once a week
|
||
|
CALENDAR_FREQUENCY_MONTH = 0x02, // Released once a month
|
||
|
CALENDAR_FREQUENCY_QUARTER = 0x03, // Released once a quarter
|
||
|
CALENDAR_FREQUENCY_YEAR = 0x04, // Released once a year
|
||
|
CALENDAR_FREQUENCY_DAY = 0x05 // Released once a day
|
||
|
};
|
||
|
|
||
|
enum ENUM_CALENDAR_EVENT_TYPE
|
||
|
{
|
||
|
CALENDAR_TYPE_EVENT = 0x00, // Event (meeting, speech, etc.)
|
||
|
CALENDAR_TYPE_INDICATOR = 0x01, // Indicator
|
||
|
CALENDAR_TYPE_HOLIDAY = 0x02 // Holiday
|
||
|
};
|
||
|
|
||
|
enum ENUM_CALENDAR_EVENT_SECTOR
|
||
|
{
|
||
|
CALENDAR_SECTOR_NONE = 0x00, // Sector is not set
|
||
|
CALENDAR_SECTOR_MARKET = 0x01, // Market, exchange
|
||
|
CALENDAR_SECTOR_GDP = 0x02, // Gross Domestic Product (GDP)
|
||
|
CALENDAR_SECTOR_JOBS = 0x03, // Labor market
|
||
|
CALENDAR_SECTOR_PRICES = 0x04, // Prices
|
||
|
CALENDAR_SECTOR_MONEY = 0x05, // Money
|
||
|
CALENDAR_SECTOR_TRADE = 0x06, // Trading
|
||
|
CALENDAR_SECTOR_GOVERNMENT = 0x07, // Government
|
||
|
CALENDAR_SECTOR_BUSINESS = 0x08, // Business
|
||
|
CALENDAR_SECTOR_CONSUMER = 0x09, // Consumption
|
||
|
CALENDAR_SECTOR_HOUSING = 0x0A, // Housing
|
||
|
CALENDAR_SECTOR_TAXES = 0x0B, // Taxes
|
||
|
CALENDAR_SECTOR_HOLIDAYS = 0x0C // Holidays
|
||
|
};
|
||
|
|
||
|
enum ENUM_CALENDAR_EVENT_IMPORTANCE
|
||
|
{
|
||
|
CALENDAR_IMPORTANCE_NONE = 0x00, // Importance is not set
|
||
|
CALENDAR_IMPORTANCE_LOW = 0x01, // Low importance
|
||
|
CALENDAR_IMPORTANCE_MODERATE = 0x02, // Medium importance
|
||
|
CALENDAR_IMPORTANCE_HIGH = 0x03 // High importance
|
||
|
};
|
||
|
|
||
|
enum ENUM_CALENDAR_EVENT_UNIT
|
||
|
{
|
||
|
CALENDAR_UNIT_NONE = 0x00, // Measurement unit is not set
|
||
|
CALENDAR_UNIT_PERCENT = 0x01, // Percentage
|
||
|
CALENDAR_UNIT_CURRENCY = 0x02, // National currency
|
||
|
CALENDAR_UNIT_HOUR = 0x03, // Hours
|
||
|
CALENDAR_UNIT_JOB = 0x04, // Jobs
|
||
|
CALENDAR_UNIT_RIG = 0x05, // Drilling rigs
|
||
|
CALENDAR_UNIT_USD = 0x06, // USD
|
||
|
CALENDAR_UNIT_PEOPLE = 0x07, // People
|
||
|
CALENDAR_UNIT_MORTGAGE = 0x08, // Mortgage loans
|
||
|
CALENDAR_UNIT_VOTE = 0x09, // Votes
|
||
|
CALENDAR_UNIT_BARREL = 0x0A, // Barrels
|
||
|
CALENDAR_UNIT_CUBICFEET = 0x0B, // Cubic feet
|
||
|
CALENDAR_UNIT_POSITION = 0x0C, // Non-commercial net positions
|
||
|
CALENDAR_UNIT_BUILDING = 0x0D // Buildings
|
||
|
};
|
||
|
|
||
|
enum ENUM_CALENDAR_EVENT_MULTIPLIER
|
||
|
{
|
||
|
CALENDAR_MULTIPLIER_NONE = 0x00, // Multiplier is not set
|
||
|
CALENDAR_MULTIPLIER_THOUSANDS = 0x01, // Thousands
|
||
|
CALENDAR_MULTIPLIER_MILLIONS = 0x02, // Millions
|
||
|
CALENDAR_MULTIPLIER_BILLIONS = 0x03, // Billions
|
||
|
CALENDAR_MULTIPLIER_TRILLIONS = 0x04 // Trillions
|
||
|
};
|
||
|
|
||
|
enum ENUM_CALENDAR_EVENT_IMPACT
|
||
|
{
|
||
|
CALENDAR_IMPACT_NA = 0x00, // Impact is not set
|
||
|
CALENDAR_IMPACT_POSITIVE = 0x01, // Positive impact
|
||
|
CALENDAR_IMPACT_NEGATIVE = 0x02 // Negative impact
|
||
|
};
|
||
|
|
||
|
enum ENUM_CALENDAR_EVENT_TIMEMODE
|
||
|
{
|
||
|
CALENDAR_TIMEMODE_DATETIME = 0x00, // Source publishes an exact time of an event
|
||
|
CALENDAR_TIMEMODE_DATE = 0x01, // Event takes all day
|
||
|
CALENDAR_TIMEMODE_NOTIME = 0x02, // Source publishes no time of an event
|
||
|
CALENDAR_TIMEMODE_TENTATIVE = 0x03 // Source publishes a day of an event rather than its exact time. The time is specified upon the occurrence of the event.
|
||
|
};
|
||
|
|
||
|
|
||
|
// Structures
|
||
|
struct MqlCalendarCountry
|
||
|
{
|
||
|
ulong id; // country ID (ISO 3166-1)
|
||
|
string name; // country text name (in the current terminal encoding)
|
||
|
string code; // country code name (ISO 3166-1 alpha-2)
|
||
|
string currency; // country currency code
|
||
|
string currency_symbol; // country currency symbol
|
||
|
string url_name; // country name used in the mql5.com website URL
|
||
|
};
|
||
|
|
||
|
|
||
|
struct MqlCalendarEvent
|
||
|
{
|
||
|
ulong id; // event ID
|
||
|
ENUM_CALENDAR_EVENT_TYPE type; // event type from the ENUM_CALENDAR_EVENT_TYPE enumeration
|
||
|
ENUM_CALENDAR_EVENT_SECTOR sector; // sector an event is related to
|
||
|
ENUM_CALENDAR_EVENT_FREQUENCY frequency; // event frequency
|
||
|
ENUM_CALENDAR_EVENT_TIMEMODE time_mode; // event time mode
|
||
|
ulong country_id; // country ID
|
||
|
ENUM_CALENDAR_EVENT_UNIT unit; // economic indicator value's unit of measure
|
||
|
ENUM_CALENDAR_EVENT_IMPORTANCE importance; // event importance
|
||
|
ENUM_CALENDAR_EVENT_MULTIPLIER multiplier; // economic indicator value multiplier
|
||
|
uint digits; // number of decimal places
|
||
|
string source_url; // URL of a source where an event is published
|
||
|
string event_code; // event code
|
||
|
string name; // event text name in the terminal language (in the current terminal encoding)
|
||
|
};
|
||
|
|
||
|
#ifndef DBL_NAN
|
||
|
static const union __MqlCalendarValue_dbl_conv_dbl_nan { const double d; const ulong ul; __MqlCalendarValue_dbl_conv_dbl_nan() : ul(0x7FF8000000000001) {}; } __mql4_calendar_dbl_nan;
|
||
|
#define DBL_NAN __mql4_calendar_dbl_nan.d
|
||
|
|
||
|
#endif
|
||
|
|
||
|
struct MqlCalendarValue
|
||
|
{
|
||
|
ulong id; // value ID
|
||
|
ulong event_id; // event ID
|
||
|
datetime time; // event date and time
|
||
|
datetime period; // event reporting period
|
||
|
int revision; // revision of the published indicator relative to the reporting period
|
||
|
long actual_value; // actual value multiplied by 10^6 or LONG_MIN if the value is not set
|
||
|
long prev_value; // previous value multiplied by 10^6 or LONG_MIN if the value is not set
|
||
|
long revised_prev_value; // revised previous value multiplied by 10^6 or LONG_MIN if the value is not set
|
||
|
long forecast_value; // forecast value multiplied by 10^6 or LONG_MIN if the value is not set
|
||
|
ENUM_CALENDAR_EVENT_IMPACT impact_type; // potential impact on the currency rate
|
||
|
|
||
|
//--- functions checking the values
|
||
|
bool HasActualValue(void) const { return(actual_value != LONG_MIN); } // returns true if actual_value is set
|
||
|
bool HasPreviousValue(void) const { return(prev_value != LONG_MIN); } // returns true if prev_value is set
|
||
|
bool HasRevisedValue(void) const { return(revised_prev_value != LONG_MIN); } // returns true if revised_prev_value is set
|
||
|
bool HasForecastValue(void) const { return(forecast_value != LONG_MIN); } // returns true if forecast_value is set
|
||
|
|
||
|
//--- functions receiving the values
|
||
|
double GetActualValue(void) const { return((actual_value != LONG_MIN) ? (actual_value / 1000000.0) : DBL_NAN); } // returns actual_value or nan if the value is no set
|
||
|
double GetPreviousValue(void) const { return((prev_value != LONG_MIN) ? (prev_value / 1000000.0) : DBL_NAN); } // returns prev_value or nan if the value is no set
|
||
|
double GetRevisedValue(void) const { return((revised_prev_value != LONG_MIN) ? (revised_prev_value / 1000000.0) : DBL_NAN); } // returns revised_prev_value or nan if the value is no set
|
||
|
double GetForecastValue(void) const { return((forecast_value != LONG_MIN) ? (forecast_value / 1000000.0) : DBL_NAN); } // returns forecast_value or nan if the value is no set
|
||
|
};
|
||
|
|
||
|
#undef DBL_NAN;
|
||
|
|
||
|
//
|
||
|
// END MQL compatibility */
|
||
|
//*********************************************************************************************************************************************************/
|
||
|
#endif // LIB_MQLPLUS_MQL4_COMPATIBILITY_MQL5_BACKPORT_MQH_INCLUDED
|