bifurcado de nique_372/AiDataTaskRuner
126 líneas
3,9 KiB
MQL5
126 líneas
3,9 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| Saver.mqh |
|
|
//| Copyright 2025, Niquel Mendoza. |
|
|
//| https://www.mql5.com/es/users/nique_372 |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2025, Niquel Mendoza."
|
|
#property link "https://www.mql5.com/es/users/nique_372"
|
|
#property strict
|
|
|
|
#ifndef AIDATATASKRUNNER_BACKEND_BASES_SAVER_MQH
|
|
#define AIDATATASKRUNNER_BACKEND_BASES_SAVER_MQH
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#include "Defines.mqh"
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CTaskSaver : public CLoggerBase
|
|
{
|
|
public:
|
|
CTaskSaver(void) {}
|
|
~CTaskSaver(void) {}
|
|
|
|
//---
|
|
bool Load(const string& file_name, TaskTester& out[], int& size, int file_common);
|
|
bool Save(const string& file_name, TaskTester& out[], int size, int file_common, bool filter);
|
|
};
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
bool CTaskSaver::Save(const string &file_name, TaskTester &out[], int size, int file_common, bool filter)
|
|
{
|
|
//---
|
|
::ResetLastError();
|
|
const int fh = FileOpen(file_name, FILE_WRITE | FILE_CSV | file_common);
|
|
if(fh == INVALID_HANDLE)
|
|
{
|
|
LogError(StringFormat("Fallo al abrir el archivo = %s, ultimo error = %d", file_name, ::GetLastError()), FUNCION_ACTUAL);
|
|
return false;
|
|
}
|
|
//---
|
|
FileWrite(fh, "Timeframe,Symbol,SetFile,SymbolFolderName,Label,LabelId,StartDate,EndDate");
|
|
|
|
//---
|
|
for(int i = 0; i < size; i++)
|
|
{
|
|
if(filter && (out[i].state == AIEXECUTOR_TASK_STATE_IN_PROCESS
|
|
|| out[i].state == AIEXECUTOR_TASK_STATE_IN_QUEQE
|
|
|| out[i].state == AIEXECUTOR_TASK_STATE_PENDIENTE))
|
|
FileWrite(fh, out[i].ToString());
|
|
}
|
|
|
|
//---
|
|
FileClose(fh);
|
|
return true;
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
bool CTaskSaver::Load(const string &file_name, TaskTester& out[], int& size, int file_common)
|
|
{
|
|
//---
|
|
if(FileIsExist(file_name))
|
|
{
|
|
//---
|
|
::ResetLastError();
|
|
const int fh = FileOpen(file_name, FILE_READ | FILE_CSV | file_common);
|
|
if(fh == INVALID_HANDLE)
|
|
{
|
|
LogError(StringFormat("Fallo al abrir el archivo = %s, ultimo error = %d", file_name, ::GetLastError()), FUNCION_ACTUAL);
|
|
return false;
|
|
}
|
|
|
|
//---
|
|
FileReadString(fh); // Cabezera
|
|
|
|
//---
|
|
size = ArrayResize(out, 0);
|
|
|
|
//---
|
|
string arr[8];
|
|
while(FileIsEnding(fh))
|
|
{
|
|
if(StringSplit(FileReadString(fh), ',', arr) != 8)
|
|
{
|
|
LogWarning("Linea invalida omitida", FUNCION_ACTUAL);
|
|
continue;
|
|
}
|
|
out[ArrayResize(out, (++size)) - 1].Assing(arr);
|
|
}
|
|
|
|
|
|
//---
|
|
FileClose(fh);
|
|
}
|
|
else
|
|
{
|
|
LogWarning("No se enocnrro un archivo del cual cargar", FUNCION_ACTUAL);
|
|
}
|
|
|
|
|
|
//---
|
|
return true;
|
|
}
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
/*
|
|
ExpertPath=ICTRaptor.ex5
|
|
MainFolder=ICTKiller\\
|
|
TemporalFIleName=none
|
|
MoveFilesName=pred.csv,sl.csv,tp.csv,scaler_tp.csv,scaler_sl.csv,scaler_pred.csv
|
|
|
|
*/
|
|
|
|
/*
|
|
Timeframe,Symbol,SetFile,SymbolFolderName,Label,LabelId,StartDate,EndDate
|
|
1,XAUUSD,ICTKiller\\XAUUSD\\M1\\Best\\data.set,XAUUSD,Best,0,2025.01.01 10:10:10,2026.01.01
|
|
*/
|
|
|
|
//+------------------------------------------------------------------+
|
|
#endif // AIDATATASKRUNNER_BACKEND_BASES_SAVER_MQH
|