geforkt von nique_372/MQLArticles
//+------------------------------------------------------------------+
| |
//| Def.mqh |
| |
//| Copyright 2026, Niquel Mendoza. |
| |
//| https://www.mql5.com |
| |
//+------------------------------------------------------------------+
| |
#property copyright "Copyright 2026, Niquel Mendoza."
| |
#property link "https://www.mql5.com"
| |
#property strict
| |
| |
#ifndef MQLARTICLES_ACCOUNT_RM_LOSSPROFIT_BASES_DEF_MQH
| |
#define MQLARTICLES_ACCOUNT_RM_LOSSPROFIT_BASES_DEF_MQH
| |
| |
//+------------------------------------------------------------------+
| |
//| Include |
| |
//+------------------------------------------------------------------+
| |
#include "..\\..\\\..\\MoneyStatus\\Manager.mqh"
| |
#include "..\\\..\\Bases\\Functions.mqh"
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
namespace TSN
| |
{
| |
//+------------------------------------------------------------------+
| |
//| Defines |
| |
//+------------------------------------------------------------------+
| |
//---
| |
class CLossProfit; // Class to handle maximum losses or gains
| |
class CLossProfitManager; // Container class to manage CLossProfit objects
| |
| |
| |
//---
| |
#define MAX_VAL_DEFINES_CLOSS_PROFIT (DBL_MAX)
| |
#define MIN_VAL_DEFINES_CLOSE_PROFIT (0.0)
| |
| |
//---
| |
#define TSNMQLART_ACCST_RMLP_DYNCTYPE_NEG (0)
| |
#define TSNMQLART_ACCST_RMLP_DYNCTYPE_POS (1)
| |
#define TSNMQLART_ACCST_RMLP_DYNCTYPE_NEG_POS (2)
| |
#define TSNMQLART_ACCST_RMLP_DYNCTYPE_INV (3)
| |
| |
//---
| |
__forceinline bool LossProfitEmptyFuncionSup(const double value, const double saved_value, void* ptr) { return false; }
| |
| |
//---
| |
enum ENUM_TYPE_LOSS_PROFIT
| |
{
| |
LP_GMLPO = 0, // Maxima perdida por operacion (base % a arriesgar)
| |
| |
//---
| |
LP_MDL, // Maxima perdida diaria
| |
LP_MWL, // Maxima perdida semanal
| |
LP_MML, // Maxima perdida mensual
| |
LP_ML, // Maxima perdida total
| |
LP_ML_PICO, // Maxima perdida desde el pico
| |
| |
//---
| |
LP_MDP, // Maxima ganancia diaria
| |
LP_MWP, // Maxima ganancia semanal
| |
LP_MMP, // Maxima ganancia mensual
| |
LP_MP, // Maxima ganancia total
| |
LP_MP_BAJO, // Maxima ganancia desde el bajo
| |
| |
//---
| |
LP_TOTAL, // Total
| |
};
| |
| |
//---
| |
TSNSTD_STATIC_ASSERT(LP_GMLPO == 0
| |
&& LP_MDL == 1 && LP_MWL == 2 && LP_MML == 3 && LP_ML == 4 && LP_ML_PICO == 5
| |
&& LP_MDP == 6 && LP_MWP == 7 && LP_MMP == 8 && LP_MP == 9 && LP_MP_BAJO == 10 && LP_TOTAL == 11,
| |
tsnqmalrt_rm_lp_check_values)
| |
| |
//--- NOTA: solo funciona para las perdidas\ganancias en base a preiodos (Diario,Semanal,Mensual)
| |
// los demas pico y total cada uno decidie como lo maneja
| |
// dado que depende de como lo tomes peudes hacer varias cosas.
| |
#define TSNMQLART_RM_LP_M_BEVENTS_F_LOSS(LP_TYPE) BASICEVENT_REF_FLAG_MAKE((LP_TYPE)-TSN::LP_MDL)
| |
#define TSNMQLART_RM_LP_M_BEVENTS_F_PROFIT(LP_TYPE) BASICEVENT_REF_FLAG_MAKE((LP_TYPE)-TSN::LP_MDP)
| |
| |
//---
| |
enum ENUM_LOSS_PROFIT
| |
{
| |
T_LOSS,
| |
T_PROFIT,
| |
T_GMLPO
| |
};
| |
| |
//--- Tipos basicos
| |
#define LOSSPROFIT_TYPE_GMLPO (LP_GMLPO) // Tipo base % a arriesgar
| |
| |
//---
| |
#define LOSSPROFIT_TYPE_MDL (LP_MDL) // Maxima perdida diaria
| |
#define LOSSPROFIT_TYPE_MWL (LP_MWL) // Maxima perdida semanal
| |
#define LOSSPROFIT_TYPE_MML (LP_MML) // Maxima perdida mensual
| |
#define LOSSPROFIT_TYPE_ML (LP_ML) // Maxima perdida
| |
#define LOSSPROFIT_TYPE_MDDPICO (LP_ML_PICO) // Maxima perdida desde nuevo pico de la cuenta
| |
| |
//---
| |
#define LOSSPROFIT_TYPE_MDP (LP_MDP) // Maxima ganancia diaria
| |
#define LOSSPROFIT_TYPE_MWP (LP_MWP) // Maxima ganancia semanal
| |
#define LOSSPROFIT_TYPE_MMP (LP_MMP) // Maxima ganancia mensual
| |
#define LOSSPROFIT_TYPE_MP (LP_MP) // Maxima ganancia
| |
#define LOSSPROFIT_TYPE_MDDBAJO (LP_MP_BAJO) // Maxima ganancia desde el bajo de la cuenta
| |
| |
//--- Losses Profits
| |
#define LOSS_PROFIT_COUNT (LP_TOTAL)
| |
#define LOSS_PROFIT_COUNT_MAXTYPE (6)
| |
| |
//---
| |
const string g_mqarticles_lp_str_names[LOSS_PROFIT_COUNT]
| |
{
| |
"GMLPO",
| |
"Maxium daily loss",
| |
"Maxium weekly loss",
| |
"Maxium monthly loss",
| |
"Maxium loss",
| |
"Maxium loss PICO",
| |
"Maxium daily profit",
| |
"Maxium weekly profit",
| |
"Maxium monthly profit",
| |
"Maxium profit",
| |
"Maxium profit BAJO",
| |
};
| |
| |
//---
| |
#ifndef TSN_MQLART_RM_LP_NAME
| |
#define TSN_MQLART_RM_LP_NAME(TYPE) g_mqarticles_lp_str_names[TYPE]
| |
#endif // TSN_MQLART_RM_LP_NAME
| |
| |
| |
//---
| |
enum ENUM_TSNMQLART_RM_LP_RES
| |
{
| |
TSNMQLART_RM_LP_RES_OK,
| |
| |
//---
| |
TSNMQLART_RM_LP_RES_LPDYNC_ERR_INVALID_SIZE,
| |
TSNMQLART_RM_LP_RES_LPDYNC_ERR_MALFORMED_VALUES,
| |
TSNMQLART_RM_LP_RES_LPDYNC_ERR_SIZE_NOT_EQ_ARRS,
| |
| |
TSNMQLART_RM_LP_RES_LPDYNC_ERR_INVALID_CACHE,
| |
TSNMQLART_RM_LP_RES_LPDYNC_ERR_INVALID_VALUE_DYNC_PCTG,
| |
TSNMQLART_RM_LP_RES_LPDYNC_ERR_DYN_PCTG_ADD_HASHMAP
| |
};
| |
| |
//--- Dynamic gmlpo/ Dynamic risk per operation
| |
struct Dynamic_LossProfit
| |
{
| |
double balance_to_activate_the_risk[];
| |
double risk_to_be_adjusted[];
| |
};
| |
| |
| |
//--- Enumeration to define the types of calculation of the value of maximum profits and losses
| |
enum ENUM_RISK_CALCULATION_MODE
| |
{
| |
money = 0, //Money
| |
percentage //Percentage %
| |
};
| |
| |
//---
| |
const string RiskCalcModeToString[2]
| |
{
| |
"Money",
| |
"Percentage"
| |
};
| |
| |
//--- Enumeration to define the value to which the percentages will be applied
| |
enum ENUM_APPLIED_PERCENTAGES
| |
{
| |
Balance = 0, // Balance
| |
ganancianeta, // Net profit
| |
free_margin, // Free margin
| |
equity // Equity
| |
};
| |
| |
| |
//---
| |
// #define MQLARTICLES_RM_LOSSPROFIT_ACTIVEGUARDS
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
//--- typedef
| |
// Superate
| |
typedef bool (*FuncionLossProfitSuperate)(const double, const double, void*);
| |
// Calculate percentage value (recibe el porcentage)
| |
// [calc value], [ptr]
| |
typedef double (*FTSNMQLArtRmPctgVal)(double, void*);
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
#define TSNMQLART_RISKM_NORM_PERCERNTAGE(P) (P/100.0)
| |
#define TSNMQLART_RISKM_NORM_PERCERNTAGE_A(P) P/=100.0
| |
#define TSNMQLART_RISKM_NORM_TO_PERCENTAGE(P) (P*100.0)
| |
| |
//---
| |
}
| |
| |
| |
#endif // MQLARTICLES_ACCOUNT_RM_LOSSPROFIT_BASES_DEF_MQH
| |
//+------------------------------------------------------------------+
|