From 4154ad7f030d8b4d60670a2c5f8005fee83c3808 Mon Sep 17 00:00:00 2001 From: kenorb Date: Wed, 6 Oct 2021 15:07:17 +0100 Subject: [PATCH] Renames Condition to TaskCondition --- .github/workflows/test.yml | 2 - Action.mqh | 2 +- Chart.mqh | 2 +- Condition.struct.h | 111 ------------------ EA.mqh | 2 +- Market.mqh | 2 +- Task/Task.h | 4 +- Task/Task.struct.h | 22 ++-- Condition.enum.h => Task/TaskCondition.enum.h | 8 +- Condition.mqh => Task/TaskCondition.h | 60 +++++----- Task/TaskCondition.struct.h | 111 ++++++++++++++++++ Task/tests/Task.test.mq5 | 2 +- .../tests/TaskCondition.test.mq4 | 4 +- .../tests/TaskCondition.test.mq5 | 36 +++--- Trade.mqh | 2 +- tests/CompileTest.mq5 | 2 +- 16 files changed, 185 insertions(+), 187 deletions(-) delete mode 100644 Condition.struct.h rename Condition.enum.h => Task/TaskCondition.enum.h (98%) rename Condition.mqh => Task/TaskCondition.h (85%) create mode 100644 Task/TaskCondition.struct.h rename tests/ConditionTest.mq4 => Task/tests/TaskCondition.test.mq4 (92%) rename tests/ConditionTest.mq5 => Task/tests/TaskCondition.test.mq5 (77%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a222d90a5..de9a7ccec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,7 +45,6 @@ jobs: - BufferTest - ChartTest - CompileIndicatorsTest - - ConditionTest - DatabaseTest # - DrawIndicatorTest - EATest @@ -62,7 +61,6 @@ jobs: - StrategyTest-RSI - SymbolInfoTest - SummaryReportTest - - TaskTest - TickerTest - TradeTest steps: diff --git a/Action.mqh b/Action.mqh index 65dc92f3b..92696c6de 100644 --- a/Action.mqh +++ b/Action.mqh @@ -35,8 +35,8 @@ class Action; // Includes. #include "Action.enum.h" #include "Action.struct.h" -#include "Condition.enum.h" #include "EA.mqh" +#include "Task/TaskCondition.enum.h" /** * Action class. diff --git a/Chart.mqh b/Chart.mqh index f8786e046..b366f1f18 100644 --- a/Chart.mqh +++ b/Chart.mqh @@ -42,10 +42,10 @@ class Market; #include "Chart.enum.h" #include "Chart.struct.h" #include "Chart.struct.serialize.h" -#include "Condition.enum.h" #include "Convert.mqh" #include "Market.mqh" #include "Serializer.mqh" +#include "Task/TaskCondition.enum.h" #ifndef __MQL4__ // Defines structs (for MQL4 backward compatibility). diff --git a/Condition.struct.h b/Condition.struct.h deleted file mode 100644 index ba536e9d4..000000000 --- a/Condition.struct.h +++ /dev/null @@ -1,111 +0,0 @@ -//+------------------------------------------------------------------+ -//| EA31337 framework | -//| Copyright 2016-2021, EA31337 Ltd | -//| https://github.com/EA31337 | -//+------------------------------------------------------------------+ - -/* - * This file is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * @file - * Includes Condition's structs. - */ - -#ifndef __MQL__ -// Allows the preprocessor to include a header file when it is needed. -#pragma once -#endif - -// Includes. -#include "Account/Account.enum.h" -#include "Chart.enum.h" -#include "DateTime.enum.h" -#include "EA.enum.h" -#include "Indicator.enum.h" -//#include "Market.enum.h" -#include "Order.enum.h" -#include "Strategy.enum.h" -#include "Task/Task.enum.h" -#include "Trade.enum.h" - -struct ConditionEntry { - unsigned char flags; // Condition flags. - datetime last_check; // Time of the latest check. - datetime last_success; // Time of the last success. - int frequency; // How often to check. - long cond_id; // Condition ID. - short tries; // Number of successful tries left. - void *obj; // Reference to associated object. - ENUM_CONDITION_STATEMENT next_statement; // Statement type of the next condition. - ENUM_CONDITION_TYPE type; // Condition type. - DataParamEntry args[]; // Condition arguments. - // Constructors. - void ConditionEntry() : type(FINAL_CONDITION_TYPE_ENTRY), cond_id(WRONG_VALUE) { Init(); } - void ConditionEntry(long _cond_id, ENUM_CONDITION_TYPE _type) : type(_type), cond_id(_cond_id) { Init(); } - void ConditionEntry(ConditionEntry &_ce) { this = _ce; } - void ConditionEntry(ENUM_ACCOUNT_CONDITION _cond_id) : type(COND_TYPE_ACCOUNT), cond_id(_cond_id) { Init(); } - void ConditionEntry(ENUM_CHART_CONDITION _cond_id) : type(COND_TYPE_CHART), cond_id(_cond_id) { Init(); } - void ConditionEntry(ENUM_DATETIME_CONDITION _cond_id) : type(COND_TYPE_DATETIME), cond_id(_cond_id) { Init(); } - void ConditionEntry(ENUM_EA_CONDITION _cond_id) : type(COND_TYPE_EA), cond_id(_cond_id) { Init(); } - void ConditionEntry(ENUM_INDICATOR_CONDITION _cond_id) : type(COND_TYPE_INDICATOR), cond_id(_cond_id) { Init(); } - void ConditionEntry(ENUM_MARKET_CONDITION _cond_id) : type(COND_TYPE_MARKET), cond_id(_cond_id) { Init(); } - void ConditionEntry(ENUM_ORDER_CONDITION _cond_id) : type(COND_TYPE_ORDER), cond_id(_cond_id) { Init(); } - void ConditionEntry(ENUM_STRATEGY_CONDITION _cond_id) : type(COND_TYPE_STRATEGY), cond_id(_cond_id) { Init(); } - void ConditionEntry(ENUM_TASK_CONDITION _cond_id) : type(COND_TYPE_TASK), cond_id(_cond_id) { Init(); } - void ConditionEntry(ENUM_TRADE_CONDITION _cond_id) : type(COND_TYPE_TRADE), cond_id(_cond_id) { Init(); } - // Deconstructor. - void ~ConditionEntry() { - // Object::Delete(obj); - } - // Flag methods. - bool HasFlag(unsigned char _flag) { return bool(flags & _flag); } - void AddFlags(unsigned char _flags) { flags |= _flags; } - void RemoveFlags(unsigned char _flags) { flags &= ~_flags; } - void SetFlag(ENUM_CONDITION_ENTRY_FLAGS _flag, bool _value) { - if (_value) - AddFlags(_flag); - else - RemoveFlags(_flag); - } - void SetFlags(unsigned char _flags) { flags = _flags; } - // State methods. - bool IsActive() { return HasFlag(COND_ENTRY_FLAG_IS_ACTIVE); } - bool IsExpired() { return HasFlag(COND_ENTRY_FLAG_IS_EXPIRED); } - bool IsReady() { return HasFlag(COND_ENTRY_FLAG_IS_READY); } - bool IsInvalid() { return HasFlag(COND_ENTRY_FLAG_IS_INVALID); } - bool IsValid() { return !IsInvalid(); } - // Getters. - long GetId() { return cond_id; } - ENUM_CONDITION_TYPE GetType() { return type; } - // Setters. - void AddArg(MqlParam &_arg) { - // @todo: Add another value to args[]. - } - void Init() { - flags = COND_ENTRY_FLAG_NONE; - frequency = 60; - SetFlag(COND_ENTRY_FLAG_IS_ACTIVE, cond_id != WRONG_VALUE); - SetFlag(COND_ENTRY_FLAG_IS_INVALID, cond_id == WRONG_VALUE); - last_check = last_success = 0; - next_statement = COND_AND; - tries = 1; - } - void SetArgs(MqlParam &_args[]) { - // @todo: for(). - } - void SetObject(void *_obj) { obj = _obj; } - void SetTries(short _count) { tries = _count; } -}; diff --git a/EA.mqh b/EA.mqh index 31f0282ba..588324794 100644 --- a/EA.mqh +++ b/EA.mqh @@ -32,7 +32,6 @@ // Includes. #include "Action.enum.h" #include "Chart.mqh" -#include "Condition.enum.h" #include "Data.struct.h" #include "Dict.mqh" #include "DictObject.mqh" @@ -47,6 +46,7 @@ #include "Strategy.mqh" #include "SummaryReport.mqh" #include "Task/Task.h" +#include "Task/TaskCondition.enum.h" #include "Terminal.mqh" #include "Trade.mqh" #include "Trade/TradeSignal.h" diff --git a/Market.mqh b/Market.mqh index bca614aaf..7f99b2646 100644 --- a/Market.mqh +++ b/Market.mqh @@ -29,12 +29,12 @@ class Market; class SymbolInfo; // Includes. -#include "Condition.enum.h" #include "Market.struct.h" #include "Math.h" #include "Order.mqh" #include "Serializer.mqh" #include "SymbolInfo.mqh" +#include "Task/TaskCondition.enum.h" // Structs. // Market info. diff --git a/Task/Task.h b/Task/Task.h index 96152ec9a..2c41e2ead 100644 --- a/Task/Task.h +++ b/Task/Task.h @@ -31,9 +31,9 @@ // Includes. #include "../Action.mqh" -#include "../Condition.mqh" #include "../DictStruct.mqh" #include "../Refs.mqh" +#include "../Task/TaskCondition.h" #include "Task.enum.h" #include "Task.struct.h" @@ -98,7 +98,7 @@ class Task { static bool Process(TaskEntry &_entry) { bool _result = false; if (_entry.IsActive()) { - if (Condition::Test(_entry.GetCondition())) { + if (TaskCondition::Test(_entry.GetCondition())) { ActionEntry _action = _entry.GetAction(); Action::Execute(_action); if (_action.IsDone()) { diff --git a/Task/Task.struct.h b/Task/Task.struct.h index e9a4e977d..57b5d856c 100644 --- a/Task/Task.struct.h +++ b/Task/Task.struct.h @@ -32,20 +32,20 @@ // Includes. #include "../Action.struct.h" -#include "../Condition.struct.h" #include "Task.enum.h" +#include "TaskCondition.struct.h" struct TaskEntry { - ActionEntry action; // Action of the task. - ConditionEntry cond; // Condition of the task. - datetime expires; // Time of expiration. - datetime last_process; // Time of the last process. - datetime last_success; // Time of the last success. - unsigned char flags; // Action flags. + ActionEntry action; // Action of the task. + TaskConditionEntry cond; // TaskCondition of the task. + datetime expires; // Time of expiration. + datetime last_process; // Time of the last process. + datetime last_success; // Time of the last success. + unsigned char flags; // Action flags. // Constructors. void TaskEntry() { Init(); } - void TaskEntry(ActionEntry &_action, ConditionEntry &_cond) : action(_action), cond(_cond) { Init(); } - void TaskEntry(long _aid, ENUM_ACTION_TYPE _atype, long _cid, ENUM_CONDITION_TYPE _ctype) + void TaskEntry(ActionEntry &_action, TaskConditionEntry &_cond) : action(_action), cond(_cond) { Init(); } + void TaskEntry(long _aid, ENUM_ACTION_TYPE _atype, long _cid, ENUM_TASK_CONDITION_TYPE _ctype) : action(_aid, _atype), cond(_cid, _ctype) { Init(); } @@ -80,9 +80,9 @@ struct TaskEntry { long GetActionId() { return action.GetId(); } long GetConditionId() { return cond.GetId(); } ActionEntry GetAction() { return action; } - ConditionEntry GetCondition() { return cond; } + TaskConditionEntry GetCondition() { return cond; } ENUM_ACTION_TYPE GetActionType() { return action.GetType(); } - ENUM_CONDITION_TYPE GetConditionType() { return cond.GetType(); } + ENUM_TASK_CONDITION_TYPE GetConditionType() { return cond.GetType(); } // Setters. void SetActionObject(void *_obj) { action.SetObject(_obj); } void SetConditionObject(void *_obj) { cond.SetObject(_obj); } diff --git a/Condition.enum.h b/Task/TaskCondition.enum.h similarity index 98% rename from Condition.enum.h rename to Task/TaskCondition.enum.h index 3f7a8e9a4..25faf93a4 100644 --- a/Condition.enum.h +++ b/Task/TaskCondition.enum.h @@ -21,7 +21,7 @@ /** * @file - * Includes Condition's enums. + * Includes TaskCondition's enums. */ #ifndef __MQL__ @@ -85,7 +85,7 @@ enum ENUM_MARKET_EVENT { #endif /* Defines condition entry flags. */ -enum ENUM_CONDITION_ENTRY_FLAGS { +enum ENUM_TASK_CONDITION_ENTRY_FLAGS { COND_ENTRY_FLAG_NONE = 0, COND_ENTRY_FLAG_IS_ACTIVE = 1, COND_ENTRY_FLAG_IS_EXPIRED = 2, @@ -94,7 +94,7 @@ enum ENUM_CONDITION_ENTRY_FLAGS { }; /* Defines condition statements (operators). */ -enum ENUM_CONDITION_STATEMENT { +enum ENUM_TASK_CONDITION_STATEMENT { COND_AND = 1, // Use AND statement. COND_OR, // Use OR statement. COND_SEQ, // Use sequential checks. @@ -102,7 +102,7 @@ enum ENUM_CONDITION_STATEMENT { }; /* Defines condition types. */ -enum ENUM_CONDITION_TYPE { +enum ENUM_TASK_CONDITION_TYPE { COND_TYPE_ACCOUNT = 1, // Account condition. COND_TYPE_ACTION, // Action condition. COND_TYPE_CHART, // Chart condition. diff --git a/Condition.mqh b/Task/TaskCondition.h similarity index 85% rename from Condition.mqh rename to Task/TaskCondition.h index 9118becab..48aad39fe 100644 --- a/Condition.mqh +++ b/Task/TaskCondition.h @@ -26,28 +26,28 @@ */ // Prevents processing this includes file for the second time. -#ifndef CONDITION_MQH -#define CONDITION_MQH +#ifndef TASK_CONDITION_MQH +#define TASK_CONDITION_MQH // Includes. -#include "Account.mqh" -#include "Chart.mqh" -#include "DateTime.mqh" -#include "DictStruct.mqh" -#include "EA.mqh" -#include "Indicator.mqh" -#include "Market.mqh" -#include "Object.mqh" -#include "Order.mqh" +#include "../Account.mqh" +#include "../Chart.mqh" +#include "../DateTime.mqh" +#include "../DictStruct.mqh" +#include "../EA.mqh" +#include "../Indicator.mqh" +#include "../Market.mqh" +#include "../Object.mqh" +#include "../Order.mqh" // Includes class enum and structs. -#include "Condition.enum.h" -#include "Condition.struct.h" +#include "TaskCondition.enum.h" +#include "TaskCondition.struct.h" /** - * Condition class. + * TaskCondition class. */ -class Condition { +class TaskCondition { public: protected: // Class variables. @@ -55,31 +55,31 @@ class Condition { public: // Class variables. - DictStruct conds; + DictStruct conds; /* Special methods */ /** * Class constructor. */ - Condition() {} - Condition(ConditionEntry &_entry) { conds.Push(_entry); } - Condition(long _cond_id, ENUM_CONDITION_TYPE _type) { - ConditionEntry _entry(_cond_id, _type); + TaskCondition() {} + TaskCondition(TaskConditionEntry &_entry) { conds.Push(_entry); } + TaskCondition(long _cond_id, ENUM_TASK_CONDITION_TYPE _type) { + TaskConditionEntry _entry(_cond_id, _type); conds.Push(_entry); } template - Condition(T _cond_id, void *_obj = NULL) { - ConditionEntry _entry(_cond_id); + TaskCondition(T _cond_id, void *_obj = NULL) { + TaskConditionEntry _entry(_cond_id); if (_obj != NULL) { _entry.SetObject(_obj); } conds.Push(_entry); } template - Condition(T _cond_id, MqlParam &_args[], void *_obj = NULL) { + TaskCondition(T _cond_id, MqlParam &_args[], void *_obj = NULL) { Init(); - ConditionEntry _entry(_cond_id); + TaskConditionEntry _entry(_cond_id); _entry.SetArgs(_args); if (_obj != NULL) { _entry.SetObject(_obj); @@ -90,7 +90,7 @@ class Condition { /** * Class copy constructor. */ - Condition(Condition &_cond) { conds = _cond.GetConditions(); } + TaskCondition(TaskCondition &_cond) { conds = _cond.GetConditions(); } /* Main methods */ @@ -99,9 +99,9 @@ class Condition { */ bool Test() { bool _result = false, _prev_result = true; - for (DictStructIterator iter = conds.Begin(); iter.IsValid(); ++iter) { + for (DictStructIterator iter = conds.Begin(); iter.IsValid(); ++iter) { bool _curr_result = false; - ConditionEntry _entry = iter.Value(); + TaskConditionEntry _entry = iter.Value(); if (!_entry.IsValid()) { // Ignore invalid entries. continue; @@ -130,7 +130,7 @@ class Condition { /** * Test specific condition. */ - static bool Test(ConditionEntry &_entry) { + static bool Test(TaskConditionEntry &_entry) { bool _result = false; switch (_entry.type) { case COND_TYPE_ACCOUNT: @@ -262,8 +262,8 @@ class Condition { /** * Returns conditions. */ - DictStruct *GetConditions() { return &conds; } + DictStruct *GetConditions() { return &conds; } /* Setters */ }; -#endif // CONDITION_MQH +#endif // TASK_CONDITION_MQH diff --git a/Task/TaskCondition.struct.h b/Task/TaskCondition.struct.h new file mode 100644 index 000000000..97b10383e --- /dev/null +++ b/Task/TaskCondition.struct.h @@ -0,0 +1,111 @@ +//+------------------------------------------------------------------+ +//| EA31337 framework | +//| Copyright 2016-2021, EA31337 Ltd | +//| https://github.com/EA31337 | +//+------------------------------------------------------------------+ + +/* + * This file is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * @file + * Includes Condition's structs. + */ + +#ifndef __MQL__ +// Allows the preprocessor to include a header file when it is needed. +#pragma once +#endif + +// Includes. +#include "../Account.enum.h" +#include "../Chart.enum.h" +#include "../DateTime.enum.h" +#include "../EA.enum.h" +#include "../Indicator.enum.h" +//#include "Market.enum.h" +#include "../Order.enum.h" +#include "../Strategy.enum.h" +#include "../Trade.enum.h" +#include "Task.enum.h" + +struct TaskConditionEntry { + unsigned char flags; // Condition flags. + datetime last_check; // Time of the latest check. + datetime last_success; // Time of the last success. + int frequency; // How often to check. + long cond_id; // Condition ID. + short tries; // Number of successful tries left. + void *obj; // Reference to associated object. + ENUM_TASK_CONDITION_STATEMENT next_statement; // Statement type of the next condition. + ENUM_TASK_CONDITION_TYPE type; // Task's condition type. + DataParamEntry args[]; // Task's condition arguments. + // Constructors. + void TaskConditionEntry() : type(FINAL_CONDITION_TYPE_ENTRY), cond_id(WRONG_VALUE) { Init(); } + void TaskConditionEntry(long _cond_id, ENUM_TASK_CONDITION_TYPE _type) : type(_type), cond_id(_cond_id) { Init(); } + void TaskConditionEntry(TaskConditionEntry &_ce) { this = _ce; } + void TaskConditionEntry(ENUM_ACCOUNT_CONDITION _cond_id) : type(COND_TYPE_ACCOUNT), cond_id(_cond_id) { Init(); } + void TaskConditionEntry(ENUM_CHART_CONDITION _cond_id) : type(COND_TYPE_CHART), cond_id(_cond_id) { Init(); } + void TaskConditionEntry(ENUM_DATETIME_CONDITION _cond_id) : type(COND_TYPE_DATETIME), cond_id(_cond_id) { Init(); } + void TaskConditionEntry(ENUM_EA_CONDITION _cond_id) : type(COND_TYPE_EA), cond_id(_cond_id) { Init(); } + void TaskConditionEntry(ENUM_INDICATOR_CONDITION _cond_id) : type(COND_TYPE_INDICATOR), cond_id(_cond_id) { Init(); } + void TaskConditionEntry(ENUM_MARKET_CONDITION _cond_id) : type(COND_TYPE_MARKET), cond_id(_cond_id) { Init(); } + void TaskConditionEntry(ENUM_ORDER_CONDITION _cond_id) : type(COND_TYPE_ORDER), cond_id(_cond_id) { Init(); } + void TaskConditionEntry(ENUM_STRATEGY_CONDITION _cond_id) : type(COND_TYPE_STRATEGY), cond_id(_cond_id) { Init(); } + void TaskConditionEntry(ENUM_TASK_CONDITION _cond_id) : type(COND_TYPE_TASK), cond_id(_cond_id) { Init(); } + void TaskConditionEntry(ENUM_TRADE_CONDITION _cond_id) : type(COND_TYPE_TRADE), cond_id(_cond_id) { Init(); } + // Deconstructor. + void ~TaskConditionEntry() { + // Object::Delete(obj); + } + // Flag methods. + bool HasFlag(unsigned char _flag) { return bool(flags & _flag); } + void AddFlags(unsigned char _flags) { flags |= _flags; } + void RemoveFlags(unsigned char _flags) { flags &= ~_flags; } + void SetFlag(ENUM_TASK_CONDITION_ENTRY_FLAGS _flag, bool _value) { + if (_value) + AddFlags(_flag); + else + RemoveFlags(_flag); + } + void SetFlags(unsigned char _flags) { flags = _flags; } + // State methods. + bool IsActive() { return HasFlag(COND_ENTRY_FLAG_IS_ACTIVE); } + bool IsExpired() { return HasFlag(COND_ENTRY_FLAG_IS_EXPIRED); } + bool IsReady() { return HasFlag(COND_ENTRY_FLAG_IS_READY); } + bool IsInvalid() { return HasFlag(COND_ENTRY_FLAG_IS_INVALID); } + bool IsValid() { return !IsInvalid(); } + // Getters. + long GetId() { return cond_id; } + ENUM_TASK_CONDITION_TYPE GetType() { return type; } + // Setters. + void AddArg(MqlParam &_arg) { + // @todo: Add another value to args[]. + } + void Init() { + flags = COND_ENTRY_FLAG_NONE; + frequency = 60; + SetFlag(COND_ENTRY_FLAG_IS_ACTIVE, cond_id != WRONG_VALUE); + SetFlag(COND_ENTRY_FLAG_IS_INVALID, cond_id == WRONG_VALUE); + last_check = last_success = 0; + next_statement = COND_AND; + tries = 1; + } + void SetArgs(MqlParam &_args[]) { + // @todo: for(). + } + void SetObject(void *_obj) { obj = _obj; } + void SetTries(short _count) { tries = _count; } +}; diff --git a/Task/tests/Task.test.mq5 b/Task/tests/Task.test.mq5 index 34652fedc..f84783996 100644 --- a/Task/tests/Task.test.mq5 +++ b/Task/tests/Task.test.mq5 @@ -32,8 +32,8 @@ struct DataParamEntry; #include "../../Chart.mqh" #include "../../DictObject.mqh" #include "../../EA.mqh" -#include "../Task.h" #include "../../Test.mqh" +#include "../Task.h" // Global variables. Chart *chart; diff --git a/tests/ConditionTest.mq4 b/Task/tests/TaskCondition.test.mq4 similarity index 92% rename from tests/ConditionTest.mq4 rename to Task/tests/TaskCondition.test.mq4 index 89bff6caa..961feb86a 100644 --- a/tests/ConditionTest.mq4 +++ b/Task/tests/TaskCondition.test.mq4 @@ -21,8 +21,8 @@ /** * @file - * Test functionality of Condition class. + * Test functionality of TaskCondition class. */ // Includes. -#include "ConditionTest.mq5" +#include "TaskCondition.test.mq5" diff --git a/tests/ConditionTest.mq5 b/Task/tests/TaskCondition.test.mq5 similarity index 77% rename from tests/ConditionTest.mq5 rename to Task/tests/TaskCondition.test.mq5 index bb92cf89b..fd2d006f9 100644 --- a/tests/ConditionTest.mq5 +++ b/Task/tests/TaskCondition.test.mq5 @@ -21,21 +21,21 @@ /** * @file - * Test functionality of Condition class. + * Test functionality of TaskCondition class. */ // Forward declaration. struct DataParamEntry; // Includes. -#include "../Condition.mqh" -#include "../DictObject.mqh" -#include "../Indicators/Indi_Demo.mqh" -#include "../Test.mqh" +#include "../../DictObject.mqh" +#include "../../Indicators/Indi_Demo.mqh" +#include "../../Test.mqh" +#include "../TaskCondition.h" // Global variables. Chart *chart; -DictObject conds; +DictObject conds; int bar_processed; /** @@ -78,7 +78,7 @@ void OnDeinit(const int reason) { delete chart; } bool TestAccountConditions() { bool _result = true; Account *_acc = new Account(); - Condition *_cond = new Condition(ACCOUNT_COND_BAL_IN_LOSS); + TaskCondition *_cond = new TaskCondition(ACCOUNT_COND_BAL_IN_LOSS); assertTrueOrReturnFalse(_cond.Test() == _acc.CheckCondition(ACCOUNT_COND_BAL_IN_LOSS), "Wrong condition: ACCOUNT_COND_BAL_IN_LOSS!"); delete _cond; @@ -92,7 +92,7 @@ bool TestAccountConditions() { bool TestChartConditions() { bool _result = true; Chart *_chart = new Chart(); - Condition *_cond = new Condition(CHART_COND_ASK_BAR_PEAK, _chart); + TaskCondition *_cond = new TaskCondition(CHART_COND_ASK_BAR_PEAK, _chart); assertTrueOrReturnFalse(_cond.Test() == _chart.CheckCondition(CHART_COND_ASK_BAR_PEAK), "Wrong condition: CHART_COND_ASK_BAR_PEAK!"); delete _cond; @@ -106,11 +106,11 @@ bool TestChartConditions() { bool TestDateTimeConditions() { bool _result = true; DateTime *_dt = new DateTime(); - Condition *_cond1 = new Condition(DATETIME_COND_NEW_HOUR, _dt); + TaskCondition *_cond1 = new TaskCondition(DATETIME_COND_NEW_HOUR, _dt); assertTrueOrReturnFalse(_cond1.Test() == _dt.CheckCondition(DATETIME_COND_NEW_HOUR), "Wrong condition: DATETIME_COND_NEW_HOUR (dynamic)!"); delete _cond1; - Condition *_cond2 = new Condition(DATETIME_COND_NEW_HOUR); + TaskCondition *_cond2 = new TaskCondition(DATETIME_COND_NEW_HOUR); assertTrueOrReturnFalse(_cond2.Test() == DateTime::CheckCondition(DATETIME_COND_NEW_HOUR), "Wrong condition: DATETIME_COND_NEW_HOUR (static)!"); delete _cond2; @@ -126,22 +126,22 @@ bool TestIndicatorConditions() { Indi_Demo *_demo = new Indi_Demo(); /* @fixme assertTrueOrReturnFalse( - (new Condition(INDI_COND_ENTRY_IS_MAX, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_IS_MAX), + (new TaskCondition(INDI_COND_ENTRY_IS_MAX, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_IS_MAX), "Wrong condition: INDI_COND_ENTRY_IS_MAX!"); assertTrueOrReturnFalse( - (new Condition(INDI_COND_ENTRY_IS_MIN, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_IS_MIN), + (new TaskCondition(INDI_COND_ENTRY_IS_MIN, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_IS_MIN), "Wrong condition: INDI_COND_ENTRY_IS_MIN!"); assertTrueOrReturnFalse( - (new Condition(INDI_COND_ENTRY_GT_AVG, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_GT_AVG), + (new TaskCondition(INDI_COND_ENTRY_GT_AVG, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_GT_AVG), "Wrong condition: INDI_COND_ENTRY_GT_AVG!"); assertTrueOrReturnFalse( - (new Condition(INDI_COND_ENTRY_GT_MED, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_GT_MED), + (new TaskCondition(INDI_COND_ENTRY_GT_MED, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_GT_MED), "Wrong condition: INDI_COND_ENTRY_GT_MED!"); assertTrueOrReturnFalse( - (new Condition(INDI_COND_ENTRY_LT_AVG, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_LT_AVG), + (new TaskCondition(INDI_COND_ENTRY_LT_AVG, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_LT_AVG), "Wrong condition: INDI_COND_ENTRY_LT_AVG!"); assertTrueOrReturnFalse( - (new Condition(INDI_COND_ENTRY_LT_MED, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_LT_MED), + (new TaskCondition(INDI_COND_ENTRY_LT_MED, _demo)).Test() == _demo.CheckCondition(INDI_COND_ENTRY_LT_MED), "Wrong condition: INDI_COND_ENTRY_LT_MED!"); */ delete _demo; @@ -154,7 +154,7 @@ bool TestIndicatorConditions() { bool TestMarketConditions() { bool _result = true; Market *_market = new Market(); - Condition *_cond = new Condition(MARKET_COND_IN_PEAK_HOURS, _market); + TaskCondition *_cond = new TaskCondition(MARKET_COND_IN_PEAK_HOURS, _market); assertTrueOrReturnFalse(_cond.Test() == _market.CheckCondition(MARKET_COND_IN_PEAK_HOURS), "Wrong condition: MARKET_COND_IN_PEAK_HOURS!"); delete _cond; @@ -186,7 +186,7 @@ bool TestOrderConditions() { bool TestTradeConditions() { bool _result = true; Trade *_trade = new Trade(); - Condition *_cond = new Condition(TRADE_COND_ALLOWED_NOT, _trade); + TaskCondition *_cond = new TaskCondition(TRADE_COND_ALLOWED_NOT, _trade); assertTrueOrReturnFalse(_cond.Test() == _trade.CheckCondition(TRADE_COND_ALLOWED_NOT), "Wrong condition: TRADE_COND_ALLOWED_NOT!"); delete _cond; diff --git a/Trade.mqh b/Trade.mqh index c55a92caa..915c34091 100644 --- a/Trade.mqh +++ b/Trade.mqh @@ -33,13 +33,13 @@ class Trade; #include "Account.mqh" #include "Action.enum.h" #include "Chart.mqh" -#include "Condition.enum.h" #include "Convert.mqh" #include "DictStruct.mqh" #include "Math.h" #include "Object.mqh" #include "Order.mqh" #include "OrderQuery.h" +#include "Task/TaskCondition.enum.h" #include "Trade.enum.h" #include "Trade.struct.h" diff --git a/tests/CompileTest.mq5 b/tests/CompileTest.mq5 index 29cacc1fa..a2923ce26 100644 --- a/tests/CompileTest.mq5 +++ b/tests/CompileTest.mq5 @@ -44,7 +44,6 @@ #include "../BufferStruct.mqh" #include "../Chart.mqh" #include "../Collection.mqh" -#include "../Condition.mqh" #include "../Config.mqh" #include "../Convert.mqh" #include "../Database.mqh" @@ -68,6 +67,7 @@ #include "../Log.mqh" #include "../MD5.mqh" #include "../Storage/IValueStorage.h" +#include "../Task/TaskCondition.h" //#include "../MQL4.mqh" // @removeme //#include "../MQL5.mqh" // @removeme #include "../Mail.mqh"