Download MetaTrader 5

How can I match the current time and datetime in csv file?

To add comments, please log in or register
cape1354
183
cape1354  
The first column in the csv file is the date and the second column is the number between 1 and 100 calculated as the indicater.


When the date column and the test time are correct, the number of columns in the second column is received as a variable.


The double value which second column matches the value I calculate in the current test, and then start the transaction.

However, it is difficult to guess the first column and current time.

Where is the problem?



int CurrentTime;

int i;

bool Max_Average=False;
bool NewBar= false;

int data_size=1000;
string file_name = "max.csv";
double data_double_average[];
string data_double_datetime[];
int file_handle = FileOpen(file_name, FILE_READ|FILE_CSV,",");


datetime PreviousBar;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
     
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
int start()
  {
//---
   if((NewBar()))   
        {
    
      if(file_handle != INVALID_HANDLE)
     {
     
      
      ArrayResize(data_double_datetime, data_size);
      ArrayResize(data_double_average,data_size);
      
      }
    
   
    for(i = 0; i< 8760; i++)
            {
            data_double_datetime[i]= FileReadString(file_handle);
            data_double_average[i]= (double)FileReadNumber(file_handle);
            if(data_double_datetime[i]== TimeToStr(TimeCurrent())){
            break;
                        
            Print(data_double_datetime[i]==TimeToStr ( TimeCurrent ()));
            Max_Average = data_double_average[i];
            }
             
          
            return(0);
      
      
      FileClose(file_handle);
      }
      
      
      
      
      }return(0);
  }


//+------------------------------------------------------------------+
//|       one bar on trade                                           |
//+------------------------------------------------------------------+

bool NewBar()
{
if(PreviousBar<Time[0])
{
PreviousBar=Time[0];
return(true);
}
return(false);
}


Files:
max.zip 15 kb
To add comments, please log in or register