//+------------------------------------------------------------------+ //| ScalerBase.mqh | //| Copyright 2026, Leo. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2026, Leo." #property link "https://www.mql5.com/en/users/nique_372" #property strict #ifndef SCALERBYLEO_SRC_SCALER_SCALERBASE_MQH #define SCALERBYLEO_SRC_SCALER_SCALERBASE_MQH //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #include "Defines.mqh" #include "..\\..\\..\\MQLArticles\\Utils\\Basic.mqh" //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ namespace TSN { //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #define SCALER_BASE_MIN_VALUE 1e-10 //+------------------------------------------------------------------+ //| Scaler Base | //+------------------------------------------------------------------+ class ScalerBase { protected: ulong m_i_start; // Columna/índice de inicio del rango a escalar long m_i_count; // >0: N elementos desde m_i_start | <0: excluir |N| del final | LONG_MAX: todo string m_file_name_out; string m_prefix_file; bool m_loaded_scaler; bool m_reconstruir; // true: el output conserva el tamaño total (afuera del rango queda sin tocar) ENUM_SCALERBYLEO_ERROR m_last_err; ENUM_SCALERBYLEO_TYPE m_type; // lo inicializa cada hija en su constructor public: ScalerBase(void); ~ScalerBase(void) {} //--- Tipo __forceinline ENUM_SCALERBYLEO_TYPE Type() const { return m_type; } //--- Rango inline void SetRangeEscaler(ulong start, long count = LONG_MAX); // Custom inline void SetRangeEscaler(long count = -1); // Excluir últimas N columnas //--- Reconstrucción de salida inline void SetReconstruir(bool val) { m_reconstruir = val; } inline bool GetReconstruir() const { return m_reconstruir; } //--- Error inline ENUM_SCALERBYLEO_ERROR GetLastScalerError() const { return m_last_err; } __forceinline void ResetLastErr() { m_last_err = SCALERBYLEO_ERR_NONE; } //--- Común inline string GetOutputFile() const { return m_file_name_out; } //--- Carga virtual bool LoadByArr(const string &arr[]) = 0; bool LoadByStr(const string &str, const ushort separator); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ ScalerBase::ScalerBase(void) : m_i_start(0), m_i_count(LONG_MAX), m_file_name_out(NULL), m_prefix_file(NULL), m_loaded_scaler(false), m_reconstruir(false), m_last_err(SCALERBYLEO_ERR_NONE), m_type(SCALERBYLEO_SCALER_TYPE_MINMAX) { } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ inline void ScalerBase::SetRangeEscaler(ulong start, long count = LONG_MAX) { m_i_start = start; m_i_count = count; } //+------------------------------------------------------------------+ inline void ScalerBase::SetRangeEscaler(long count = -1) { m_i_start = 0; m_i_count = count; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool ScalerBase::LoadByStr(const string &str, const ushort separator) { string arr[]; if(StringSplit(str, separator, arr) <= 0) { m_last_err = SCALERBYLEO_ERR_INVALID_DATA; return false; } return LoadByArr(arr); } } #endif // SCALERBYLEO_SRC_SCALER_SCALERBASE_MQH //+------------------------------------------------------------------+