Skip to content

Commit

Permalink
Fixed C++ and MQL5 errors for tests in /tests folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
nseam committed Feb 2, 2023
1 parent 88108ce commit 17cd38a
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 17 deletions.
1 change: 1 addition & 0 deletions 3D/Chart3DCandles.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* 3D chart candles renderer.
*/

#include "../Chart.define.h"
#include "Chart3DType.h"
#include "Cube.h"
#include "Device.h"
Expand Down
5 changes: 5 additions & 0 deletions 3D/Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ struct PointEntry {
T point;
long key;

// Default constructor.
PointEntry() {}

// Copy constructor.
PointEntry(const PointEntry<T>& r) : point(r.point), key(r.key) {}

// Constructor.
PointEntry(const T& _point) {
point = _point;
key = MakeKey(_point.Position.x, _point.Position.y, _point.Position.z);
Expand Down
17 changes: 12 additions & 5 deletions 3D/Vertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ struct Vertex {
DXVector3 Normal;
DXColor Color;

Vertex() {
Color.r = 1.0f;
Color.g = 1.0f;
Color.b = 1.0f;
Color.a = 1.0f;
// Default constructor.
Vertex(float r = 1, float g = 1, float b = 1, float a = 1) {
Color.r = r;
Color.g = g;
Color.b = b;
Color.a = a;
}

Vertex(const Vertex &r) {
Position = r.Position;
Normal = r.Normal;
Color = r.Color;
}

static const ShaderVertexLayout Layout[3];
Expand Down
15 changes: 15 additions & 0 deletions Account/Account.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ struct AccountEntry {
double margin_used;
double margin_free;
double margin_avail;

// Default constructor.
AccountEntry() {}

// Constructor.
AccountEntry(const AccountEntry& r)
: dtime(r.dtime),
balance(r.balance),
credit(r.credit),
equity(r.equity),
profit(r.profit),
margin_used(r.margin_used),
margin_free(r.margin_free),
margin_avail(r.margin_avail) {}

// Serializers.
void SerializeStub(int _n1 = 1, int _n2 = 1, int _n3 = 1, int _n4 = 1, int _n5 = 1) {}
SerializerNodeType Serialize(Serializer& _s) {
Expand Down
14 changes: 14 additions & 0 deletions BufferFXT.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ struct BufferFXTEntry {
int flag; // Flag to launch an expert (0 - bar will be modified, but the expert will not be launched).

public:
// Default constructor
BufferFXTEntry() {}

// Copy constructor
BufferFXTEntry(const BufferFXTEntry &r)
: otm(r.otm),
open(r.open),
high(r.high),
low(r.low),
close(r.close),
volume(r.volume),
ctm(r.ctm),
flag(r.flag) {}

bool operator==(const BufferFXTEntry &_s) {
// @fixme
return false;
Expand Down
2 changes: 1 addition & 1 deletion BufferStruct.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BufferStruct : public DictStruct<long, TStruct> {
* Constructor.
*/
BufferStruct() : min(INT_MAX), max(INT_MIN) { THIS_ATTR SetOverflowListener(BufferStructOverflowListener, 10); }
BufferStruct(BufferStruct& _right) : min(INT_MAX), max(INT_MIN) {
BufferStruct(const BufferStruct& _right) : min(INT_MAX), max(INT_MIN) {
this = _right;
THIS_ATTR SetOverflowListener(BufferStructOverflowListener, 10);
}
Expand Down
1 change: 1 addition & 0 deletions Chart.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct ChartEntry {
// Constructors.
ChartEntry() {}
ChartEntry(const BarEntry& _bar) { SetBar(_bar); }
ChartEntry(const ChartEntry& _r) { SetBar(_r.bar); }
// Getters.
BarEntry GetBar() { return bar; }
string ToCSV() { return StringFormat("%s", bar.ToCSV()); }
Expand Down
1 change: 1 addition & 0 deletions Database.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ struct DbSymbolInfoEntry : public SymbolInfoEntry {
DatabaseTableSchema schema;
// Constructors.
DbSymbolInfoEntry() { DefineSchema(); }
DbSymbolInfoEntry(const DbSymbolInfoEntry &r) { schema = r.schema; }
DbSymbolInfoEntry(const MqlTick &_tick, const string _symbol = NULL) : SymbolInfoEntry(_tick, _symbol) {
DefineSchema();
}
Expand Down
1 change: 1 addition & 0 deletions DateTime.entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
// Includes.
#include "DateTime.static.h"
#include "PlatformTime.h"
#include "Std.h"

struct DateTimeEntry : MqlDateTime {
int week_of_year;
Expand Down
5 changes: 5 additions & 0 deletions Indicators/Indi_RSI.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ struct IndiRSIParams : IndicatorParams {
struct RSIGainLossData {
double avg_gain;
double avg_loss;
// Default constructor.
RSIGainLossData() {}

// Copy constructor.
RSIGainLossData(const RSIGainLossData &r) : avg_gain(r.avg_gain), avg_loss(r.avg_loss) {}
};

/**
Expand Down
9 changes: 5 additions & 4 deletions Strategy.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class Strategy : public Taskable<DataParamEntry> {
* Gets strategy entry.
*/
StgEntry GetEntry() {
StgEntry _entry = {};
StgEntry _entry;
for (ENUM_STRATEGY_STATS_PERIOD _p = EA_STATS_DAILY; _p < FINAL_ENUM_STRATEGY_STATS_PERIOD; _p++) {
_entry.SetStats(stats_period[(int)_p], _p);
}
Expand Down Expand Up @@ -988,9 +988,10 @@ class Strategy : public Taskable<DataParamEntry> {
if (METHOD(_method, 1)) _result |= _result || !IsTrend(_cmd); // 2
if (METHOD(_method, 2)) _result |= _result || !trade REF_DEREF IsPivot(_cmd); // 4
if (METHOD(_method, 3))
_result |= _result || Open[_shift] > High[_shift + 1] || Open[_shift] < Low[_shift + 1]; // 8
if (METHOD(_method, 4)) _result |= _result || trade REF_DEREF IsPeak(_cmd); // 16
if (METHOD(_method, 5)) _result |= _result || trade REF_DEREF HasOrderBetter(_cmd); // 32
_result |= _result || iOpen(Symbol(), PERIOD_CURRENT, _shift) > iHigh(Symbol(), PERIOD_CURRENT, _shift + 1) ||
iOpen(Symbol(), PERIOD_CURRENT, _shift) < iLow(Symbol(), PERIOD_CURRENT, _shift + 1); // 8
if (METHOD(_method, 4)) _result |= _result || trade REF_DEREF IsPeak(_cmd); // 16
if (METHOD(_method, 5)) _result |= _result || trade REF_DEREF HasOrderBetter(_cmd); // 32
/*
if (METHOD(_method, 6))
_result |=
Expand Down
9 changes: 9 additions & 0 deletions Strategy.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,15 @@ struct StgStatsPeriod {
struct StgEntry {
unsigned short signals;
StgStatsPeriod stats_period[FINAL_ENUM_STRATEGY_STATS_PERIOD];
// Default constructor.
StgEntry() {}

// Copy constructor.
StgEntry(const StgEntry &r) : signals(r.signals) {
for (int i = 0; i < FINAL_ENUM_STRATEGY_STATS_PERIOD; ++i) {
stats_period[i] = r.stats_period[i];
}
}
string ToCSV() {
return StringFormat("%s,%s,%s,%s", stats_period[(int)EA_STATS_DAILY].ToCSV(),
stats_period[(int)EA_STATS_WEEKLY].ToCSV(), stats_period[(int)EA_STATS_MONTHLY].ToCSV(),
Expand Down
14 changes: 7 additions & 7 deletions tests/DatabaseTest.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ int OnInit() {
db = new Database(":memory:", DATABASE_OPEN_MEMORY);

// Create Table1 table.
DatabaseTableColumnEntry columns[] = {
{"SYMBOL", TYPE_CHAR, DATABASE_COLUMN_FLAG_NONE, 6},
{"BID", TYPE_DOUBLE},
{"ASK", TYPE_DOUBLE},
{"VOLUME", TYPE_INT, DATABASE_COLUMN_FLAG_IS_NULL},
{"COMMENT", TYPE_STRING, DATABASE_COLUMN_FLAG_IS_NULL},
};
ARRAY(DatabaseTableColumnEntry, columns);
ArrayPushObject(columns, DatabaseTableColumnEntry("SYMBOL", TYPE_CHAR, DATABASE_COLUMN_FLAG_NONE, 6));
ArrayPushObject(columns, DatabaseTableColumnEntry("BID", TYPE_DOUBLE));
ArrayPushObject(columns, DatabaseTableColumnEntry("ASK", TYPE_DOUBLE));
ArrayPushObject(columns, DatabaseTableColumnEntry("VOLUME", TYPE_INT, DATABASE_COLUMN_FLAG_IS_NULL));
ArrayPushObject(columns, DatabaseTableColumnEntry("COMMENT", TYPE_STRING, DATABASE_COLUMN_FLAG_IS_NULL));

DatabaseTableSchema schema = columns;
assertTrueOrFail(db.CreateTable("Table1", schema), "Cannot create table! Error: " + (string)_LastError);
DatabasePrint(db.GetHandle(), "PRAGMA TABLE_INFO(Table1);", 0);
Expand Down

0 comments on commit 17cd38a

Please sign in to comment.