This code finally came together, but I need help for one last part

 

Hey guys, this is my first post and just wanted to say thanks real quick to everyone here who has contributed. This site is a goldmine as long as you're willing to take the time, be patient, and use the search function.

So anyway, after a long struggle but eventual success, I created a script. The idea is to simply plot some horizontal lines on the screen at a few price points...of course the coding gets a bit ridiculous for something that seems so simple :P The idea is to actually have a .txt file with the levels in it. The end goal would be to host that file online somewhere and have it update in that one location, so that whoever is using this script will automatically have the levels updated if they're updated in the file online.

Honestly, I have just about EVERYTHING set up the way I want it and it's running very smooth. I even got through the workaround to point to files that aren't in the experts/files or experts/include folders using the import Kernel32.dll and its associated commands. I simply use that to essentially copy the text file from the anywhere directory and paste it into the experts/files folder for further, easier use. My very last struggle is how I will be able to have it point to a file that's hosted online (or what could be done to accomplish the same end goal). So far I can only make this work with a local file (though that file can be anywhere in the computer).

Any and all help is GREATLY GREATLY GREATLY appreciated! I highlighted the main portion that I'm concerned about in black

//+------------------------------------------------------------------+
//|                                                    IFR_Lines.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

// constants for function _lopen
#define OF_READ               0
#define OF_WRITE              1
#define OF_READWRITE          2
#define OF_SHARE_COMPAT       3
#define OF_SHARE_DENY_NONE    4
#define OF_SHARE_DENY_READ    5
#define OF_SHARE_DENY_WRITE   6
#define OF_SHARE_EXCLUSIVE    7
 
 
#import "kernel32.dll"
   int _lopen  (string path, int of);
   int _lcreat (string path, int attrib);
   int _llseek (int handle, int offset, int origin);
   int _lread  (int handle, string buffer, int bytes);
   int _lwrite (int handle, string buffer, int bytes);
   int _lclose (int handle);
#import

//Following function to read file
string ReadFile (string path) 
  {
    int handle=_lopen (path,OF_READ);           
    if(handle<0) 
      {
        Print("Error opening file ",path); 
        return ("");
      }
    int result=_llseek (handle,0,0);      
    if(result<0) 
      {
        Print("Error placing the pointer" ); 
        return ("");
      }
    string buffer="";
    string char1="x";
    int count=0;
    result=_lread (handle,char1,1);
    while(result>0) 
      {
        buffer=buffer+char1;
        char1="x";
        count++;
        result=_lread (handle,char1,1);
     }
    result=_lclose (handle);              
    if(result<0)  
      Print("Error closing file ",path);
    return (buffer);
  }
//Following is the function to write file after reading it//
void WriteFile (string path, string buffer)
{
int count=StringLen (buffer);
int result;
int handle=_lopen (path,OF_WRITE);
if (handle<0)
{
handle=_lcreat (path,0);
if(handle<0)
{
Print ("File creation error ",path);
return;
}
result=_lclose (handle);
}
handle=_lopen (path,OF_WRITE);
if(handle<0)
{
Print ("Error opening file",path);
return;
}
result=_llseek (handle,0,0);
if(result<0)
{
Print ("Error setting pointer");
return;
}
result=_lwrite (handle,buffer,count);
if (result<0)
Print ("Error writing file ",path," ",count, " byte");
result=_lclose (handle); 
if (result<0)
Print ("Error closing file ",path);
}

//#property show_inputs

 color      LineColor,Line1color,Line2color,Line3color,Line4color,Line5color,Line6color;
 int        LineWidth,Line1width,Line2width,Line3width,Line4width,Line5width,Line6width;
 int        LineStyle;
 int        i,j,handle,index;
 double     Line1Position,Line2Position,Line3Position,Line4Position,Line5Position,Line6Position;
 string   objname;




//+------------------------------------------------------------------+
int init()  {
//+------------------------------------------------------------------+
  i = 0;
  return(0);
}

//+------------------------------------------------------------------+
/*int deinit()  {
//+------------------------------------------------------------------+
  ObjectDelete("horiz line-1");
  ObjectDelete("horiz line-2");
  ObjectDelete("horiz line-3");
  ObjectDelete("horiz line-4");
  ObjectDelete("horiz line-5");
  ObjectDelete("horiz line-6");
  return(0);
}
*/
//+------------------------------------------------------------------+
int start()
//+------------------------------------------------------------------+
 {
     while (true)
       { 
                           //this address below I would REALLY like to be able 
                           //to point to an online file instead of just a local one,
                           //but is that even possible? Simply entering the http link
                           //file didn't work :(
                           
string buffer=ReadFile ("C:\\Users\User\Documents\Text.txt");
int count=StringLen (buffer);
Print ("Read byte:",count);
WriteFile ("C:\Users\User\Documents\Market Dealings\New folder\experts\files\USDJPYStopLevels.txt",buffer);
                   //I know the directory is weird, but that's my MT4 client folder

 int i,handle,index;
 LineWidth = 2;
 LineStyle = 0;
 LineColor = Magenta;
 

 string val[12];
 handle=FileOpen("USDJPYStopLevels.txt",FILE_READ);
 //Print(handle); 
 //Print("try to open file");
 if(handle==-1)return(0);// if not exist
 //Print("it exists");
 if(FileSize(handle)==0){FileClose(handle); return(0); } //if empty
 for(i=0;i<12;i++)
  //for(j=0;j<1;j++)
   {
    //val[i]StrToInteger(FileReadString(handle));//read one variable
  val[i]=FileReadString(handle);
   
  //Print(FileReadString(handle));//read one variable   
    //Print("Val",i, " - ",val[i]);//You can print it to be sure
   } 
 FileClose(handle); //close file

//Line1 
 Line1Position      = StrToDouble(val [0]);
//Line1 Width (based on the qualifying word)
Line1width = 2;
     index =StringFind(val[1],"Small",0);
      if (index !=-1) {
       Line1width = 1;
       }
     index =StringFind(val[1],"Large",0);
     if (index !=-1) {
     Line1width = 4;
       }
     index =StringFind(val[1],"Massive",0);
     if (index !=-1) {
     Line1width = 5;
       }
   
//Line1 Create
      if (Line1Position >= 0)  {
        objname = "horiz line-1";
        ObjectDelete(objname);
        ObjectCreate(objname,OBJ_HLINE,0,0,Line1Position);
        ObjectSet(objname,OBJPROP_COLOR,LineColor);
        ObjectSet(objname,OBJPROP_WIDTH,Line1width);
        ObjectSet(objname,OBJPROP_STYLE,LineStyle);
       }


//Line2 
 Line2Position      = StrToDouble(val [2]);
 //Line2 Width (based on the qualifying word)
 Line2width = 2;
     index =StringFind(val[3],"Small",0);
      if (index !=-1) {
       Line2width = 1;
       }
     index =StringFind(val[3],"Large",0);
     if (index !=-1) {
     Line2width = 4;
       }
     index =StringFind(val[3],"Massive",0);
     if (index !=-1) {
     Line2width = 5;
       }
     //Line2 Create
      if (Line2Position >= 0)  {
        objname = "horiz line-2";
        ObjectDelete(objname);
        ObjectCreate(objname,OBJ_HLINE,0,0,Line2Position);
        ObjectSet(objname,OBJPROP_COLOR,LineColor);
        ObjectSet(objname,OBJPROP_WIDTH,Line2width);
        ObjectSet(objname,OBJPROP_STYLE,LineStyle);
          }  
//Line3 
 Line3Position      = StrToDouble(val [4]);
//Line3 Width (based on the qualifying word)
Line3width = 2;
     index =StringFind(val[5],"Small",0);
      if (index !=-1) {
       Line3width = 1;
       }
     index =StringFind(val[5],"Large",0);
     if (index !=-1) {
     Line3width = 4;
       }
     index =StringFind(val[5],"Massive",0);
     if (index !=-1) {
     Line3width = 5;
       }
     //Line3 Create
      if (Line3Position >= 0)  {
        objname = "horiz line-3";
        ObjectDelete(objname);
        ObjectCreate(objname,OBJ_HLINE,0,0,Line3Position);
        ObjectSet(objname,OBJPROP_COLOR,LineColor);
        ObjectSet(objname,OBJPROP_WIDTH,Line3width);
        ObjectSet(objname,OBJPROP_STYLE,LineStyle);
        } 
 //Line4 
 Line4Position      = StrToDouble(val [6]);
//Line4 Width (based on the qualifying word)
Line4width = 2;
     index =StringFind(val[7],"Small",0);
      if (index !=-1) {
       Line4width = 1;
       }
     index =StringFind(val[7],"Large",0);
     if (index !=-1) {
     Line4width = 4;
       }
     index =StringFind(val[7],"Massive",0);
     if (index !=-1) {
     Line4width = 5;
       }
     //Line4 Create
      if (Line4Position >= 0)  {
        objname = "horiz line-4";
        ObjectDelete(objname);
        ObjectCreate(objname,OBJ_HLINE,0,0,Line4Position);
        ObjectSet(objname,OBJPROP_COLOR,LineColor);
        ObjectSet(objname,OBJPROP_WIDTH,Line4width);
        ObjectSet(objname,OBJPROP_STYLE,LineStyle);
        }
//Line5 
 Line5Position      = StrToDouble(val [8]);
//Line5 Width (based on the qualifying word)
Line5width = 2;
     index =StringFind(val[9],"Small",0);
      if (index !=-1) {
       Line5width = 1;
       }
     index =StringFind(val[9],"Large",0);
     if (index !=-1) {
     Line5width = 4;
       }
     index =StringFind(val[9],"Massive",0);
     if (index !=-1) {
     Line5width = 5;
       }
     //Line5 Create
      if (Line5Position >= 0)  {
        objname = "horiz line-5";
        ObjectDelete(objname);
        ObjectCreate(objname,OBJ_HLINE,0,0,Line5Position);
        ObjectSet(objname,OBJPROP_COLOR,LineColor);
        ObjectSet(objname,OBJPROP_WIDTH,Line5width);
        ObjectSet(objname,OBJPROP_STYLE,LineStyle);
        } 
 //Line6 
 Line6Position      = StrToDouble(val [10]);
 //Line6 Width (based on the qualifying word)
Line6width = 2;
     index =StringFind(val[11],"Small",0);
      if (index !=-1) {
       Line6width = 1;
       }
     index =StringFind(val[11],"Large",0);
     if (index !=-1) {
     Line6width = 4;
       }
     index =StringFind(val[11],"Massive",0);
     if (index !=-1) {
     Line6width = 5;
       }

 //Line6 Create
      if (Line6Position >= 0)  {
        objname = "horiz line-6";
        ObjectDelete(objname);
        ObjectCreate(objname,OBJ_HLINE,0,0,Line6Position);
        ObjectSet(objname,OBJPROP_COLOR,LineColor);
        ObjectSet(objname,OBJPROP_WIDTH,Line6width);
        ObjectSet(objname,OBJPROP_STYLE,LineStyle);
        }
  Sleep(2000);
  }
  return(0);
  
} 

Okay, and here's the .txt file for reference so you know what I'm trying to pull out of it to create those lines:

104.00
Large Stops
100.00
Large Stops
99.20
Small Stops
96.80
Stops
95.50
Large Stops
93.50
Large Stops
 

Catabolist:

. . . My very last struggle is how I will be able to have it point to a file that's hosted online (or what could be done to accomplish the same end goal). So far I can only make this work with a local file (though that file can be anywhere in the computer).

Any and all help is GREATLY GREATLY GREATLY appreciated! I highlighted the main portion that I'm concerned about in black

You might consider using the functions from Windows' WinINet.dll. See Microsoft's documentation for WinINet.dll on MSDN. It appears others on this forum have used it, so you should do a search for wininet.dll.

 
Okay, looking into this now. Thanks for the heads-up! I'm still a shameful noob at this, so just to clarify: will I be using a HTTP GET to retrieve the file via URL?
 
Just looked into some of the other options - looks like InternetReadFile is spot on for what I need. Now to figure out how the hell to implement it...haha
 
Catabolist:
Just looked into some of the other options - looks like InternetReadFile is spot on for what I need. Now to figure out how the hell to implement it...haha

here is an example.
Files:
grabweb.mq4  3 kb
 
another one attached.
Reason: