diff --git a/3D/Chart3DCandles.h b/3D/Chart3DCandles.h index 9f1cc40b9..ea421b0e5 100644 --- a/3D/Chart3DCandles.h +++ b/3D/Chart3DCandles.h @@ -25,6 +25,7 @@ * 3D chart candles renderer. */ +#include "../Chart.define.h" #include "Chart3DType.h" #include "Cube.h" #include "Device.h" diff --git a/3D/Mesh.h b/3D/Mesh.h index 0ee82c0dc..719b33aff 100644 --- a/3D/Mesh.h +++ b/3D/Mesh.h @@ -45,8 +45,13 @@ struct PointEntry { T point; long key; + // Default constructor. PointEntry() {} + // Copy constructor. + PointEntry(const PointEntry& 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); diff --git a/3D/Vertex.h b/3D/Vertex.h index 8466fa312..f9b84851e 100644 --- a/3D/Vertex.h +++ b/3D/Vertex.h @@ -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]; diff --git a/Account/Account.struct.h b/Account/Account.struct.h index efae51d51..4d90c2a94 100644 --- a/Account/Account.struct.h +++ b/Account/Account.struct.h @@ -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) { diff --git a/BufferFXT.mqh b/BufferFXT.mqh index 61a372f85..a60dc0c02 100644 --- a/BufferFXT.mqh +++ b/BufferFXT.mqh @@ -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; diff --git a/BufferStruct.mqh b/BufferStruct.mqh index 216a9f15a..a43c06074 100644 --- a/BufferStruct.mqh +++ b/BufferStruct.mqh @@ -64,7 +64,7 @@ class BufferStruct : public DictStruct { * 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); } diff --git a/Chart.struct.h b/Chart.struct.h index a4100f935..e0c04a219 100644 --- a/Chart.struct.h +++ b/Chart.struct.h @@ -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()); } diff --git a/Database.mqh b/Database.mqh index 2a4bcc82b..80571651c 100644 --- a/Database.mqh +++ b/Database.mqh @@ -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(); } diff --git a/DateTime.entry.h b/DateTime.entry.h index c99d8d27f..539ec5a45 100644 --- a/DateTime.entry.h +++ b/DateTime.entry.h @@ -33,6 +33,7 @@ // Includes. #include "DateTime.static.h" #include "PlatformTime.h" +#include "Std.h" struct DateTimeEntry : MqlDateTime { int week_of_year; diff --git a/Indicators/Indi_RSI.mqh b/Indicators/Indi_RSI.mqh index 3b401778e..5aacd6181 100644 --- a/Indicators/Indi_RSI.mqh +++ b/Indicators/Indi_RSI.mqh @@ -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) {} }; /** diff --git a/Strategy.mqh b/Strategy.mqh index d52f5168a..961808aa7 100644 --- a/Strategy.mqh +++ b/Strategy.mqh @@ -259,7 +259,7 @@ class Strategy : public Taskable { * 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); } @@ -988,9 +988,10 @@ class Strategy : public Taskable { 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 |= diff --git a/Strategy.struct.h b/Strategy.struct.h index 5c4eef27f..19dce3bcd 100644 --- a/Strategy.struct.h +++ b/Strategy.struct.h @@ -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(), diff --git a/tests/DatabaseTest.mq5 b/tests/DatabaseTest.mq5 index c37b969c9..2cbc81ddf 100644 --- a/tests/DatabaseTest.mq5 +++ b/tests/DatabaseTest.mq5 @@ -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);