2025-11-10 09:32:46 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| Defines.mqh |
|
| | | //| Copyright 2025, Niquel Mendoza. |
|
| | | //| https://www.mql5.com/es/users/nique_372/news |
|
| | | //+------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2025, Niquel Mendoza."
|
| | | #property link "https://www.mql5.com/es/users/nique_372/news"
|
| | | #property strict
|
| | |
|
2025-11-12 07:42:02 -05:00 | | | #ifndef MQLARTICLES_POSMGMT_CONDPARTIALS_BASE_DEFINES_MQH
|
| | | #define MQLARTICLES_POSMGMT_CONDPARTIALS_BASE_DEFINES_MQH
|
2025-11-10 09:32:46 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
2025-11-12 16:03:01 -05:00 | | | //| Include |
|
2025-11-10 09:32:46 -05:00 | | | //+------------------------------------------------------------------+
|
2026-10-28 17:19:08 -05:00 | | | #include "..\\..\\..\\Account\\MoneyStatus\\Manager.mqh"
|
2026-09-06 20:42:03 -05:00 | | | #include "..\\..\\..\\Utils\\FA\\DiffCalc.mqh"
|
2026-11-01 20:54:30 -05:00 | | | #include <TSN\\Std\\Memory.mqh>
|
2026-11-05 17:09:00 -05:00 | | | #include <TSN\\Std\\Basics\\ErrManager.mqh>
|
| | | #include <TSN\\Std\\Misce\\BitReinterprete.mqh>
|
2025-11-10 09:32:46 -05:00 | | |
|
2026-09-13 08:47:52 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | namespace TSN
|
| | | {
|
2025-11-10 09:32:46 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| Defines |
|
| | | //+------------------------------------------------------------------+
|
2026-11-01 15:00:25 -05:00 | | | #ifndef CONDITIONAL_PARTIAL_ARR_MAIN_RESERVE
|
2026-08-04 17:02:36 -05:00 | | | #define CONDITIONAL_PARTIAL_ARR_MAIN_RESERVE 16
|
2026-11-01 15:00:25 -05:00 | | | #endif // CONDITIONAL_PARTIAL_ARR_MAIN_RESERVE
|
2025-11-10 09:32:46 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| Interface for partial condition |
|
| | | //+------------------------------------------------------------------+
|
2026-01-29 08:19:47 -05:00 | | | class IConditionPartial : public CAllClassEventsBasic
|
2025-11-10 09:32:46 -05:00 | | | {
|
| | | public:
|
2026-01-31 19:44:40 -05:00 | | | IConditionPartial() {}
|
2026-01-29 08:19:47 -05:00 | | | ~IConditionPartial() {}
|
| | |
|
| | | virtual void OnInitPartials(double initial_price) = 0;
|
2026-02-14 17:00:45 -05:00 | | | virtual void Execute(const datetime current_time) = 0;
|
2026-01-29 08:19:47 -05:00 | | | virtual string Name() const = 0;
|
| | | virtual bool CloseBuy() = 0;
|
| | | virtual bool CloseSell() = 0;
|
2025-11-10 09:32:46 -05:00 | | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| Structures |
|
| | | //+------------------------------------------------------------------+
|
| | | //--- Structure for partial configuration
|
| | | struct ConditionalPartialConfig
|
| | | {
|
| | | //---
|
| | | string str_percentage_volume_to_close;
|
| | | string symbol;
|
2026-11-02 15:21:28 -05:00 | | | IConditionPartial *condition;
|
| | | CDiff *min_distance_to_close_pos;
|
2025-11-10 09:32:46 -05:00 | | | ulong magic_number;
|
2026-11-02 15:21:28 -05:00 | | | bool delete_condition;
|
2025-11-10 09:32:46 -05:00 | | | bool auto_mode;
|
2026-11-02 15:21:28 -05:00 | | | bool constant;
|
| | | bool forze_to_close;
|
2025-11-10 09:32:46 -05:00 | | |
|
| | | //---
|
| | | ConditionalPartialConfig()
|
2026-11-02 15:21:28 -05:00 | | | : str_percentage_volume_to_close(NULL), symbol(_Symbol), magic_number(NOT_MAGIC_NUMBER),
|
| | | condition(NULL), min_distance_to_close_pos(NULL), auto_mode(true), delete_condition(true),
|
| | | constant(false), forze_to_close(false)
|
2025-11-10 09:32:46 -05:00 | | | {
|
| | | }
|
| | | };
|
| | |
|
| | | //--- Structure to store a trackable position (to which partial closes will be applied until its removal)
|
2026-11-02 15:21:28 -05:00 | | | struct pack(8) ConditionalPartialTrackedPositionBase
|
2025-11-10 09:32:46 -05:00 | | | {
|
| | | ulong ticket;
|
| | | double next_min_price;
|
| | | ENUM_POSITION_TYPE type;
|
2026-11-02 15:21:28 -05:00 | | | };
|
| | | struct ConditionalPartialTrackedPosition : ConditionalPartialTrackedPositionBase
|
| | | {
|
2025-11-10 09:32:46 -05:00 | | | int next_index_to_close;
|
2026-11-01 18:06:28 -05:00 | | | int try;
|
2025-11-10 09:32:46 -05:00 | | | };
|
2026-01-29 08:19:47 -05:00 | | |
|
2026-11-02 15:21:28 -05:00 | | | //---
|
| | | enum ENUM_TSNQMLART_CONDPARTIAL_ERR
|
| | | {
|
| | | TSNQMLART_CONDPARTIAL_ERR_NOT,
|
| | | TSNQMLART_CONDPARTIAL_ERR_INVALID_NUM_VOLTOCLOSE_ARR,
|
2026-11-07 09:34:18 -05:00 | | | TSNQMLART_CONDPARTIAL_ERR_MALFORMED_VOLTOCLOSE, // algun volumen del string no se pudo convertir (ToArr devuelve negativo)
|
2026-11-02 15:21:28 -05:00 | | | TSNQMLART_CONDPARTIAL_ERR_INVALID_VOLTOCLOSE_MUSTBE_0_100,
|
| | | TSNQMLART_CONDPARTIAL_ERR_SELECT_POSITION,
|
| | | TSNQMLART_CONDPARTIAL_ERR_INVALID_SYMBOL,
|
| | | TSNQMLART_CONDPARTIAL_ERR_POSITION_NOT_FOUND,
|
| | | };
|
| | |
|
| | | //---
|
| | | #define MQLART_CONDPARTIAL_CONSTANT (31)
|
| | | #define MQLART_CONDPARTIAL_NO_CONSTANT (0)
|
| | |
|
| | | //---
|
| | | #define MQLART_CONDPARTIAL_PBUY uchar
|
| | | #define MQLART_CONDPARTIAL_PSELL ushort
|
2025-11-12 07:42:02 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| Enums |
|
| | | //+------------------------------------------------------------------+
|
| | | enum ENUM_TYPE_CONDITIONAL_PARTIAL_CLASS
|
2026-01-29 08:19:47 -05:00 | | | {
|
2026-11-02 15:21:28 -05:00 | | | CONDITIONAL_PARTIAL_CLASS_TYPE_BASE = 0, // Default conditional partial closures
|
| | | CONDITIONAL_PARTIAL_CLASS_TYPE_CONSTANT // Constant conditional partial closures
|
2026-01-29 08:19:47 -05:00 | | | };
|
| | |
|
2026-10-30 13:37:47 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | //---
|
| | | //--- Por defecto usaremos el round (para manteer compatiblidad)
|
| | | #ifndef MQLART_POSMGMT_CONDPARTIALS_LOTROUND
|
| | | #define MQLART_POSMGMT_CONDPARTIALS_LOTROUND(number, step) TSNMQLART_ROUND_LOTSIZE_F(MathRound, number, step)
|
| | | #endif // MQLART_POSMGMT_CONDPARTIALS_LOTROUND
|
| | |
|
| | |
|
2026-11-01 18:06:28 -05:00 | | | //---
|
| | | #ifndef MQLART_POSMGMT_CONDPARTIALS_TRYDEF
|
| | | #define MQLART_POSMGMT_CONDPARTIALS_TRYDEF (4)
|
| | | #endif // MQLART_POSMGMT_CONDPARTIALS_TRYDEF
|
| | |
|
2026-09-13 08:47:52 -05:00 | | | //---
|
| | | }
|
2025-11-10 09:32:46 -05:00 | | | //+------------------------------------------------------------------+
|
2025-11-12 07:42:02 -05:00 | | | #endif // MQLARTICLES_POSMGMT_CONDPARTIALS_BASE_DEFINES_MQH
|