2026-09-15 11:21:44 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| 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
|
| | |
|
2026-09-16 10:10:34 -05:00 | | | #ifndef SCALERBYLEO_SRC_SCALER_SCALERBASE_MQH
|
| | | #define SCALERBYLEO_SRC_SCALER_SCALERBASE_MQH
|
2026-09-15 11:21:44 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-09-16 10:10:34 -05:00 | | | #include "Defines.mqh"
|
2026-09-15 11:21:44 -05:00 | | | #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;
|
2026-09-16 10:10:34 -05:00 | | | ENUM_SCALERBYLEO_TYPE m_type; // lo inicializa cada hija en su constructor
|
2026-09-15 11:21:44 -05:00 | | |
|
| | | public:
|
| | | ScalerBase(void);
|
| | | ~ScalerBase(void) {}
|
| | |
|
2026-09-16 10:10:34 -05:00 | | | //--- Tipo
|
| | | __forceinline ENUM_SCALERBYLEO_TYPE Type() const { return m_type; }
|
| | |
|
2026-09-15 11:21:44 -05:00 | | | //--- Rango
|
2026-09-15 12:10:28 -05:00 | | | inline void SetRangeEscaler(ulong start, long count = LONG_MAX); // Custom
|
| | | inline void SetRangeEscaler(long count = -1); // Excluir últimas N columnas
|
2026-09-15 11:21:44 -05:00 | | |
|
| | | //--- 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; }
|
2026-09-15 12:10:28 -05:00 | | | __forceinline void ResetLastErr() { m_last_err = SCALERBYLEO_ERR_NONE; }
|
2026-09-15 11:21:44 -05:00 | | |
|
| | | //--- 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),
|
2026-09-16 10:10:34 -05:00 | | | m_loaded_scaler(false), m_reconstruir(false), m_last_err(SCALERBYLEO_ERR_NONE),
|
| | | m_type(SCALERBYLEO_SCALER_TYPE_MINMAX)
|
2026-09-15 11:21:44 -05:00 | | | {
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-09-15 12:10:28 -05:00 | | | inline void ScalerBase::SetRangeEscaler(ulong start, long count = LONG_MAX)
|
2026-09-15 11:21:44 -05:00 | | | {
|
| | | 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);
|
| | | }
|
| | | }
|
2026-09-16 10:10:34 -05:00 | | | #endif // SCALERBYLEO_SRC_SCALER_SCALERBASE_MQH
|
2026-09-15 11:21:44 -05:00 | | | //+------------------------------------------------------------------+
|