Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.002-dev-new #743

Open
wants to merge 76 commits into
base: v3.001-dev-new
Choose a base branch
from
Open
Changes from 5 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
28bc1e9
Account/SymbolInfo: Adds copy constructors
kenorb Dec 5, 2021
3871dd8
Adds Exchange class and tests
kenorb Dec 5, 2021
3f09d09
Exchange: Adds Trade
kenorb Dec 5, 2021
92bb334
SymbolInfo: Adds class constructor with symbol properties
kenorb Dec 5, 2021
78323e0
Exchange: Adds methods to add/remove account and symbol
kenorb Dec 5, 2021
a94b5c4
SymbolInfo: SymbolInfoEntry: Fixes struct copy constructor
kenorb Dec 8, 2021
35af70c
Merge pull request #621 from EA31337/dev-exchange
kenorb Jan 15, 2022
af586ee
Moves Deal enums to Deal.enum.h
kenorb Jan 17, 2022
f6fb496
Moves enums and structs from Std and MQL5 to appropriate files
kenorb Jan 17, 2022
19a1a84
Adds .extern.h files
kenorb Jan 18, 2022
79e542c
Adds code page defines
kenorb Jan 18, 2022
df9180d
Adds Common and File defines
kenorb Jan 18, 2022
a70c358
Integrates extern includes
kenorb Jan 18, 2022
c3bb151
Refs: Uses PTR_ATTRIB syntax
kenorb Jan 18, 2022
fde05e4
Adds .extern.h file for DateTime
kenorb Jan 18, 2022
471e417
Adds StringSplit() as extern
kenorb Jan 18, 2022
f2142ea
Adds Compile workflow for CPP
kenorb Jan 18, 2022
e17381a
GHA: Compiles based on the file list
kenorb Jan 18, 2022
0b8be3b
Adds TradeSignal and TradeSignalManager C++ compilation tests
kenorb Jan 18, 2022
8826b3d
Trade: Fixes C++ compilation errors
kenorb Jan 18, 2022
1dc8803
Making MQL code to compile in C++. Especially the TradeSignalManager.…
nseam Jan 19, 2022
57af000
Merge pull request #634 from nseam/dev-indicator-refactor
kenorb Jan 19, 2022
1c8a2ed
State in the art of MQL/C++ compatibility.
nseam Jan 20, 2022
98f7b4e
Working compilation via GCC for TradeSignal.test.cpp and TradeSignalM…
nseam Jan 21, 2022
abf3b60
Merge pull request #636 from EA31337/dev-indicator-refactor
kenorb Jan 23, 2022
8d1e4a5
Should fix all GCC warnings.
nseam Jan 24, 2022
e76c4e5
Merge pull request #637 from nseam/dev-cpp
kenorb Jan 24, 2022
208de59
Merge remote-tracking branch 'origin/dev-cpp' into dev-v2011
kenorb Jan 25, 2022
afb673c
Should fix new issues with C++ compatibility.
nseam Jan 26, 2022
4355ade
Merge pull request #640 from nseam/dev-cpp
kenorb Jan 26, 2022
dc609ad
Merge branch 'dev-account' into dev-v2011
kenorb Jan 30, 2022
118347d
Merge tag 'v2.010' into dev-v2011
kenorb Mar 24, 2022
e61fe6c
CPP: Removes EnumToString
kenorb Mar 24, 2022
3a77d0a
Refs #337 New week detection. Added check if it's the first day of th…
nseam Apr 22, 2022
66f4342
Refactors IndicatorData class to be inherited by Indicator class
kenorb May 29, 2022
cb29a33
Splits IndicatorParams struct into IndicatorDataParams
kenorb Jun 19, 2022
2e47d5c
Indicator: Moves GetValuePrice() to IndicatorData
kenorb Jun 19, 2022
b550609
Merge pull request #650 from nseam/dev
kenorb Jun 26, 2022
17373a5
Moves indicator data related methods to IndicatorData
kenorb Jun 26, 2022
b010f5d
Indicators: Adds Indicator source type and mode to constructor's argu…
kenorb Jun 26, 2022
b26dfa5
Fixes timeframe handling
kenorb Jun 27, 2022
78a0fbd
Merge pull request #642 from EA31337/dev-v2011
kenorb Jul 2, 2022
3cdadf9
Should fix problem "'array' - constant variable cannot be passed [GH-…
nseam Dec 6, 2022
9fb1008
Refs EA31337-classes/EA31337-indicators-other#13, EA31337-classes/EA3…
nseam Dec 1, 2023
42d1880
Merge tag 'v2.011' into v3.002-dev-new
kenorb Apr 24, 2024
b847600
GHA: Fixes workflow test for Exchange using new format
kenorb Apr 24, 2024
d907ae9
GHA: Compile: Adds support for path input
kenorb Apr 24, 2024
8f3c6e9
GHA: Compile: Adds support for skip_init input
kenorb Apr 24, 2024
d32799f
GHA: Clean-up platform artifacts after the test
kenorb Apr 24, 2024
ac96c48
GHA: Compile: Fixes wrong path on missing inputs
kenorb Apr 24, 2024
5439c88
Merge branch 'v3.001-dev-new' into v3.002-dev-new
kenorb Apr 24, 2024
998d55a
GHA: Compile: Fixes init-platform boolean condition
kenorb Apr 24, 2024
6d417d6
GHA: Compile: Fixes init-platform boolean condition
kenorb Apr 24, 2024
65aa9b2
Fixes C++ const-related errors.
nseam Nov 30, 2022
7adfaf4
GHA: Compile: Fixes init-platform condition to compare with string, n…
kenorb Apr 24, 2024
f1445fb
GHA: Compile: Fixes init-platform condition to compare with string, n…
kenorb Apr 24, 2024
483bd03
Merge tag 'v2.011.1' into v3.002-dev-new
kenorb Apr 24, 2024
112b49e
Merge remote-tracking branch 'nseam/v3.000-dev' into v3.001-dev-new
kenorb Apr 24, 2024
1b9a596
Merge branch 'v3.001-dev-new' into v3.002-dev-new
kenorb Apr 24, 2024
69b6ae1
GHA: Exchange: Adds path
kenorb Apr 25, 2024
92450aa
Account/AccountMt: Fixes zero division
kenorb Feb 19, 2022
bf75e6d
EA: Fixes recent issue with error during trade request
kenorb Jul 25, 2022
0bfc38d
Trade: Disables filling modes for MQL4
kenorb Jul 25, 2022
b4e2393
Order: Refresh order after modification
kenorb Jul 21, 2023
136ab98
Order: Fixes the current volume value when data in orequest is missing
kenorb Jul 21, 2023
c363605
Trade: TradeParams: Adds max_spread
kenorb Jul 22, 2022
71089fc
Workaround for closing order conditions after orders are loaded from …
kenorb Aug 12, 2023
7ca1f82
Merge branch 'v3.001-dev-new' into v3.002-dev-new
kenorb Apr 25, 2024
460891f
Trade: Disables filling modes for MQL4
kenorb Jul 25, 2022
b14a877
GHA: Fixes compilation workflows
kenorb Feb 18, 2024
0d00fcb
GHA: Compile: Skips clean-up by default
kenorb Apr 23, 2024
31708c9
GHA: Compile: Support for workflow calls
kenorb Apr 23, 2024
35a2814
Account/AccountMt: Fixes zero division
kenorb Feb 19, 2022
01934b4
Merge tag 'v3.000.2' into v3.002-dev-new
kenorb Apr 25, 2024
efa612e
Merge remote-tracking branch 'origin/v3.001-dev-new' into v3.002-dev-new
kenorb Apr 27, 2024
03bf8a8
IndicatorData: Adds Set()
kenorb Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Account.struct.h
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ class Serializer;

// Includes.
#include "Serializer.mqh"
#include "Terminal.define.h"

// Struct for account entries.
struct AccountEntry {
38 changes: 32 additions & 6 deletions Array.extern.h
Original file line number Diff line number Diff line change
@@ -22,10 +22,36 @@

// Define external global functions.
#ifndef __MQL__
extern int ArrayInitialize();
extern int ArrayResize(void& array[], int new_size, int reserve_size = 0);
extern bool ArrayReverse();
extern bool ArraySetAsSeries(const void& array[], bool flag);
extern int ArraySize(const void& array[]);
extern bool ArraySort(void& array[]);
#pragma once

template <typename T>
extern int ArraySize(const ARRAY_REF(T, _array));

template <typename T, int size>
extern constexpr int ArraySize(const T REF(_array)[size]);

template <typename T>
extern int ArrayResize(ARRAY_REF(T, _array), int _new_size, int _reserve_size = 0);

template <typename T>
extern bool ArraySetAsSeries(ARRAY_REF(T, _array), bool _flag);

template <typename T>
extern int ArrayMaximum(const ARRAY_REF(T, _array), int _start = 0, unsigned int _count = WHOLE_ARRAY);

template <typename T>
extern int ArrayMinimum(const ARRAY_REF(T, _array), int _start = 0, unsigned int _count = WHOLE_ARRAY);

template <typename T>
extern int ArrayFree(const ARRAY_REF(T, _array));

template <typename T>
extern int ArrayReverse(const ARRAY_REF(T, _array));

template <typename T>
extern int ArrayInitialize(ARRAY_REF(T, array), char value);

template <typename T>
extern int ArraySort(ARRAY_REF(T, array));

#endif
7 changes: 4 additions & 3 deletions Array.mqh
Original file line number Diff line number Diff line change
@@ -27,10 +27,11 @@

// Includes.
#include "Array.extern.h"
#include "Convert.extern.h"
#include "Common.extern.h"
#include "Convert.extern.h"
#include "Math.extern.h"
#include "Std.h"
#include "String.extern.h"

// Defines.
#ifndef MODE_ASCEND
@@ -533,7 +534,7 @@ static int GetLowestArrDoubleValue(double& arr[][], int key) {
*/
template <typename T>
void ArrayPrint(ARRAY_REF(T, _arr), // Printed array.
int _digits = 0, // Number of decimal places.
int _digits = 0, // Number of decimal places.
const string _dlm = NULL, // Separator of the structure field values.
long _start = 0, // First printed element index.
long _count = WHOLE_ARRAY, // Number of printed elements.
@@ -543,7 +544,7 @@ static int GetLowestArrDoubleValue(double& arr[][], int key) {
#else
int i;
string output = "";
for (i = _start; i < _count == WHOLE_ARRAY ? ArraySize(_arr) : _count; i++) {
for (i = _start; i < (_count == WHOLE_ARRAY ? ArraySize(_arr) : _count); i++) {
output += (string)_arr[i] + _dlm;
}
Print(output);
1 change: 1 addition & 0 deletions Chart.struct.tf.h
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@

// Includes.
#include "Chart.enum.h"
#include "Terminal.define.h"

/* Defines struct for chart timeframe. */
struct ChartTf {
2 changes: 1 addition & 1 deletion Common.define.h
Original file line number Diff line number Diff line change
@@ -26,10 +26,10 @@
*/
#ifndef __MQL__
// Data types.
#include <string>
typedef std::string string;
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long datetime;
typedef unsigned long ulong;
typedef unsigned short ushort;
#endif
23 changes: 16 additions & 7 deletions Common.extern.h
Original file line number Diff line number Diff line change
@@ -22,17 +22,26 @@

// Define external global functions.
#ifndef __MQL__
#pragma once
#include "Chart.enum.h"
#include "DateTime.enum.h"

extern void DebugBreak();
// Errors.
extern void SetUserError(ushort user_error);
// Exceptions.
extern int NotImplementedException();
// Print-related functions.
extern void Alert(string arg1);
extern void Alert(string arg1, string arg2);
template <typename T>
extern void Print(T arg);
template <typename T1, typename T2>
extern void Print(T1 arg1, T2 arg2);
extern void PrintFormat(string format_string, ...);
template <typename... Args>
extern std::string StringFormat(const std::string& format, Args... args);

template <typename... Args>
extern std::string PrintFormat(const std::string& format, Args... args);

template <typename... Args>
extern void Print(Args... args);

template <typename... Args>
extern void Alert(Args... args);

#endif
6 changes: 3 additions & 3 deletions Condition.mqh
Original file line number Diff line number Diff line change
@@ -109,13 +109,13 @@ class Condition {
if (_entry.IsActive()) {
switch (_entry.next_statement) {
case COND_AND:
_curr_result = _prev_result && this.Test(_entry);
_curr_result = _prev_result && this PTR_DEREF Test(_entry);
break;
case COND_OR:
_curr_result = _prev_result || this.Test(_entry);
_curr_result = _prev_result || this PTR_DEREF Test(_entry);
break;
case COND_SEQ:
_curr_result = this.Test(_entry);
_curr_result = this PTR_DEREF Test(_entry);
if (!_curr_result) {
// Do not check further conditions when the current condition is false.
return false;
17 changes: 9 additions & 8 deletions Convert.mqh
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
#include "Account.extern.h"
#include "Array.mqh"
#include "Convert.extern.h"
#include "Math.extern.h"
#include "Order.enum.h"
#include "SymbolInfo.enum.h"
#include "SymbolInfo.extern.h"
@@ -66,7 +67,7 @@ class Convert {
case ORDER_TYPE_BUY_STOP:
return ORDER_TYPE_BUY;
default:
return (ENUM_ORDER_TYPE)-1;
return InvalidEnumValue<ENUM_ORDER_TYPE>::value();
}
}

@@ -81,7 +82,7 @@ class Convert {
* Returns OP_BUY when value is positive, OP_SELL when negative, otherwise -1.
*/
static ENUM_ORDER_TYPE ValueToOp(int value) {
return value == 0 ? (ENUM_ORDER_TYPE)-1 : (value > 0 ? ORDER_TYPE_BUY : ORDER_TYPE_SELL);
return value == 0 ? InvalidEnumValue<ENUM_ORDER_TYPE>::value() : (value > 0 ? ORDER_TYPE_BUY : ORDER_TYPE_SELL);
}

/**
@@ -95,13 +96,13 @@ class Convert {
* Returns OP_BUY when value is positive, OP_SELL when negative, otherwise -1.
*/
static ENUM_ORDER_TYPE ValueToOp(double value) {
return value == 0 ? (ENUM_ORDER_TYPE)-1 : (value > 0 ? ORDER_TYPE_BUY : ORDER_TYPE_SELL);
return value == 0 ? InvalidEnumValue<ENUM_ORDER_TYPE>::value() : (value > 0 ? ORDER_TYPE_BUY : ORDER_TYPE_SELL);
}

/**
* Points per pip given digits after decimal point of a symbol price.
*/
static uint PointsPerPip(uint digits) { return (uint)pow(10, digits - (digits < 4 ? 2 : 4)); }
static uint PointsPerPip(uint digits) { return (uint)pow((unsigned int)10, digits - (digits < 4 ? 2 : 4)); }

/**
* Returns number of points per pip.
@@ -180,19 +181,19 @@ class Convert {
switch (mode) {
case 0: // Forex.
// In currencies a tick is a point.
return pts * SymbolInfoStatic::SymbolInfoDouble(_symbol, SYMBOL_TRADE_TICK_SIZE);
return (double)pts * SymbolInfoStatic::SymbolInfoDouble(_symbol, SYMBOL_TRADE_TICK_SIZE);
case 1: // CFD.
// In metals a Tick is still the smallest change, but is larger than a point.
// If price can change from 123.25 to 123.50,
// you have a TickSize of 0.25 and a point of 0.01. Pip has no meaning.
// @todo
return pts * SymbolInfoStatic::SymbolInfoDouble(_symbol, SYMBOL_TRADE_TICK_SIZE);
return (double)pts * SymbolInfoStatic::SymbolInfoDouble(_symbol, SYMBOL_TRADE_TICK_SIZE);
case 2: // Futures.
// @todo
return pts * SymbolInfoStatic::SymbolInfoDouble(_symbol, SYMBOL_TRADE_TICK_SIZE);
return (double)pts * SymbolInfoStatic::SymbolInfoDouble(_symbol, SYMBOL_TRADE_TICK_SIZE);
case 3: // CFD for indices.
// @todo
return pts * SymbolInfoStatic::SymbolInfoDouble(_symbol, SYMBOL_TRADE_TICK_SIZE);
return (double)pts * SymbolInfoStatic::SymbolInfoDouble(_symbol, SYMBOL_TRADE_TICK_SIZE);
}
return false;
}
47 changes: 47 additions & 0 deletions DateTime.extern.h
Original file line number Diff line number Diff line change
@@ -28,5 +28,52 @@
* Includes external declarations related to date and time.
*/
#ifndef __MQL__
#pragma once
// Forward declarations.
struct MqlDateTime;

/**
* MQL's "datetime" type.
*/
class datetime {
time_t dt;

public:
datetime();
datetime(const long& _time);
datetime(const int& _time);
bool operator==(const int& _time) const;
bool operator==(const datetime& _time) const;
bool operator<(const int& _time) const;
bool operator>(const int& _time) const;
bool operator<(const datetime& _time);
bool operator>(const datetime& _time);
operator long() const;
};

extern datetime TimeCurrent();
extern datetime TimeCurrent(MqlDateTime& dt_struct);

extern int CopyTime(string symbol_name, ENUM_TIMEFRAMES timeframe, int start_pos, int count,
ARRAY_REF(datetime, time_array));

extern int CopyTime(string symbol_name, ENUM_TIMEFRAMES timeframe, datetime start_time, int count,
ARRAY_REF(datetime, time_array));

extern int CopyTime(string symbol_name, ENUM_TIMEFRAMES timeframe, datetime start_time, datetime stop_time,
ARRAY_REF(datetime, time_array));

extern datetime StructToTime(MqlDateTime& dt_struct);
extern bool TimeToStruct(datetime dt, MqlDateTime& dt_struct);
extern datetime TimeGMT();
extern datetime TimeGMT(MqlDateTime& dt_struct);
extern datetime TimeTradeServer();
extern datetime TimeTradeServer(MqlDateTime& dt_struct);
extern datetime StringToTime(const string& value);
extern string TimeToString(datetime value, int mode = TIME_DATE | TIME_MINUTES);

template <char... T>
extern datetime operator"" _D();

#define DATETIME_LITERAL(STR) _D " ## STR ## "
#endif
21 changes: 21 additions & 0 deletions Dict.enum.h
Original file line number Diff line number Diff line change
@@ -32,3 +32,24 @@

#define DICT_GROW_UP_PERCENT_DEFAULT 25
#define DICT_PERFORMANCE_PROBLEM_AVG_CONFLICTS 10

/**
* Whether Dict operates in yet uknown mode, as dict or as list.
*/
enum DictMode { DictModeUnknown, DictModeDict, DictModeList };

/**
* Reason of call to overflow listener.
*/
enum ENUM_DICT_OVERFLOW_REASON {
DICT_OVERFLOW_REASON_FULL,
DICT_OVERFLOW_REASON_TOO_MANY_CONFLICTS,
};

/**
* Dictionary flags.
*/
enum ENUM_DICT_FLAG {
DICT_FLAG_NONE = 0,
DICT_FLAG_FILL_HOLES_UNSORTED = 1,
};
1 change: 1 addition & 0 deletions Dict.mqh
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
#include "DictBase.mqh"
#include "Matrix.mqh"
#include "Serializer.mqh"
#include "SerializerNodeIterator.mqh"

template <typename K, typename V>
class DictIterator : public DictIteratorBase<K, V> {
29 changes: 4 additions & 25 deletions DictBase.mqh
Original file line number Diff line number Diff line change
@@ -31,27 +31,6 @@
#include "DictSlot.mqh"
#include "Serializer.mqh"

/**
* Whether Dict operates in yet uknown mode, as dict or as list.
*/
enum DictMode { DictModeUnknown, DictModeDict, DictModeList };

/**
* Reason of call to overflow listener.
*/
enum ENUM_DICT_OVERFLOW_REASON {
DICT_OVERFLOW_REASON_FULL,
DICT_OVERFLOW_REASON_TOO_MANY_CONFLICTS,
};

/**
* Dictionary flags.
*/
enum ENUM_DICT_FLAG {
DICT_FLAG_NONE = 0,
DICT_FLAG_FILL_HOLES_UNSORTED = 1,
};

/**
* Dictionary overflow listener. arguments are:
* - ENUM_DICT_OVERFLOW_REASON overflow_reason
@@ -225,7 +204,7 @@ class DictBase {

if (_DictSlots_ref.DictSlots[position].IsUsed()) {
if (GetMode() == DictModeList) {
_should_be_removed = position == (int)key;
_should_be_removed = position == (unsigned int)key;
} else {
_should_be_removed =
_DictSlots_ref.DictSlots[position].HasKey() && _DictSlots_ref.DictSlots[position].key == key;
@@ -262,7 +241,7 @@ class DictBase {
*/
void FillHoleUnsorted(int _hole_slot_idx) {
// After moving last element to fill the hole we
if (_hole_slot_idx == Size() - 1) {
if ((unsigned int)_hole_slot_idx == Size() - 1) {
// We've just removed last element, thus don't need to do anything.
} else {
// Moving last slot into given one.
@@ -361,10 +340,10 @@ class DictBase {
* Specialization of hashing function.
*/
unsigned int Hash(const string& x) {
unsigned char c[];
ARRAY(unsigned char, c);
unsigned int h = 0;

if (x != NULL) {
if (!IsNull(x)) {
h = 5381;
int n = StringToCharArray(x, c);
for (int i = 0; i < n; i++) {
Loading