Skip to content

Commit

Permalink
WIP. Refactoring of MQL code to be compatible with C++.
Browse files Browse the repository at this point in the history
  • Loading branch information
nseam committed May 29, 2021
1 parent 081bab5 commit 1083060
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
14 changes: 7 additions & 7 deletions Array.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Array {
}

template <typename T>
static int ArrayCopy( T REF(dst_array)[], const T REF(src_array)[], const int dst_start = 0, const int src_start = 0, const int count = WHOLE_ARRAY);
static int ArrayCopy(ARRAY_REF(T, dst_array), const ARRAY_REF(T, src_array), const int dst_start = 0, const int src_start = 0, const int count = WHOLE_ARRAY);

/**
* Return plain text of array values separated by the delimiter.
Expand All @@ -116,7 +116,7 @@ class Array {
* int arr[] - array to look for the values
* string sep - delimiter to separate array values
*/
static string GetArrayValues(int REF(arr)[], string sep = ", ") {
static string GetArrayValues(ARRAY_REF(int, arr), string sep = ", ") {
int i;
string result = "";
for (i = 0; i < ArraySize(arr); i++) {
Expand All @@ -133,7 +133,7 @@ class Array {
* double arr[] - array to look for the values
* string sep - delimiter to separate array values
*/
static string GetArrayValues(double REF(arr)[], string sep = ", ") {
static string GetArrayValues(ARRAY_REF(double, arr), string sep = ", ") {
int i;
string result = "";
for (i = 0; i < ArraySize(arr); i++) {
Expand All @@ -146,14 +146,14 @@ class Array {
/**
* Find lower value within the 1-dim array of floats.
*/
static double LowestArrValue(double REF(arr)[]) {
static double LowestArrValue(ARRAY_REF(double, arr)) {
return (arr[ArrayMinimum(arr)]);
}

/**
* Find higher value within the 1-dim array of floats.
*/
static double HighestArrValue(double REF(arr)[]) {
static double HighestArrValue(ARRAY_REF(double, arr)) {
return (arr[ArrayMaximum(arr)]);
}

Expand Down Expand Up @@ -732,7 +732,7 @@ class Array {
* - https://www.mql5.com/en/docs/array/arraymaximum
*/
template <typename X>
static int ArrayMaximum(const X REF(array)[], int start = 0, int count = WHOLE_ARRAY) {
static int ArrayMaximum(const ARRAY_REF(X, array), int start = 0, int count = WHOLE_ARRAY) {
#ifdef __MQLBUILD__
return ::ArrayMaximum(array);
#else
Expand All @@ -755,7 +755,7 @@ class Array {
* - https://www.mql5.com/en/docs/array/arraysize
*/
template <typename X>
static int ArraySize(const X REF(array)[]) {
static int ArraySize(const ARRAY_REF(X, array)) {
#ifdef __MQLBUILD__
return ::ArraySize(array);
#else
Expand Down
4 changes: 3 additions & 1 deletion Chart.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
class Class;

// Includes.
#include "Array.mqh"
#include "Bar.struct.h"
#include "Chart.define.h"
#include "Chart.enum.h"
Expand Down Expand Up @@ -217,7 +218,8 @@ struct ChartStatic {
return ::iBarShift(_symbol, _tf, _time, _exact);
#else // __MQL5__
if (_time < 0) return (-1);
ARRAY(datetime, arr), _time0;
ARRAY(datetime, arr);
datetime _time0;
// ENUM_TIMEFRAMES _tf = MQL4::TFMigrate(_tf);
CopyTime(_symbol, _tf, 0, 1, arr);
_time0 = arr[0];
Expand Down
4 changes: 3 additions & 1 deletion String.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#ifndef STRING_MQH
#define STRING_MQH

#include "Array.mqh"

// Defines.
#define NL "\n" // New line: 0x0A (MQL file functions auto-convert 0x0A to 0x0D0A).
#define TAB "\t" // Tab: 0x09.
Expand All @@ -33,7 +35,7 @@
*/
class String {
protected:
string strings[];
ARRAY(string, strings);
string dlm;

public:
Expand Down

0 comments on commit 1083060

Please sign in to comment.