139 lines
No EOL
4.2 KiB
MQL5
139 lines
No EOL
4.2 KiB
MQL5
#ifndef LIB_MQLPLUS_MQL4_COMPATIBILITY_GENERIC_MQH_INCLUDED
|
|
#define LIB_MQLPLUS_MQL4_COMPATIBILITY_GENERIC_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 additions
|
|
//
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| MQL4: MQL5-compatible Bars() |
|
|
//+------------------------------------------------------------------+
|
|
/*
|
|
const int mt5_Bars(const string symbol, const ENUM_TIMEFRAMES timeframe, const datetime start_time = NULL, const datetime stop_time = NULL)
|
|
{
|
|
if( (symbol != _Symbol)
|
|
|| (timeframe != _Period)
|
|
|| (start_time != NULL)
|
|
|| (stop_time != NULL) )
|
|
{
|
|
// Needs implementation //
|
|
printf("Function not implemented: %s", __FUNCTION__);
|
|
return(NULL);
|
|
}
|
|
|
|
// Return
|
|
return(Bars);
|
|
}
|
|
#define Bars mt5_Bars
|
|
*/
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| MQL4: MQL5-compatible Digits() |
|
|
//+------------------------------------------------------------------+
|
|
/*
|
|
const int mt5_Digits()
|
|
{ return(_Digits); }
|
|
#define Digits mt5_Digits
|
|
*/
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| MQL4: MQL5-compatible Period() |
|
|
//+------------------------------------------------------------------+
|
|
const ENUM_TIMEFRAMES mt5_Period()
|
|
{ return((ENUM_TIMEFRAMES)Period()); }
|
|
#define Period mt5_Period
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| MQL4: MQL5-compatible TimeTradeServer() |
|
|
//+------------------------------------------------------------------+
|
|
const datetime TimeTradeServer(MqlDateTime& dt_struct)
|
|
{
|
|
const datetime srv_tm = TimeTradeServer();
|
|
TimeToStruct(srv_tm, dt_struct);
|
|
return(srv_tm);
|
|
}
|
|
|
|
datetime TimeTradeServer()
|
|
{ return(TimeCurrent()); }
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| MQL4: MQL5-compatible SymbolExist() |
|
|
//+------------------------------------------------------------------+
|
|
const bool SymbolExist(const string symbol, bool& is_custom)
|
|
{
|
|
// Static cache init
|
|
|
|
static union chr_ul { uchar uc[8]; ulong ul; } conv;
|
|
const static int max = SymbolsTotal(false);
|
|
static bool is_init = false;
|
|
static ulong symbol_db[];
|
|
|
|
|
|
// Initialize search db
|
|
|
|
if(!is_init)
|
|
{
|
|
ArrayResize(symbol_db, max);
|
|
for(int cnt = NULL; (cnt < max) && !_StopFlag; cnt++)
|
|
{
|
|
StringToCharArray(SymbolName(cnt, false), conv.uc, NULL, 8);
|
|
symbol_db[cnt] = conv.ul;
|
|
}
|
|
ArraySort(symbol_db);
|
|
is_init = true;
|
|
}
|
|
|
|
|
|
// Find symbol
|
|
|
|
is_custom = false;
|
|
StringToCharArray(symbol, conv.uc, NULL, 8);
|
|
|
|
// Return
|
|
return(symbol_db[ArrayBsearch(symbol_db, conv.ul)] == conv.ul);
|
|
}
|
|
|
|
|
|
|
|
//
|
|
// END MQL compatibility */
|
|
//*********************************************************************************************************************************************************/
|
|
#endif // LIB_MQLPLUS_MQL4_COMPATIBILITY_GENERIC_MQH_INCLUDED |