using FileOpen, FileClose and FileReadNumber with indicators

 

I'm trying to create an indicator that will plot a line against my chart based on the close price + a variable "Weight1". The variable "Weight1" is calculated from another application and the value is placed in a text file. I would like my indicator to read the value in the text file and add it to the close price..


Here is the script I use to read the text file

void Read()
  {
  int Fhandle;
  double Adjustment;
   
        Fhandle = FileOpen(InputFilename,FILE_CSV|FILE_READ,',');
        if(Fhandle > 0)
        {
              Weight1 = FileReadNumber(Fhandle);
                        
                        
                FileClose(Fhandle);
        } //end if(FileHandle > 0)
}

If this won't work as an indicator, can someone please suggest a way I can input the "Weight1" variable it into the indicator without assigning it manually?


Thanks in advance!

 
Put this script into your indicator and assign the variable Weight1 to the one in your indicator? Script looks good, just put the File close outside the if (fhandle...)
 

Thanks for your help, I really appreciate it. I just realized that the problem was I assigned the "InputFileName" external var with the entire path of the file.. =)



Reason: