MQLArticles/Utils/FA/ClasesBases.mqh

159 lines
11 KiB
MQL5

2025-09-22 09:08:13 -05:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| ClasesBases.mqh |
//| Copyright 2025, Niquel Mendoza. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
2025-11-10 09:33:53 -05:00
#property copyright "Copyright 2025, Niquel Mendoza."
2025-09-22 09:08:13 -05:00
#property link "https://www.mql5.com"
2025-09-22 09:08:13 -05:00
#property strict
2026-01-28 12:07:29 -05:00
2025-09-22 09:08:13 -05:00
2026-02-13 11:39:07 -05:00
#ifndef MQLARTICLES_UTILS_FA_CLASESBASES_MQH
2025-09-22 09:08:13 -05:00
#define MQLARTICLES_UTILS_FA_CLASESBASES_MQH
2025-09-22 09:08:13 -05:00
//+------------------------------------------------------------------+
//| Includes |
//+------------------------------------------------------------------+
2025-09-22 09:08:13 -05:00
//--- (Eventos basicos | CManagerBase | CSpecializedManager | CLoggerBase)
#include "Events.mqh"
2025-09-22 09:08:13 -05:00
//--- (CBarControler | CBarControlerFast | CAtr | CAtrOptimized | CAtrOptimizedZero | CAtrOptimizedNonZero | CAtrUltraOptimized | CDiff | CDiffAtr | CDiffPoints)
#include "DiffCalc.mqh"
2025-09-22 09:08:13 -05:00
2026-02-14 17:00:45 -05:00
2025-09-22 09:08:13 -05:00
//+------------------------------------------------------------------+
//| Class to detect if the PC has been suspended |
//+------------------------------------------------------------------+
2026-01-06 06:47:46 -05:00
class CSuspendChecker
2025-09-22 09:08:13 -05:00
{
2026-01-06 06:47:46 -05:00
2025-09-22 09:08:13 -05:00
private:
uint m_lastTick; // Last recorded tick
uchar m_threshold; // Threshold in minutes
datetime m_last_time_revised;
public:
// Constructor, sets the time threshold
CSuspendChecker()
2025-09-22 09:08:13 -05:00
{
2025-09-22 09:08:13 -05:00
m_threshold = 2;
m_lastTick = GetTickCount64Minutes; // Initialize with current time
m_last_time_revised = TimeCurrent();
}
2026-02-26 19:01:46 -05:00
2025-09-22 09:08:13 -05:00
// Checks if there has been a suspension
bool CheckForSuspend(const bool flag_new_day, const datetime curr_time)
{
2025-09-22 09:08:13 -05:00
if(TESTER_FLAG)
return false;
2025-09-22 09:08:13 -05:00
const uint currentTick = GetTickCount64Minutes;
m_last_time_revised = curr_time;
m_lastTick = currentTick; // Update the last tick
2025-09-22 09:08:13 -05:00
// If the difference exceeds the threshold, the PC was likely suspended
if(!flag_new_day && (currentTick - m_lastTick) > m_threshold)
2025-09-22 09:08:13 -05:00
return true;
2025-09-22 09:08:13 -05:00
return false;
}
inline datetime GetLasTimeRevised()
{
2025-09-22 09:08:13 -05:00
return this.m_last_time_revised;
}
inline void Threshold(uchar new_minutes)
{
2025-09-22 09:08:13 -05:00
m_threshold = new_minutes;
}
};
//+------------------------------------------------------------------+
//| CConversions Class: price <EFBFBD>! pixels <EFBFBD>! bars |
2025-09-22 09:08:13 -05:00
//+------------------------------------------------------------------+
class CGraphConversion
{
2025-09-22 09:08:13 -05:00
private:
double valor_1_unidad_precio_a_px;
2025-09-22 09:08:13 -05:00
double valor_1_px_a_unidad_precio;
2025-11-10 09:33:53 -05:00
double valor_1_barra_a_px;
2025-09-22 09:08:13 -05:00
double valor_1_px_a_barra;