Skip to content

v3.003-dev-new #744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 33 commits into
base: v3.002-dev-new
Choose a base branch
from
Open

v3.003-dev-new #744

wants to merge 33 commits into from

Conversation

kenorb
Copy link
Member

@kenorb kenorb commented Apr 25, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new macros for evaluating trade signal flags and added corresponding unit tests to ensure correct trade signal identification.
    • Added a new struct for managing task condition entries, enhancing task condition state management.
  • Refactor

    • Systematically renamed and restructured action and condition-related classes, enums, and structs to use "TaskAction" and "TaskCondition" terminology for improved clarity.
    • Updated include paths and file organization to reflect the new task-oriented structure.
  • Bug Fixes

    • Corrected pointer dereferencing in dictionary and serializer components to ensure proper member access and prevent errors.
  • Tests

    • Updated and expanded test files to align with the new task-based structure and verify new macro and struct functionality.
    • Removed obsolete test entries from automated workflows.
  • Chores

    • Improved documentation comments and added conditional compilation guards to prevent macro redefinition warnings.
    • Simplified preprocessor logic for platform-specific definitions.

@kenorb kenorb added this to the v3.003 milestone Apr 25, 2024
nseam and others added 8 commits April 25, 2024 01:43
…ing to create new abstract instance of IndicatorBase class. Dict<long, IndicatorBase*> now have template specialization which will print an error and stop debugging if you try do deserialize such Dict.
* v3.002-dev-new:
  Account/AccountMt: Fixes zero division
  GHA: Compile: Support for workflow calls
  GHA: Compile: Skips clean-up by default
  GHA: Fixes compilation workflows
  Trade: Disables filling modes for MQL4
  Workaround for closing order conditions after orders are loaded from active pool (GH-705)
  Trade: TradeParams: Adds max_spread
  Order: Fixes the current volume value when data in orequest is missing
  Order: Refresh order after modification
  Trade: Disables filling modes for MQL4
  EA: Fixes recent issue with error during trade request
  Account/AccountMt: Fixes zero division
kenorb and others added 6 commits April 25, 2024 23:07
* v3.001-dev-new-stuff:
  Adds EA31337.vscode-mql-tools extension
  Fixes new lines [end-of-file-fixer]
  Disables wine package
  devcontainer: Adds node
  Adds wine to devcontainer
  Adds DavidAnson.vscode-markdownlint extension to devcontainer
  Adds initial .vscode/settings.json
…3-dev-new

* origin/v3.001-dev-new-cgava:
  GHA: Compile: Support for workflow calls
  Trade: TradeSignalEnumMacro: Fixes includes to use local path
  Moves enum macros into the main file and fixes compilation errors
  Adds a wrapper file for TradeSignalEnumMacro
  Renames TradeEnumMacro.mq4 to TradeSignalEnumMacro.test.mq5
  CGA(Trade): proposal for macor based computation of SIGNAL BUY/SELL CLOSE/BUY composite signal
  GHA: Compile: Skips clean-up by default
* origin/v3.002-dev-new:
  Workaround for closing order conditions after orders are loaded from active pool (GH-705)
  Trade: TradeParams: Adds max_spread
  Order: Fixes the current volume value when data in orequest is missing
  Order: Refresh order after modification
  Trade: Disables filling modes for MQL4
  Account/AccountMt: Fixes zero division
  Refs EA31337-classes/EA31337-indicators-other#13, EA31337-classes/EA31337-indicators-other#15. WIP. TDI-RT-Clone and Heiken_Ashi_Smoothed indicators made to work in MT5.
  GHA: Compile: Adds support for path input
* v3.002-dev-new:
  Strategy: Improves logic for TrendStrength()
  Strategy: Adds missing trend_threshold to constructor
  IndicatorData: Adds Set()
Copy link

coderabbitai bot commented May 18, 2025

Walkthrough

This update refactors core framework components by replacing generic "Action" and "Condition" types with new, task-specific "TaskAction" and "TaskCondition" classes, enums, and structs. It updates includes, type names, and test code accordingly. Additional improvements include macro guards, pointer dereference fixes, new trade signal macros, and enhanced buffer management utilities.

Changes

Files / Groups Change Summary
Task/TaskAction.h, Task/TaskAction.struct.h, Task/TaskAction.enum.h, Task/tests/TaskAction.test.mq4, Task/tests/TaskAction.test.mq5 Renamed Action class/struct/enums to TaskAction, updated constructors, methods, comments, and test usage accordingly.
Task/TaskCondition.h, Task/TaskCondition.struct.h, Task/TaskCondition.enum.h, Task/tests/TaskCondition.test.mq4, Task/tests/TaskCondition.test.mq5 Renamed Condition class/struct/enums to TaskCondition, updated all references, includes, and test usage.
Task/Task.h, Task/Task.struct.h, Task/tests/Task.test.mq4, Task/tests/Task.test.mq5 Updated includes and types from generic Action/Condition to TaskAction/TaskCondition; refactored flag logic in Task processing.
Condition.struct.h Entire file removed; ConditionEntry struct and all its logic deleted.
Chart.mqh, Market.mqh, Order.mqh, Trade.mqh, EA.mqh, Strategy.mqh, Strategy.struct.h, EA.struct.h, Trade/TradeSignal.struct.h, tests/CompileTest.mq5 Updated includes to use new TaskAction/TaskCondition headers and paths; adjusted comments and include paths for clarity and modularity.
DictObject.mqh, DictStruct.mqh, DictIteratorBase.mqh, SerializerConverter.mqh Fixed pointer member access by adding explicit dereferencing (PTR_DEREF), updated method calls accordingly.
Serializer.mqh Added forward declaration for IndicatorBase, default parameter for constructor, and template overload for serializing IndicatorBase*.
Math.define.h Added preprocessor guards around numeric limit macros to prevent redefinition.
Object.mqh Unconditionally defines nullptr as NULL, removing MQL4-specific conditional.
Task/Task.enum.h, Task/TaskAction.enum.h Updated enum comments to clarify association with TaskAction class.
Task/tests/Task.test.mq4, Task/tests/Task.test.mq5 Updated test includes to match new file and class names.
Trade/TradeSignal.struct.h, Trade/tests/TradeSignalEnumMacro.test.mq4, Trade/tests/TradeSignalEnumMacro.test.mq5 Added macros for trade signal checks; new tests verify correct macro behavior for trade signals.
Std.h Changed InvalidEnumValue to constexpr, added buffer acquisition/release macros and AsSeriesReleaseEnsurer struct for safer buffer management.
Indicators/Indi_Drawer.mqh Switched from ActionEntry to TaskActionEntry in local variables and includes.
SerializerJson.mqh Added include for Serializer.enum.h.
.github/workflows/compile-cpp.yml Added Emscripten toolchain setup, split compile step into Emscripten and native g++ compilation.
.github/workflows/test.yml Removed ActionTest, ConditionTest, and TaskTest from test matrix.

Sequence Diagram(s)

sequenceDiagram
    participant EA as EA
    participant Task as Task
    participant TaskAction as TaskAction
    participant TaskCondition as TaskCondition

    EA->>Task: Create TaskEntry(TaskActionEntry, TaskConditionEntry)
    Task->>TaskAction: GetActions()
    Task->>TaskCondition: GetConditions()
    TaskAction->>TaskAction: Execute(TaskActionEntry)
    TaskCondition->>TaskCondition: Test(TaskConditionEntry)
Loading
sequenceDiagram
    participant Trade as Trade
    participant Signal as TradeSignal

    Trade->>Signal: Check signal flags using new macros
    Signal-->>Trade: Return true/false for open/close buy/sell
Loading

Poem

A hop, a skip, a code refactor,
Actions and Conditions now Task-prefactor!
Macros guard and signals clear,
Buffers safe, no bugs to fear.
With pointers dereferenced and tests anew,
This bunny celebrates—code fresh as dew! 🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (5)
SerializerConverter.mqh (1)

118-118: Inconsistent null pointer literal usage

Line 111 uses NULL while this line uses nullptr. Consider standardizing on one null pointer literal throughout the codebase.

-    SerializerConverter _converter(((C*)nullptr)PTR_DEREF Parse(data), 0);
+    SerializerConverter _converter(((C*)NULL)PTR_DEREF Parse(data), 0);
Task/Task.struct.h (1)

75-78: Flag constants not renamed.

While the struct and member types have been renamed to use the Task prefix, the flag constants (like ACTION_ENTRY_FLAG_IS_ACTIVE) have not been renamed to match the new naming convention.

Consider renaming these flag constants to include the TASK prefix for consistency:

-  bool IsActive() { return HasFlag(ACTION_ENTRY_FLAG_IS_ACTIVE); }
-  bool IsDone() { return HasFlag(ACTION_ENTRY_FLAG_IS_DONE); }
-  bool IsFailed() { return HasFlag(ACTION_ENTRY_FLAG_IS_FAILED); }
-  bool IsValid() { return !HasFlag(ACTION_ENTRY_FLAG_IS_INVALID); }
+  bool IsActive() { return HasFlag(TASK_ACTION_ENTRY_FLAG_IS_ACTIVE); }
+  bool IsDone() { return HasFlag(TASK_ACTION_ENTRY_FLAG_IS_DONE); }
+  bool IsFailed() { return HasFlag(TASK_ACTION_ENTRY_FLAG_IS_FAILED); }
+  bool IsValid() { return !HasFlag(TASK_ACTION_ENTRY_FLAG_IS_INVALID); }
Task/TaskAction.h (1)

377-377: Header guard not updated.

The header guard still uses ACTION_MQH instead of TASK_ACTION_MQH, which doesn't match the new file naming convention.

Consider updating the header guard to match the new file name:

-#ifndef ACTION_MQH
-#define ACTION_MQH
+#ifndef TASK_ACTION_MQH
+#define TASK_ACTION_MQH

// Content of the file

-#endif  // ACTION_MQH
+#endif  // TASK_ACTION_MQH
Std.h (1)

264-417: High macro duplication – explore variadic helpers

ACQUIRE_BUFFER1ACQUIRE_BUFFER8 and the matching RELEASE_BUFFER* blocks are copy-pasted eight times. This is error-prone and hard to maintain (future changes must be done in sixteen places).

A single variadic macro can do the job:

#define _FOR_EACH(MACRO, ...)  EXPAND(_FOR_EACH_N(MACRO, __VA_ARGS__, _R8,_R7,_R6,_R5,_R4,_R3,_R2,_R1)(_FOR_EACH_ ## MACRO, __VA_ARGS__))
/* … generic machinery omitted for brevity … */

#define ACQUIRE_BUFFERS(...)                                      \
  SET_BUFFER_AS_SERIES_RELEASE_ENSURER_BEGIN(ARGC(__VA_ARGS__));  \
  _FOR_EACH(SET_BUFFER_AS_SERIES_FOR_TARGET, __VA_ARGS__)

#define RELEASE_BUFFERS(...)                                      \
  _FOR_EACH(SET_BUFFER_AS_SERIES_FOR_HOST, __VA_ARGS__)           \
  SET_BUFFER_AS_SERIES_RELEASE_ENSURER_END(ARGC(__VA_ARGS__))

This removes 300+ lines and the risk of the two blocks diverging.

Task/TaskCondition.h (1)

100-128: Iterator copies large struct by value

Inside Test() each loop iteration copies a whole TaskConditionEntry (_entry = iter.Value();).
The struct is already sizable (flags, timestamps, flexible arg array) — copying it repeatedly is unnecessary.

-    TaskConditionEntry _entry = iter.Value();
+    TaskConditionEntry & _entry = iter.Value();

Using a reference avoids extra allocations and keeps any flag changes (‘invalid’ etc.) in sync with the dictionary entry.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c32123 and c25de49.

⛔ Files ignored due to path filters (3)
  • .coderabbit.yaml is excluded by none and included by none
  • .devcontainer/devcontainer.json is excluded by none and included by none
  • .vscode/settings.json is excluded by none and included by none
📒 Files selected for processing (40)
  • .github/workflows/compile-cpp.yml (1 hunks)
  • .github/workflows/test.yml (0 hunks)
  • Chart.mqh (1 hunks)
  • Condition.struct.h (0 hunks)
  • DictIteratorBase.mqh (1 hunks)
  • DictObject.mqh (6 hunks)
  • DictStruct.mqh (5 hunks)
  • EA.mqh (1 hunks)
  • EA.struct.h (2 hunks)
  • Indicators/Indi_Drawer.mqh (3 hunks)
  • Market.mqh (1 hunks)
  • Math.define.h (1 hunks)
  • Object.mqh (0 hunks)
  • Order.mqh (1 hunks)
  • Serializer.mqh (3 hunks)
  • SerializerConverter.mqh (2 hunks)
  • SerializerJson.mqh (1 hunks)
  • Std.h (2 hunks)
  • Strategy.mqh (1 hunks)
  • Strategy.struct.h (1 hunks)
  • Task/Task.enum.h (1 hunks)
  • Task/Task.h (3 hunks)
  • Task/Task.struct.h (2 hunks)
  • Task/TaskAction.enum.h (3 hunks)
  • Task/TaskAction.h (9 hunks)
  • Task/TaskAction.struct.h (2 hunks)
  • Task/TaskCondition.enum.h (4 hunks)
  • Task/TaskCondition.h (5 hunks)
  • Task/TaskCondition.struct.h (1 hunks)
  • Task/tests/Task.test.mq4 (1 hunks)
  • Task/tests/Task.test.mq5 (1 hunks)
  • Task/tests/TaskAction.test.mq4 (1 hunks)
  • Task/tests/TaskAction.test.mq5 (3 hunks)
  • Task/tests/TaskCondition.test.mq4 (1 hunks)
  • Task/tests/TaskCondition.test.mq5 (7 hunks)
  • Trade.mqh (2 hunks)
  • Trade/TradeSignal.struct.h (1 hunks)
  • Trade/tests/TradeSignalEnumMacro.test.mq4 (1 hunks)
  • Trade/tests/TradeSignalEnumMacro.test.mq5 (1 hunks)
  • tests/CompileTest.mq5 (3 hunks)
💤 Files with no reviewable changes (3)
  • Object.mqh
  • .github/workflows/test.yml
  • Condition.struct.h
🧰 Additional context used
🧬 Code Graph Analysis (1)
Task/TaskAction.h (4)
Task/Task.h (13)
  • _entry (74-74)
  • _entry (74-74)
  • _entry (98-115)
  • _entry (98-98)
  • _cond (214-235)
  • _cond (214-214)
  • _cond (236-239)
  • _cond (236-236)
  • _result (82-90)
  • _action (249-260)
  • _action (249-249)
  • _action (261-264)
  • _action (261-261)
Task/TaskAction.struct.h (6)
  • _obj (105-105)
  • _obj (105-105)
  • _flag (71-71)
  • _flag (71-71)
  • _flag (74-79)
  • _flag (74-74)
Task/Task.struct.h (3)
  • IsValid (78-78)
  • IsValid (78-78)
  • _action (47-47)
Task/TaskCondition.struct.h (2)
  • IsValid (89-89)
  • IsValid (89-89)
🔇 Additional comments (88)
SerializerJson.mqh (1)

30-30: LGTM: Added include for Serializer enums

This addition aligns with the broader refactoring effort of modularizing enum and struct headers.

SerializerConverter.mqh (2)

33-33: LGTM: Added Object.mqh include

This inclusion is necessary and consistent with the broader refactoring effort.


111-111: Improved pointer dereferencing safety

Using the PTR_DEREF macro for pointer dereferencing is a safer practice than using direct dot notation on potentially null pointers.

.github/workflows/compile-cpp.yml (2)

39-41: LGTM: Added Emscripten toolchain support

Adding WebAssembly compilation capabilities extends platform compatibility.


45-48: LGTM: Dual compilation path implementation

Splitting the compilation into separate emcc and g++ steps ensures code compatibility with both WebAssembly and native environments.

Math.define.h (1)

43-105: Added proper include guards for numeric limit macros

Adding conditional guards prevents redefinition warnings or errors when these macros might be defined elsewhere in the codebase or included libraries.

Strategy.mqh (1)

39-39: Include directive updated to new Task header

The include has been changed to "Task/Task.h", aligning with the reorganized Task subdirectory and .h extension. This keeps the file consistent with the new module structure.

Strategy.struct.h (1)

37-37: Include directive updated to Task.struct.h path

The include path for Task.struct.h has been updated to "Task/Task.struct.h", reflecting the relocated header in the Task folder and ensuring consistency with other Task module includes.

Task/tests/TaskAction.test.mq4 (2)

24-24: Updated file header to reference TaskAction

The header comment now correctly states that this file tests the TaskAction class instead of the generic Action class, matching the refactoring.


28-28: Include directive updated to TaskAction test

The include has been changed to "TaskAction.test.mq5", aligning with the renamed test file for TaskAction.

Order.mqh (1)

46-46: Include directive updated to TaskAction enum

The include of the old "Action.enum.h" has been replaced with "Task/TaskAction.enum.h", aligning this file with the new TaskAction enumeration and directory structure.

Task/tests/Task.test.mq4 (1)

28-28: Include directive updated to Task test

The include has been corrected to "Task.test.mq5", matching the renamed Task test module.

Task/tests/TaskCondition.test.mq4 (2)

24-24: Documentation updated to match renamed class.

The test file comment now correctly reflects that it tests the TaskCondition class rather than the generic Condition class, aligning with the broader refactoring in the PR.


28-28: Include path updated to match renamed file.

The include has been properly updated to reference the renamed test file, ensuring consistency with the task-specific class naming scheme.

Task/Task.enum.h (2)

33-33: Updated enum documentation to reference TaskAction.

Documentation now correctly references the new TaskAction class instead of the generic Action class, maintaining consistency with the task-specific implementation.


40-40: Updated enum documentation to reference TaskCondition.

Documentation now properly states that ENUM_TASK_CONDITION is for the TaskAction class instead of the previously generic class, ensuring consistent documentation.

Market.mqh (1)

37-37: Updated include path to reference task-specific condition enums.

The include directive now points to the task-specific condition enum header, consistent with the PR's refactoring from generic to task-specific classes.

Chart.mqh (1)

48-48: Updated include path to reference task-specific condition enums.

The include directive now points to the task-specific condition enum header, maintaining consistency with the PR's refactoring approach.

Trade.mqh (2)

41-42: Include paths updated to reflect module restructuring.

The include paths have been updated to reference task-specific components from the new Task namespace. This change is part of a broader refactoring that replaces generic "Action" and "Condition" classes with more specific "TaskAction" and "TaskCondition" components.


1817-1817: Comment updated to match new class naming convention.

The section header has been updated from "Actions" to "TaskActions" to maintain consistency with the renamed task-specific classes.

EA.struct.h (2)

35-35: Include path updated to reflect new directory structure.

The include path for Task.struct.h has been updated to reflect its new location in the Task subdirectory. This change is part of the broader refactoring of task-related components.


228-228: Comment updated to use the new TaskAction naming convention.

The comment for the flags member has been updated from "Action flags" to "TaskAction flags" to maintain consistency with the renamed task-specific classes.

EA.mqh (1)

47-49: Include paths updated to reference new Task module.

The include paths have been updated to reference the reorganized task modules:

  1. Added Task/Task.h - Main task handling
  2. Added Task/TaskAction.enum.h - Task action enumerations
  3. Added Task/TaskCondition.enum.h - Task condition enumerations

This change is part of the refactoring that replaces generic "Action" and "Condition" with more specific "TaskAction" and "TaskCondition" components.

Task/tests/Task.test.mq5 (1)

31-37: Updated include paths to reflect new directory structure.

The include paths have been updated to accommodate two changes:

  1. The test file is now located in a deeper directory (Task/tests), requiring additional "../" to reference framework files
  2. Action and Condition components have been renamed to TaskAction and TaskCondition

These changes ensure the test file properly references the restructured task-related components.

Trade/tests/TradeSignalEnumMacro.test.mq4 (1)

1-29: LGTM: Proper test wrapper file created.

This new file correctly serves as an MQL4 wrapper to include and run tests defined in the corresponding MQL5 file, following the established pattern in the codebase for cross-platform testing.

tests/CompileTest.mq5 (1)

41-41: Updated includes to match the new task-related organization structure.

The includes have been properly updated to reflect the reorganization of task-related headers into the Task subdirectory with .h extensions, which is consistent with the broader refactoring effort.

Also applies to: 70-70, 114-114

Trade/TradeSignal.struct.h (1)

53-58: Well-implemented trade signal evaluation macros.

These new macros provide a concise way to verify valid, unfiltered trade signals by checking that the main signal bit is set while both filter and time filter bits are not set. The implementation correctly handles bitwise operations with appropriate operator precedence and explicit comparison against zero.

Task/TaskAction.enum.h (1)

24-24: Comment updates align with TaskAction refactoring.

The comment changes appropriately reflect the renaming from generic "Action" to the more specific "TaskAction" context, maintaining consistency with the broader refactoring effort in the codebase.

Also applies to: 48-48, 59-59

DictObject.mqh (7)

145-145: Improved pointer dereferencing for better memory safety

The pointer access syntax has been updated to use the PTR_DEREF macro, which provides a more consistent way to dereference pointers across different platforms and compiler environments.


147-147: Consistent pointer dereferencing syntax

Updated pointer member access to use PTR_DEREF for pointer dereferencing, maintaining consistency with the rest of the codebase.


159-159: Standardized pointer member access

Following the pattern of using PTR_DEREF for accessing pointer members throughout the codebase.


174-174: Consistent pointer dereferencing implementation

The use of PTR_DEREF makes the pointer dereferencing explicit and consistent across all dictionary implementations.


189-189: Standardized pointer value comparison

Updated to use PTR_DEREF when accessing the value member of the slot pointer, maintaining consistent pointer dereferencing throughout the class.


268-269: Updated comment to match implementation

Comment updated to match the new PTR_DEREF syntax used in the code.


288-289: Updated comment for consistency

Comment language updated to match the syntax changes using PTR_DEREF for pointer member access.

Indicators/Indi_Drawer.mqh (3)

30-30: Updated import path for refactored TaskAction API

The import path has been updated to use the new path for the refactored TaskAction class instead of the generic Action class, aligning with the architectural changes in the framework.


109-109: Updated type to use task-specific action entry

Changed from using the generic ActionEntry to the more specific TaskActionEntry class, which better represents its purpose in the task framework.


136-137: Consistent use of TaskActionEntry

Updated variable declaration to use the new TaskActionEntry type, maintaining consistency with the refactored task action system.

DictStruct.mqh (6)

147-147: Improved pointer dereferencing with PTR_DEREF

Updated the pointer access to use the PTR_DEREF macro for more consistent dereferencing across different environments.


154-154: Standardized pointer member access

Changed direct pointer member access to use the PTR_DEREF macro, maintaining consistency with the codebase's pointer dereferencing approach.


169-169: Consistent pointer dereferencing in GetByKey

Updated to use PTR_DEREF when accessing the value member of the slot pointer.


186-186: Standardized pointer access in overloaded GetByKey

Consistently updated to use PTR_DEREF for pointer member access, following the pattern throughout the codebase.


202-202: Uniform pointer dereferencing in GetByPos

Updated to use the PTR_DEREF macro for accessing the value member of the slot pointer.


234-234: Consistent pointer value comparison

Updated to use PTR_DEREF when accessing the value member of the slot pointer for comparison.

Task/Task.h (4)

33-34: Updated include paths to use relative paths

Changed the include paths to use relative paths (../) which makes the code more maintainable when files are moved or reorganized.


37-38: Added new task-specific action and condition headers

Replaced generic action and condition headers with the new task-specific versions, which better represent their purpose in the task framework.


101-103: Updated to use task-specific classes

Changed from using generic Condition and Action classes to the more specific TaskCondition and TaskAction classes, improving code clarity and organization.


189-199: Improved control flow with clearer if-else structure

Replaced a switch statement on boolean value with a more readable if-else structure, making the code easier to understand without changing its behavior.

Task/tests/TaskCondition.test.mq5 (5)

24-24: Updated file documentation to reflect TaskCondition focus.

The file documentation has been correctly updated to reflect that this test file now focuses on the TaskCondition class rather than the Condition class.


31-34: Include paths correctly updated for the new directory structure.

The include paths have been properly updated to match the new directory structure and file names, ensuring correct dependencies.


38-38: Updated dictionary to store TaskCondition objects.

Dictionary type has been correctly changed to store TaskCondition objects instead of Condition objects.


81-82: Object type references updated to TaskCondition.

All condition object instantiations have been correctly changed from Condition to TaskCondition, maintaining the same functionality while aligning with the refactoring effort.

Also applies to: 95-96, 109-111, 113-115, 157-159, 189-191


129-130: Updated indicator condition instantiations.

Indicator condition tests were correctly updated to use TaskCondition objects while preserving the same test logic.

Also applies to: 132-133, 135-136, 138-139, 141-142, 144-145

Task/tests/TaskAction.test.mq5 (4)

24-24: Updated file documentation to reflect TaskAction focus.

The file documentation has been correctly updated to reflect that this test file now focuses on the TaskAction class rather than the Action class.


34-37: Include paths correctly updated for the new directory structure.

The include paths have been properly updated to match the new directory structure and file names, ensuring correct dependencies.


42-42: Updated dictionary to store TaskAction objects.

Dictionary type has been correctly changed to store TaskAction objects instead of Action objects.


82-83: Object type references updated to TaskAction.

Action object instantiations have been correctly changed to TaskAction, maintaining the same functionality while aligning with the refactoring effort.

Also applies to: 87-88

Serializer.mqh (3)

40-40: Added forward declaration for IndicatorBase class.

Good practice to add the forward declaration for IndicatorBase before it's used in template specialization later in the code.


60-60: Constructor updated with default parameter value.

The constructor now has a default value of 0 for the flags parameter, which makes instantiation more flexible.


382-395: Added specialized Pass template for IndicatorBase pointers.

This specialized template overload properly handles serialization of IndicatorBase pointers while explicitly preventing deserialization with a clear error message. The use of nullptr for the error case aligns with modern C++ practices.

Trade/tests/TradeSignalEnumMacro.test.mq5 (4)

22-25: Added proper includes for test functionality.

The test file correctly includes the necessary headers for test assertions and the trade signal structures being tested.


26-66: Comprehensive test cases for trade signal macros.

The test function systematically verifies all combinations of signal flags to ensure that:

  1. Only the main signal flag alone returns true for each category
  2. Any combination including filter or time filter flags returns false
  3. The absence of the main flag always returns false

This is thorough test coverage for the macro behavior.


29-37: Well-structured trade signal test cases by signal type.

The test cases are well-organized by signal type (CLOSE_BUY, CLOSE_SELL, OPEN_BUY, OPEN_SELL), making it easy to understand and maintain. Each section follows the same pattern, ensuring consistent test coverage.

Also applies to: 38-46, 48-56, 57-65


71-73: Simple but effective OnInit implementation.

The OnInit function simply calls the testEnum function, which is a clean approach for a focused test file. This ensures all tests run during initialization.

Task/TaskAction.struct.h (5)

22-25: Good refactoring to use more specific TaskAction terminology.

The file header comment now correctly specifies that this file contains TaskAction structs rather than generic Action structs, which aligns with the broader refactoring effort across the codebase.


33-44: Improved include organization and dependency management.

The includes have been reordered and updated to use relative paths, adding specific enum headers earlier in the list. This better organizes dependencies and makes the file's requirements clearer.


46-55: Consistent renaming of struct and member comments.

The renaming from ActionEntry to TaskActionEntry is consistent with the broader refactoring. Comments for members like flags, action_id, type, and args have been properly updated to reflect the TaskAction terminology.


57-65: Consistent constructor signatures update.

All constructors have been renamed from ActionEntry to TaskActionEntry, maintaining consistency with the struct name change while preserving the same initialization logic.


67-69: Proper destructor renaming.

The destructor has been properly renamed to match the new struct name.

Task/TaskCondition.enum.h (5)

22-25: Good refactoring to use more specific TaskCondition terminology.

The file header comment now correctly specifies that this file contains TaskCondition's enums rather than generic Condition enums, aligning with the broader refactoring effort.


87-94: Consistent enum renaming.

The enum has been renamed from ENUM_CONDITION_ENTRY_FLAGS to ENUM_TASK_CONDITION_ENTRY_FLAGS, while preserving the same flag values for backward compatibility.


97-102: Consistent enum type renaming.

The enum has been renamed from ENUM_CONDITION_STATEMENT to ENUM_TASK_CONDITION_STATEMENT, maintaining the same enum values for backward compatibility.


105-120: Proper condition type renaming with updated comment.

The enum has been renamed from ENUM_CONDITION_TYPE to ENUM_TASK_CONDITION_TYPE, and the comment for COND_TYPE_ACTION has been updated to reference TaskAction instead of Action.


167-176: Updated comment for clarity.

The comment now correctly specifies "TaskAction conditions" instead of "Action conditions", maintaining consistency in the terminology.

Task/Task.struct.h (4)

33-36: Updated include paths to reflect new file names.

The include paths now reference the renamed TaskAction.struct.h and TaskCondition.struct.h files, maintaining proper dependency management.


39-45: Consistent member type renaming.

The types for action and cond members have been properly updated from ActionEntry and ConditionEntry to TaskActionEntry and TaskConditionEntry, along with their comments.


47-51: Updated constructor signature.

The constructor now accepts TaskActionEntry and TaskConditionEntry types, and uses ENUM_TASK_CONDITION_TYPE instead of ENUM_CONDITION_TYPE.


82-85: Updated getter return types.

The getter methods now properly return TaskActionEntry and TaskConditionEntry types, and ENUM_TASK_CONDITION_TYPE instead of ENUM_CONDITION_TYPE.

Task/TaskAction.h (9)

32-40: Updated class declarations and include paths.

The forward class declaration has been properly renamed to TaskAction, and the include paths now reference the renamed TaskAction and TaskCondition files.


41-44: Class renamed to reflect task-specific purpose.

The class has been appropriately renamed from Action to TaskAction, along with its comment, making its purpose more explicit.


52-53: Updated actions dictionary type.

The actions dictionary now uses TaskActionEntry instead of ActionEntry, maintaining consistency with the struct renaming.


59-81: Updated constructor signatures and implementations.

All constructors have been renamed to TaskAction and updated to create TaskActionEntry instances instead of ActionEntry instances.


95-98: Updated iterator types.

The iterator types and value retrieval have been updated to work with TaskActionEntry instead of ActionEntry.


112-117: Updated Execute method signature and implementation.

The Execute method now accepts a TaskActionEntry reference and casts the object to TaskAction instead of Action.


331-332: Updated method call to use TaskAction.

The method call has been properly updated to use TaskAction::CheckCondition instead of Action::CheckCondition.


371-372: Updated method call to use TaskAction.

The method call has been properly updated to use TaskAction::ExecuteAction instead of Action::ExecuteAction.


324-328:

✅ Verification successful

Changed error handling behavior.

The method now returns false immediately after logging an error, rather than continuing to the end of the method. This is a behavioral change that might affect error handling.

Please verify that all calling code expects this immediate return behavior. Run the following script to find all calls to this method:


🏁 Script executed:

#!/bin/bash
# Find all calls to CheckCondition to verify they handle the new immediate return behavior
rg -A 3 $'CheckCondition\s*\(\s*ENUM_ACTION_CONDITION'

Length of output: 505


No external callers affected by early return
A search for all invocations of CheckCondition(ENUM_ACTION_CONDITION…) only returned its two definitions in Task/TaskAction.h (the overloaded wrapper and the main implementation). There are no other call sites, so the new immediate-false return won’t break any upstream code.

Task/TaskCondition.struct.h (1)

97-108: TODO placeholders block functionality

AddArg() and SetArgs() are currently empty stubs with @todo comments.
Any caller relying on argument storage will silently lose data.

Please implement or at least assert/alert so that incorrect usage is caught early.

Comment on lines +87 to +89
#ifndef ULONG_MAX
#define ULONG_MAX std::numeric_limits<short>::max()
#endif
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix incorrect type in ULONG_MAX definition

The ULONG_MAX macro is incorrectly using short type instead of unsigned long.

#ifndef ULONG_MAX
-#define ULONG_MAX std::numeric_limits<short>::max()
+#define ULONG_MAX std::numeric_limits<unsigned long>::max()
#endif

This will cause ULONG_MAX to return a much smaller value than expected (maximum value of short instead of unsigned long), potentially leading to buffer overflows or other memory safety issues.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#ifndef ULONG_MAX
#define ULONG_MAX std::numeric_limits<short>::max()
#endif
#ifndef ULONG_MAX
#define ULONG_MAX std::numeric_limits<unsigned long>::max()
#endif
🤖 Prompt for AI Agents
In Math.define.h around lines 87 to 89, the ULONG_MAX macro is incorrectly
defined using std::numeric_limits<short>::max(), which gives the maximum value
of a short instead of an unsigned long. To fix this, change the type in
std::numeric_limits from short to unsigned long so that ULONG_MAX correctly
represents the maximum value of an unsigned long.

@@ -121,7 +121,7 @@ class DictIteratorBase {
bool IsLast() {
if (!IsValid()) return true;

if (_dict PTR_DEREF GetMode() == DictModeUnknown || _dict.Size() == 0) {
if (_dict PTR_DEREF GetMode() == DictModeUnknown || _dict PTR_DEREF Size() == 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fixed pointer dereferencing in IsLast method.

The code now properly dereferences the _dict pointer before calling the Size() method, making it consistent with other pointer dereferencing patterns in the file and preventing potential runtime errors.

🤖 Prompt for AI Agents
In DictIteratorBase.mqh at line 124, the pointer _dict was not properly
dereferenced before calling the Size() method, which can cause runtime errors.
Fix this by ensuring _dict is dereferenced using PTR_DEREF before calling
Size(), matching the dereferencing style used with GetMode() and maintaining
consistency.

Comment on lines +306 to +309
#define SET_BUFFER_AS_SERIES_RELEASE_ENSURER_BEGIN(NUM_BUFFS) \
AsSeriesReleaseEnsurer _as_series_release_ensurer(NUM_BUFFS);
#define SET_BUFFER_AS_SERIES_RELEASE_ENSURER_END(NUM_BUFFS) _as_series_release_ensurer.done(NUM_BUFFS);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Macro variable name will collide on multiple acquisitions

SET_BUFFER_AS_SERIES_RELEASE_ENSURER_BEGIN instantiates a variable named _as_series_release_ensurer without any attempt at uniquifying it.
If two ACQUIRE_BUFFERx macros are used in the same lexical scope, the second expansion redeclares the same variable → compilation error.

Consider incorporating __COUNTER__ (or __LINE__ as a fallback for MQL) to make the name unique per expansion.

🤖 Prompt for AI Agents
In Std.h around lines 306 to 309, the macros
SET_BUFFER_AS_SERIES_RELEASE_ENSURER_BEGIN and
SET_BUFFER_AS_SERIES_RELEASE_ENSURER_END declare a variable named
_as_series_release_ensurer without uniqueness, causing redeclaration errors if
used multiple times in the same scope. Modify the macros to append __COUNTER__
or __LINE__ to the variable name to ensure each expansion creates a uniquely
named variable, preventing collisions during compilation.

Comment on lines +278 to +304
// Ensures that we do RELEASE_BUFFERx after ACQUIRE_BUFFERx.
struct AsSeriesReleaseEnsurer {
bool released;
int num_buffs;
AsSeriesReleaseEnsurer(int _num_buffs) : released(false), num_buffs(_num_buffs) {}
void done(int _num_buffs) {
if (_num_buffs != num_buffs) {
Alert("You have acquired ", num_buffs, " buffers via ACQUIRE_BUFFER", num_buffs,
"(), but now trying to release with mismatched RELEASE_BUFFER", _num_buffs, "()!");
DebugBreak();
}

if (released) {
Alert("You have used RELEASE_BUFFER", num_buffs, "() again which is not required!");
DebugBreak();
}

released = true;
}
~AsSeriesReleaseEnsurer() {
if (!released) {
Alert("You have used ACQUIRE_BUFFER", num_buffs, "() but didn't release buffer(s) via RELEASE_BUFFER", num_buffs,
"() before returning from the scope!");
DebugBreak();
}
}
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Alert / DebugBreak will break C++ compilation

The helper struct AsSeriesReleaseEnsurer unconditionally calls Alert() and DebugBreak() which only exist in the MQL runtime. When the same header is compiled in the C++ tool-chain ( e.g. unit-tests, host utilities ) the build will fail with unknown identifiers.

-      Alert("You have acquired ", num_buffs, ...
-      DebugBreak();
+  #ifdef __MQL__
+      Alert("You have acquired ", num_buffs, ...
+      DebugBreak();
+  #else
+      std::cerr << "[ACQUIRE/RELEASE mismatch] expected " << num_buffs
+                << " but got " << _num_buffs << std::endl;
+      std::abort();
+  #endif

Please wrap every Alert/DebugBreak call (also in the destructor) in an #ifdef __MQL__ guard or provide portable fall-backs so that dual compilation continues to work.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In Std.h around lines 278 to 304, the calls to Alert() and DebugBreak() inside
the AsSeriesReleaseEnsurer struct cause compilation errors in the C++ tool-chain
because these functions only exist in the MQL runtime. To fix this, wrap every
Alert() and DebugBreak() call, including those in the destructor, with #ifdef
__MQL__ preprocessor guards to ensure they are only compiled in the MQL
environment. Alternatively, provide portable fallback implementations for these
functions when compiling in C++ to maintain dual compilation compatibility.

Comment on lines +58 to 59
DictStruct<short, TaskConditionEntry> conds;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Dictionary member should store values, not pointers

conds is declared as a concrete DictStruct<short, TaskConditionEntry> object.
However the copy-constructor assigns a pointer to it:

TaskCondition(TaskCondition &_cond) {          // line 93
    conds = _cond.GetConditions();             // <- pointer-to-object
}

DictStructDictStruct* is not a valid assignment and will fail to compile.

-    conds = _cond.GetConditions();
+    conds = *(_cond.GetConditions());

(or store the pointer instead).

🤖 Prompt for AI Agents
In Task/TaskCondition.h around lines 58-59 and 93, the member 'conds' is a
DictStruct object but the copy constructor assigns a pointer returned by
_cond.GetConditions() to it, causing a type mismatch. To fix this, modify the
copy constructor to assign the actual DictStruct object returned by
GetConditions(), not a pointer, or change 'conds' to store a pointer if pointer
semantics are intended. Ensure the assignment matches the declared type of
'conds'.

// 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; }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Illegal assignment to this in copy-constructor

void TaskConditionEntry(TaskConditionEntry &_ce) { this = _ce; }

this is a read-only pointer – assigning to it is undefined behaviour and disallowed in both C++ and MQL.
Copy each field or simply delegate to the assignment operator:

-  TaskConditionEntry(TaskConditionEntry &_ce) { this = _ce; }
+  TaskConditionEntry(const TaskConditionEntry &_ce) { *this = _ce; }

(also make the parameter const).

🤖 Prompt for AI Agents
In Task/TaskCondition.struct.h at line 58, the copy constructor attempts to
assign to the read-only pointer `this`, which is illegal. To fix this, change
the parameter to a const reference and copy each member field individually or
delegate to the assignment operator by calling `*this = _ce;` inside the
constructor body.

Comment on lines +56 to +70
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() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Constructors/destructor use invalid syntax

The struct declares its (copy-)constructors and destructor with a return type void, e.g.

void TaskConditionEntry() : type(...           // line 56
void ~TaskConditionEntry() {                   // line 70

In C++/MQL constructors and destructors must not specify a return type.
This will not compile.

-  void TaskConditionEntry() : type(FINAL_CONDITION_TYPE_ENTRY), cond_id(WRONG_VALUE) { Init(); }
+  TaskConditionEntry() : type(FINAL_CONDITION_TYPE_ENTRY), cond_id(WRONG_VALUE) { Init(); }

-  void ~TaskConditionEntry() {
+  ~TaskConditionEntry() {

Repeat for every constructor overload.

🤖 Prompt for AI Agents
In Task/TaskCondition.struct.h between lines 56 and 70, remove the 'void' return
type from all constructor and destructor declarations, as constructors and
destructors in C++/MQL must not have a return type. Change lines like 'void
TaskConditionEntry()' to 'TaskConditionEntry()' and 'void ~TaskConditionEntry()'
to '~TaskConditionEntry()' for all constructor overloads and the destructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants