ICTLibraryEasy/Src/Base/Data.mqh

95 lines
4 KiB
MQL5
Raw Permalink Normal View History

2026-05-25 11:41:23 -05:00
//+------------------------------------------------------------------+
2025-12-05 12:17:19 -05:00
//| Data.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 ICTLIBRARYEASY_SRC_BASE_DATA_MQH
#define ICTLIBRARYEASY_SRC_BASE_DATA_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
2026-05-25 11:41:23 -05:00
#include "Defines.mqh"
2025-12-05 12:17:19 -05:00
//+------------------------------------------------------------------+
2026-05-25 11:41:23 -05:00
//| Clase base para manejar simbolos |
2025-12-05 12:17:19 -05:00
//+------------------------------------------------------------------+
2026-05-25 11:41:23 -05:00
class CIctSymbol final
2025-12-05 12:17:19 -05:00
{
private:
2026-05-25 11:41:23 -05:00
int16_t obj_count;
2025-12-05 12:17:19 -05:00
public:
2026-05-25 11:41:23 -05:00
CIctSymbol(const string& symb);
~CIctSymbol() {}
//---
const string symbol;
MqlTick _tick;
const double point_value;
const int8_t _digits;
//---
__forceinline void GetTick(MqlTick& tick) const;
datetime tick_time; // Hora de la última actualización de precios
double tick_bid; // Precio actual Bid
double tick_ask; // Precio actual Ask
double tick_last; // Precio actual de la última transacción (Last)
ulong tick_volume; // Volumen para el precio actual Last
long tick_time_msc; // Hora de la última actualización de los precios en milisegundos
uint tick_flags; // Banderas de los tics
2025-12-05 12:17:19 -05:00
2026-05-25 11:41:23 -05:00
//--- Actulizacion data
void UpdateTick();
inline void IncrementCoount() { obj_count++; }
inline void DecrementCoount() { obj_count--; }
2025-12-05 12:17:19 -05:00
2026-05-25 11:41:23 -05:00
//--- Utilidades
inline double DistanceToPointDouble(double distance) const { return distance / point_value; }
inline long DistanceToPointLong(double distance) const { return long(::MathRound(distance / point_value)); }
//--- Getters
inline int GetCounter() const { return obj_count; }
__forceinline bool IsPriceEqual(const double v1, const double v2) const { return fabs(v1 - v2) < this.point_value; }
//--- Operadores
bool operator==(const CIctSymbol &other) const { return this.symbol == other.symbol; }
bool operator==(const CIctSymbol* other) const { return other == NULL ? false : this.symbol == other.symbol; }
2025-12-05 12:17:19 -05:00
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
2026-05-25 11:41:23 -05:00
CIctSymbol::CIctSymbol(const string& symb)
: symbol(symb), point_value(::SymbolInfoDouble(symb, SYMBOL_POINT)), _digits((int8_t)::SymbolInfoInteger(this.symbol, SYMBOL_DIGITS))
2025-12-05 12:17:19 -05:00
{
2026-05-25 11:41:23 -05:00
}
2025-12-05 12:17:19 -05:00
2026-05-25 11:41:23 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CIctSymbol::UpdateTick(void)
{
::SymbolInfoTick(this.symbol, this._tick);
this.tick_ask = _tick.ask;
this.tick_bid = _tick.bid;
this.tick_flags = _tick.flags;
this.tick_last = _tick.last;
this.tick_time = _tick.time;
this.tick_time_msc = _tick.time_msc;
this.tick_volume = _tick.volume;
2025-12-05 12:17:19 -05:00
}
//+------------------------------------------------------------------+
2026-05-25 11:41:23 -05:00
__forceinline void CIctSymbol::GetTick(MqlTick &tick) const
{
tick = _tick;
}
//+------------------------------------------------------------------+
2025-12-05 12:17:19 -05:00
#endif // ICTLIBRARYEASY_SRC_BASE_DATA_MQH