MQLArticles/Account/RM/RiskManagement/LPMods/Def.mqh
Nique_372 Nique_372 e34ed941c1
2026-10-28 13:32:56 -05:00
66 lines
2.7 KiB
MQL5
//+------------------------------------------------------------------+
//| Modificators.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
#ifndef MQLARTICLES_ACCOUNT_RM_RISKMANAGEMENT_LPMODS_DEF_MQH
#define MQLARTICLES_ACCOUNT_RM_RISKMANAGEMENT_LPMODS_DEF_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "..\\..\\LossProfit\\Manager.mqh"
#include "..\\Hooks\\Def.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
namespace TSN
{
//+--------------------------------------------------------------------+
//| Class to integrate external modifications to risk management |
//+--------------------------------------------------------------------+
class CExtraModifications : public IRiskManagementHook
{
protected:
// NOTA: solo para buen uso, si lo usas mal puede fallar..
CLossProfit* m_modifier;
public:
const int m_property_to_modify; // LP a modificar (Type)
public:
// WRONG_VALUE si no se busca modificar nada,
CExtraModifications(int _property_to_modify, uint8_t flags_events, const string& name)
: IRiskManagementHook(flags_events, name), m_property_to_modify(_property_to_modify) {}
//---
// Function that will be used in CRiskManagement to assign the "maximum loss or profit" based on the type of "maximum loss or profit" chosen
// in the constructor.
bool SetPointer(CLossProfit* _modifier);
};
//+------------------------------------------------------------------+
//| Set pointer |
//+------------------------------------------------------------------+
// asume modifer valido (ojo)
bool CExtraModifications::SetPointer(CLossProfit* _modifier)
{
//---
if(_modifier.m_type != m_property_to_modify)
return false;
//---
m_modifier = _modifier;
return true;
}
//---
}
//+------------------------------------------------------------------+
#endif // MQLARTICLES_ACCOUNT_RM_RISKMANAGEMENT_LPMODS_DEF_MQH
//+------------------------------------------------------------------+