Best Place for reading .CSV file, just Once

 

Hi all

I have implemented reading .CSV file code in OnInit() function ....every thing is OK ...BUT every time that i chang chart's TimeFrame , the OnInit() runs again ...!!!!

How can i Read my .CSV file just Once ??? is it possible at all ?

Thanks in advanced.

Kind Regards.

 
string  GV_name = "Read_csv"; //Global Variable Name
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   //--- 
   if (GlobalVariableGet(GV_name) <= 0.0)
   {
      //Read csv file here
      GlobalVariableSet(GV_name, 1.0);
   }
   //---
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   GlobalVariableSet(GV_name, -1.0);
}
//+------------------------------------------------------------------+
 
Naguisa Unada:

Thank you for your help...BUT new problem occured !!!

I read CSV and save its data in a two dimensional  dynamic string array......every time OnInit runs (or time frame changed) , this array get cleared  and filled by random data .....is it possible to save two dimensional string array in global variables too?

Thanks.

 

You want to read and write CSV files only once when you start your program, don't you?

Then there should be no problem with the program I showed you.