Skip to content

Commit

Permalink
Action: Enables Trade actions by default
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Aug 31, 2021
1 parent b244249 commit 6c7dfe1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
2 changes: 0 additions & 2 deletions Action.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)) {
Expand Down
21 changes: 10 additions & 11 deletions Action.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions Condition.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)) {
Expand Down
7 changes: 3 additions & 4 deletions Condition.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down Expand Up @@ -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;
Expand All @@ -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; }
};
1 change: 1 addition & 0 deletions Task.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 6c7dfe1

Please sign in to comment.