From 6c7dfe1430dae9ef11790f6ea73c16a970567ad3 Mon Sep 17 00:00:00 2001 From: kenorb Date: Tue, 31 Aug 2021 17:19:07 +0100 Subject: [PATCH] Action: Enables Trade actions by default --- Action.mqh | 2 -- Action.struct.h | 21 ++++++++++----------- Condition.mqh | 2 -- Condition.struct.h | 7 +++---- Task.struct.h | 1 + 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Action.mqh b/Action.mqh index 4602b7df2..85f9a3a9b 100644 --- a/Action.mqh +++ b/Action.mqh @@ -168,7 +168,6 @@ class Action { } break; #endif -#ifdef TRADE_MQH case ACTION_TYPE_TRADE: if (Object::IsValid(_entry.obj)) { _result = ((Trade *)_entry.obj).ExecuteAction((ENUM_TRADE_ACTION)_entry.action_id); @@ -177,7 +176,6 @@ class Action { _entry.AddFlags(ACTION_ENTRY_FLAG_IS_INVALID); } break; -#endif #ifdef TERMINAL_MQH case ACTION_TYPE_TERMINAL: if (Object::IsValid(_entry.obj)) { diff --git a/Action.struct.h b/Action.struct.h index 4fdcd1755..1f5481f14 100644 --- a/Action.struct.h +++ b/Action.struct.h @@ -45,14 +45,14 @@ /* Entry for Action class. */ struct ActionEntry { - unsigned char flags; /* Action flags. */ - datetime last_success; /* Time of the previous check. */ - long action_id; /* Action ID. */ - short tries; /* Number of retries left. */ - void *obj; /* Reference to associated object. */ - ENUM_ACTION_TYPE type; /* Action type. */ - ENUM_TIMEFRAMES frequency; /* How often to check. */ - DataParamEntry args[]; /* Action arguments. */ + unsigned char flags; /* Action flags. */ + datetime last_success; /* Time of the previous check. */ + int frequency; /* How often to check. */ + long action_id; /* Action ID. */ + short tries; /* Number of retries left. */ + void *obj; /* Reference to associated object. */ + ENUM_ACTION_TYPE type; /* Action type. */ + DataParamEntry args[]; /* Action arguments. */ // Constructors. ActionEntry() : type(FINAL_ACTION_TYPE_ENTRY), action_id(WRONG_VALUE) { Init(); } ActionEntry(long _action_id, ENUM_ACTION_TYPE _type) : type(_type), action_id(_action_id) { Init(); } @@ -93,6 +93,7 @@ struct ActionEntry { } void Init() { flags = ACTION_ENTRY_FLAG_NONE; + frequency = 60; SetFlag(ACTION_ENTRY_FLAG_IS_ACTIVE, action_id != WRONG_VALUE); SetFlag(ACTION_ENTRY_FLAG_IS_INVALID, action_id == WRONG_VALUE); last_success = 0; @@ -101,9 +102,7 @@ struct ActionEntry { void SetArgs(ARRAY_REF(MqlParam, _args)) { // @todo: for(). } - void SetObject(void *_obj) { - obj = _obj; - } + void SetObject(void *_obj) { obj = _obj; } void SetTries(short _count) { tries = _count; } SerializerNodeType Serialize(Serializer &s) { diff --git a/Condition.mqh b/Condition.mqh index d1cb76d77..27183866b 100644 --- a/Condition.mqh +++ b/Condition.mqh @@ -226,7 +226,6 @@ class Condition { } break; #endif -#ifdef TRADE_MQH case COND_TYPE_TRADE: if (Object::IsValid(_entry.obj)) { _result = ((Trade *)_entry.obj).CheckCondition((ENUM_TRADE_CONDITION)_entry.cond_id, _entry.args); @@ -235,7 +234,6 @@ class Condition { _entry.AddFlags(COND_ENTRY_FLAG_IS_INVALID); } break; -#endif #ifdef TERMINAL_MQH case COND_TYPE_TERMINAL: if (Object::IsValid(_entry.obj)) { diff --git a/Condition.struct.h b/Condition.struct.h index db757d648..6e3376812 100644 --- a/Condition.struct.h +++ b/Condition.struct.h @@ -45,12 +45,12 @@ 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. - ENUM_TIMEFRAMES frequency; // How often to check. DataParamEntry args[]; // Condition arguments. // Constructors. void ConditionEntry() : type(FINAL_CONDITION_TYPE_ENTRY), cond_id(WRONG_VALUE) { Init(); } @@ -96,6 +96,7 @@ struct ConditionEntry { } 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; @@ -105,8 +106,6 @@ struct ConditionEntry { void SetArgs(MqlParam &_args[]) { // @todo: for(). } - void SetObject(void *_obj) { - obj = _obj; - } + void SetObject(void *_obj) { obj = _obj; } void SetTries(short _count) { tries = _count; } }; diff --git a/Task.struct.h b/Task.struct.h index 6d0db4129..d1b7487ce 100644 --- a/Task.struct.h +++ b/Task.struct.h @@ -53,6 +53,7 @@ struct TaskEntry { void TaskEntry(AE _aid, CE _cid) : action(_aid), cond(_cid) { Init(); } + // Main methods. void Init() { flags = TASK_ENTRY_FLAG_NONE; SetFlag(TASK_ENTRY_FLAG_IS_ACTIVE, action.IsActive() && cond.IsActive());