Announcement

Collapse
No announcement yet.

Arrghh. File reading

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Hi,

    I had posted a question elsewhere about showing weekly data in an efs posted on a daily chart, so i guess your response answers that question (no).
    It depends on how you want the weekly data represented. For example, if you are trying to overlay a weekly OHLC onto a daily chart (or something similar), this is possible. How do you want to diplay your weekly data on the daily chart?

    But this gets to the format issue.These files will likely come with the data separared by commas with the date either at the end or beginning of the line.
    The good new is that it really isn't hard to parse CSV files. The bad news is all the matching you will have to do to verify date and time. Not that its hard, but it is a fair amount of really boring coding.

    I agree, a method for loading outside data into eSignal sould be great. It has been requested before, but I have never seen any replies to the request. Given that most other high-end charting packages support this, it does stand out as one of the great unimplemented features in eSignal.
    Garth

    Comment


    • #17
      Code is:

      <code>

      function preMain() {
      setPriceStudy(true);
      //setComputeOnClose(true);
      setStudyTitle("test");
      debugClear();
      }

      function main() {
      var indcurr = getCurrentBarIndex();
      if (indcurr < 0) {
      return;
      }

      if (getBarState() != BARSTATE_NEWBAR) return;

      debugPrintln("bar= "+indcurr)

      var f = new File("Formulas/testRead.txt");
      f.open("rt");

      debugPrintln("Exists: " + f.exists());
      debugPrintln("Is File Open: " + f.isOpen());
      debugPrintln("Is EOF: " + f.eof());
      debugPrintln("Length: " + f.getLength());
      debugPrintln("Position: " + f.getPosition());

      var line;
      while(!f.eof()) {
      debugPrintln("before read");
      line = f.readln();
      debugPrintln("Line: [" + line + "]");
      }
      f.close();
      debugPrintln("after");

      return;
      }
      </code>

      The result I get:
      debugPrintln("Exists: " + f.exists()); TRUE
      debugPrintln("Is File Open: " + f.isOpen()); FALSE
      debugPrintln("Is EOF: " + f.eof()); TRUE
      debugPrintln("Length: " + f.getLength()); -1
      debugPrintln("Position: " + f.getPosition()); -1

      Note that f.eof()=true so the loop to do f.readln() never gets executed.
      It doesn't seem to matter if the file was created with notepad or a file written from EFS.

      Comment


      • #18
        Code for file reading

        Here's my code for file reading, hope this helps:

        function getNumberFromTextFile()
        {
        var line;
        var f = new File("In.txt");
        f.open("rt");
        if(f.isOpen()) {
        line = f.readln();
        vMyNumber = new Number(line);
        f.close();
        }
        }


        vMyNumber is a global variable.

        All of my text files are fixed format, and I know how many lines are in each. So I never have to use the eof() stuff.

        Good luck,
        Katrina.
        Last edited by katnap; 04-13-2003, 10:05 PM.

        Comment


        • #19
          Doesn't work for me.
          Perhaps, it really is the problem with 7.2 build 544 ?!!

          Comment


          • #20
            Possible Solution

            Phil,

            If there is nothing in the file, then f.eof will equal TRUE.

            If there is nothing in the file, then there is nothing to read from the file. Thus, you loop is never activated.

            Are you trying to READ from the file or WRITE to the file??

            Brad
            Brad Matheny
            eSignal Solution Provider since 2000

            Comment


            • #21
              I am trying to read. I can successfully write to a file.
              The file contains 3 lines. I tried with a file created with notepad and a file created from efs.

              Comment


              • #22
                Re: Reply to post 'Arrghh. File reading'

                going to try it with the Beta.

                the bigger issue of course is parsing and file format issues. so easy
                to do this in Metastock, i'd hate to have to maintain two sets of data
                and apps to do this. and writing the efs is so much easier than doing
                it in MS.

                i've posted a bunch of rants/requests elsewhere since there is lots of
                valuable data (new highs/lows, specialist short ratio, COT data) that
                eSig can't reasonably supply that can be had elsewhere. that won't do
                us much good if there is no common way to read them in.

                sounds like it would be an excellent thing to have done as an
                extension, library or separate app, something that could parse and
                read in from MS or ASCII files out there already.


                On Saturday, April 12, 2003, at 08:48 PM,
                <[email protected]> wrote:

                > Hello deepfoo_1,
                >
                > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                >

                Comment


                • #23
                  Make sure the file you want to read is in the eSignal\FormulaOutput directory and when you create your file object, do it like this:

                  var f = new File(myfile.txt); //don't include the path

                  As long as myfile.txt exists in eSignal\FormulaOutput, you should be good to go.

                  fan27

                  Comment

                  Working...
                  X