Announcement

Collapse
No announcement yet.

Loading data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading data

    Hi

    I tried the following:

    Advanced Chart ( ES H4, 60) Time-Template is set like follows:
    # days = 0 dynamic mode
    automatic start/end times

    then in the efs I try to load 1 min data into an array like this:

    var aHighs = new Array();
    var aTimes = new Array();
    var x = 2000;
    aHighs = getValue("High", 0, x*-1, "ES H4,1" );
    aTimes = getValue("Time", 0, x*-1, "ES H4,1" );

    This works fine, but somewhere over 2000 bars it does not work anymore.

    How can a force eSignal to load more bars?

    Traveller

  • #2
    Traveller
    Try setting the #Days to a fixed value rather than using 0 (ie Dynamic) if the efs is returning less data than what is on the price chart.
    Having said that isn't 2000 the lookback you have for the array?
    Alex

    Comment


    • #3
      Loading data

      Alex

      If I set day #Days to a fixed value I'm not able to scroll back in my charts.
      getOldestBarIndex() returns a value around -1090.
      x=2044 works. x=2045 not.

      There should be a way to load more data into arrays.

      Traveller

      Comment


      • #4
        Loading data

        Alex

        If I set #Days to 25, getOldestBarIndex() returns -161 and I get about 9000 1-min-bar data.

        Looks strange to me.

        Traveller

        Comment


        • #5
          The problem is that you are loading a new data stream when you specify a new symbol,interval in your getValue calls:

          aHighs = getValue("High", 0, x*-1, "ES H4,1" );

          So the 1 minute data stream will be different from the 60 minute data stream on the chart.


          161 60 minute bars is about right for 25 days
          9660 would be about the correct amount for 1 minute bars

          The above assumes you are using regular trading hours.

          remember that when using H4 that you are not using continuous contracts, so there will be a point of no data. Try ES #F if you want to go past contract start...that would be the continuous contract.

          Garth
          Garth

          Comment


          • #6
            Loading data

            Ok. There is another problem. I find no way to test how many bars are available. The following does not work, if x> 2044.

            aHighs = getValue("High", 0, x*-1, "ES H4,1" );
            if( ! isNaN(aHighs[x-1])){
            debugPrintln("OK, loaded: " + x);
            } else{
            debugPrintln("not loaded");
            return null;
            }

            If the requested amount of bars is not available, the script seems to break. The if statement will never execute.

            Any idea?

            Traveller

            Comment


            • #7
              Hi,

              Yep I think I do. If you request more than is available you will only get a null return...not an array. So you will get an error when running this because you are accessing a non-array as if it is an array for that case.

              Just checking for a null return should work.

              Garth
              Garth

              Comment


              • #8
                Traveller:

                You can use getNumBars() to tell you how many bars are loaded in the chart.

                n = getNumBars();

                Chris

                Comment


                • #9
                  Chris,

                  I don't think getNumBars() allows you to specify an alternate symbol,interval. This is the problem at hand - he is grabbing 1 minute data off a 60 minute chart.

                  If I'm wrong about getNumBar(), let me know.

                  Garth
                  Garth

                  Comment


                  • #10
                    Loading data

                    No line in the script after trying to load to much bars will be executed.
                    I wrote this on the next line and it is not executed:

                    debugPrintln("This is one line after loading highs");

                    The script seems to break.

                    If I use x= getNumBars(); I get 165 for 25-Days and 320 for Dynamic mode. So, actually there are more bars in dynamic mode, but I'm only able to load 2044 1-min. bars instead of about 9000 bars in the 25-Days mode.

                    Traveller

                    Comment


                    • #11
                      Hi,

                      I'm not clear which "next line" you mean.

                      If you do:

                      var x = 2040;
                      var aHighs = getValue("High", 0, x*-1, "ES H4,1" ); // Note you don't have to declare aHighs as an array prior to this.

                      debugPrintln("This is one line after loading highs");

                      This should print without a problem. At least I haev never run into an issue yet when doing something similar.

                      usually my code would look like:

                      var x = 2040;
                      var aHighs = getValue("High", 0, x*-1, "ES H4,1" ); // Note you don't have to declare aHighs as an array prior to this.

                      if (aHighs == null)
                      return;

                      and this works.

                      Garth
                      Garth

                      Comment


                      • #12
                        Loading data

                        Garth

                        I'm very sorry, but it does not work. I restarted my computer to make shure everything ist fine. Then I used this code:

                        var aHighs ;
                        var x = 2225; // more than 2044 on dynamic mode will crash script

                        aHighs = getValue("High", 0, x*-1, "ES H4,1" );
                        debugPrintln("This is one line after loading highs");

                        if( aHighs==null){
                        debugPrintln("not loaded");

                        } else{
                        debugPrintln("OK, loaded: " + x);

                        }

                        Nothing after getValue... is executed. If I comment out aHighs=... then I get the debugPrint messages.

                        Any idea?

                        Traveller

                        Comment


                        • #13
                          Loading data

                          Garth

                          I made this workaround:

                          Global vars:

                          var ArrayLoaded= false;
                          var BarsInitial= 2500;
                          var BarsTried = 0;
                          var BarsReduction = 100;

                          Function main()

                          var aHighs ;
                          var x = 0 ;

                          if(ArrayLoaded==false){
                          if(BarsTried==0){
                          BarsTried=BarsInitial;
                          } else{
                          BarsTried=BarsTried-BarsReduction;
                          }
                          }

                          x=BarsTried;
                          if(ArrayLoaded==false){
                          aHighs = getValue("High", 0, x*-1, "ES H4,1" );
                          debugPrintln("This is one line after loading highs");
                          ArrayLoaded=true;
                          if( aHighs==null){
                          debugPrintln("not loaded");
                          } else{
                          debugPrintln("OK, loaded: " + x);
                          }
                          }



                          This will work and load 2100 bars.
                          There is only one question: Will eSignal get unstable, because code is aborted if trying to load too much bars?

                          Traveller

                          Comment


                          • #14
                            Hi,

                            I wish I could explain that. I just ran it on mine and it also didn't work. Then I ran some other code of mine that did something very similar and it worked.

                            I'll have to play with this longer to see if I can figure out what is up.

                            G
                            Garth

                            Comment


                            • #15
                              OK. Thank you Garth.

                              Traveller

                              Comment

                              Working...
                              X