import from excel to indicator to draw a OBJ_HLINE

To add comments, please log in or register
abd-
32
abd-  

was looking for a code that allow me to import data from an excel (CSV) file to mt4 platform  ..

.and use this data( it's a price data)  to Draw a horizontal line ..i found one article here that talk about the same idea

https://www.mql5.com/en/forum/6816

and the code is attached from the original article

but the code in the article is used only to disply the integer on the screen ...

how to use the integer in the CSV file to draw  OBJ_HLINE?

any help is appreciated 

//+------------------------------------------------------------------+
//|                                                   csvdisplay.mq5 |
//|                                                           meisme |
//+------------------------------------------------------------------+
#property copyright "meisme"
#property version   "1.00"

class CCsvDisplay {
   public:
   //Constructor, pass the filename here
   CCsvDisplay(string strFilename) {
      m_strFilename = strFilename;
   }
   ~CCsvDisplay(){/*Destructor*/};
   //Read the csv file
   void ReadDisplayFile() {
      if (FileIsExist(m_strFilename) == true) {
         int iFile = FileOpen(m_strFilename, FILE_TXT | FILE_READ | FILE_SHARE_READ | FILE_ANSI);
         //Is file open succeed?
         if (iFile != -1) {
         //Succeed
            Print("Open file ", m_strFilename);
            string strFormatDisplayString;
            //Parse and display file content until file reach the end
            while (FileIsEnding(iFile) == false) {
               //Read file line per line
               string strContentLine = FileReadString(iFile);
               string strParsedColumn[];
               //Parse string column by column (based on separator)
               int iContentCount = StringSplit(strContentLine, StringGetCharacter(",",0), strParsedColumn);
               if (iContentCount > 0) {
                  for (int i = 0; i < iContentCount; i++) {
                     strFormatDisplayString += strParsedColumn[i];
                     if (i != (iContentCount - 1)) strFormatDisplayString += " -> ";
                  }
                  //Add return and new line for display
                  strFormatDisplayString += "\n";
               }
            } 
            //Close file after read
            FileClose(iFile);
            //Plot string as comment on chart
            Comment(strFormatDisplayString);
         }
         else {
         //Failed
            Comment("Cannot open ", m_strFilename, " !");
         }
      }
      else {
      //File doesn't exist?
         Comment("File ", m_strFilename, " doesn't exist!");
      }
   }
   
   private:
      string m_strFilename;
};

//============

CCsvDisplay *m_pcCsvDisp;
int OnInit()
  {
   m_pcCsvDisp = new CCsvDisplay("myFile.csv");
   m_pcCsvDisp.ReadDisplayFile();
   
   Print("Load Csv display");
   return(0);
  }
  
  void OnDeinit(const int r)
  {
   if (m_pcCsvDisp != NULL) delete m_pcCsvDisp;
  }
Help needed , how to import a cvs file data as an indicator
Help needed , how to import a cvs file data as an indicator
  • 2012.05.31
  • www.mql5.com
Hi, I got a csv file with a list of data: Datetime, and values...
abd-
32
abd-  

if we use this code to draw HLINE what else we need?

any suggestion? 

         ObjectDelete("VERTECALLINE");
      ObjectCreate( "VERTECALLINE","VERTECALLINE", OBJ_HLINE,0,D'2018.06.29 20:00',----);
       ObjectSet( "VERTECALLINE", OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet( "VERTECALLINE", OBJPROP_COLOR, Red);
       ObjectSet("VERTECALLINE", OBJPROP_BACK, false); 
        ObjectSet("VERTECALLINE", OBJPROP_WIDTH,1);
                  }
abd-
32
abd-  

which type of code that we can use to import integer or number from excel sheet to an indicator to use it in MT4?

any help?

whroeder1
17945
whroeder1  
Save the file as a CSV. Read the CSV file. Perhaps you should read the manual.
abd-
32
abd-  
whroeder1:
Save the file as a CSV. Read the CSV file. Perhaps you should read the manual.

thanks for your comment whroeder1

sorry but am not a programmer..am learning some codes..

you mean by READ CSV ..like this?

int iFile = FileOpen(m_strFilename, FILE_CSV | FILE_READ | FILE_SHARE_READ | FILE_ANSI);
         

we have here a  FILE_READ

this thing is in the first code of the script

i want now the opposit thing ...to read from the excel file and use it in my code as integer ....that i can use in my coding ....

for making HLINE and TREND ...and like this ...

what the name of this function?

To add comments, please log in or register