Announcement

Collapse
No announcement yet.

Better time template control?

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

  • Better time template control?

    If I have a sub-minute interval advanced chart, e.g. 1s chart, is there any way to limit the loading of historical ticks to a reasonable number?

    What I have to do as a workaround is to require more than 1 tick in an interval before I allow my formulas to compute in streaming mode. This ensures that the formula is working in streaming mode, rather than while it is loading, since you never load anything but the end-of-bar tick.

    Is there something I can do in a time template, with a 1s chart, to specify "last 100 bars", for example, or somehow limit the time interval prior to the current time, over which loading occurs?

    I've already tried it, and can't see anyway to limit the number of historical ticks loaded.

    TIA for any solutions or workarounds.

  • #2
    Tick timestamps?

    OK, maybe I can look at the raw time for the end of bar tick as it is loading, and calculate when it's close enough to the current time, so I can avoid doing any calculation until it comes within my desired historical timeframe? That should be possible, right?

    What if I use getValueAbsolute("rawtime") ? No, that doesn't give me a historical tick's timestamp I can work with...

    Is there a way for me to get the timestamp of historical ticks as they come in ??

    Comment


    • #3
      getValue with rawtime may do the trick

      OK, got that one wrong... Here's a possible workaround I can use:

      If I use getValue("rawtime"), then I do get a value which I may be able to relate to the current time, and manually discard data older than my desired timewindow during loading...

      All I have to do is to know the rawtime for NOW, and I will be able to discard data I don't want. I can probably enter that manually, if necessary so the loading formula has access to it, which could be done in various ways...

      It would be so much better if time templates could do something for me in limiting data loaded.

      Thanks!

      Comment


      • #4
        How to discard old historical data

        This snippet when placed at the top of main will not compute until 1 hour's data prior to the last available bar. This works for me...


        if (!enabled) {
        var a=getValueAbsolute("rawtime"); // last available bar
        var r=getValue("rawtime");
        if ( (r-a) > -3600 ) enabled=true; // 60 minutes
        }
        if (!enabled) return; // do not compute

        Comment


        • #5
          bfry,

          Try this, it works well for me
          PHP Code:
          var nIndex getCurrentBarIndex();
          if (
          nIndex < -50){return;} // minimizes load time 
          All historical bars will have getCurrentBarIndex() less than zero. If you load 15000 historical bars, the very first getCurrentBarIndex(); will be -15,000, the next -14,999, until you finally reach zero. In my example, I used -50 to load the last 50 historical bars, but you could just as easily use -200 to load the last 200 historical bars.
          Last edited by Guest; 01-10-2004, 12:01 PM.

          Comment


          • #6
            Thanks! Yet another way to do it !!
            This is really a serious problem for computationally intensive EFS routines and, in my case, I do a lot of intrabar analysis, tick by tick, which requires even more control over loading, even though only end-bar data is delivered during loading...

            Comment


            • #7
              You are welcome. I use this in a number of my sub minute charts and during initial load or subsequent re-load it is a lifesaver!

              Comment


              • #8
                bfry,

                One more thing, depending on the type of advanced chart you have, the data can come in segmented, and each time a segment of data comes in the efs's are re-loaded.

                I see this behaviour mostly in Renko charts. As a result, some of my efs's reload 3 or 4 times. I have not observed my Candle charts behave in this manner. To minimize the impact of this repetitive loading, I have another conditional in some of my efs's...
                PHP Code:

                var displayedBars 100;
                var 
                barsLoaded getNumBars();
                var 
                nIndex getCurrentBarIndex();
                if (
                nIndex < -(displayedBars 50) || barsLoaded < (displayedBars 50)){return;} // minimizes load time 
                Maybe this can be of some help.


                Regards,

                Comment


                • #9
                  Thanks a million -- this coding approach really is a life saver for computationally intensive EFS's. It's easy to blame eSignal for slow loading when it's merely calling your heavy duty EFS a bit too many times !

                  Comment


                  • #10
                    I am a trader, not a programmer, but I am learning quite a bit here and there from others on this forum.

                    Below is something I have found useful to limit load/reload times during developement.

                    I always seem to do better with KISS methods, so I like these.



                    function main() {

                    // For zero historical data on load/reload use this____
                    if (getCurrentBarIndex() != 0) return;

                    // For limited Historical data use this ____ . Change the number 10 to change the number of historical bars
                    // to be processed ____ . 10 will return 20 - 30 bars, depending upon CPU speed and # of processes running.
                    if (getValue("rawtime") < getValue("rawtime") - 10) return;

                    // Use this to see the effects upon load times in the formula output window.
                    debugPrintln(getCurrentBarIndex() + " " + getHour() + ":" + getMinute() + " - History load test. ");

                    return;
                    }

                    Perhaps this will be useful to others as well.

                    Comment

                    Working...
                    X