Announcement

Collapse
No announcement yet.

Can you get TIME from TOS?

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

  • Can you get TIME from TOS?

    I've spent about 3 hours trying to figure out how to get the current time thats displayed in the TOS window. Its currently showing trades firing off at 23:10, 23:11 etc.. My chart says 16:00 becasue I have it set to a 9-1600 Time frame. I can not change this time template but need to get the current tick time that the TOS is showing (23:10). Every thing I've tried just returns the bar's time which is 16:00. How can I get the time value from the TOS data. Thanks!

    Geoff

  • #2
    Hello Geoff,

    You're most likely using the hour(), minute() and second() functions. Correct? These functions refer to the time stamp (or start time) of the bar relative to the time frame in which they are executing. If you want to get the time stamp of each trade as it occurs in the time and sales window, try specifying the interval of "1T" with those functions.

    PHP Code:
    function main() {
        if (
    getCurrentBarIndex() < 0) return;

        var 
    vHr hour(0inv("1T"));
        if (
    vHr 10vHr "0" vHr;
        var 
    vMin minute(0inv("1T"));
        if (
    vMin 10vMin "0" vMin;
        var 
    vSec second(0inv("1T"));
        if (
    vSec 10vSec "0" vSec;
        
        var 
    Time vHr ":" vMin ":" vSec;
        
    debugPrintln(Time);

        return;

    You could also use the JavaScript Date Object to build the time stamp based on your local PC clock.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      yippie!

      Oh good gracious! Thats what im talking about!! Your a useful guy to have around these parts. Believe it or not I did spend about an hour trying to figure it out before posting. What other magical intervals are there. One quick issue.. Take a look at the screen cap. The TOS seems to be a few ticks ahead of the timer. See the multiple prints of minute 16 and the formula output still says 15. The code is just the code you posted and a debugprint ln used in main(). Its good enough! Just wondering if there is something I can do to get it to sync perfectly. Im using $PLAYBACK right now so that could be the reason its not totally in sync.

      Comment


      • #4
        Hello Geoff,

        There isn't anything we can do via EFS to sync up to a time and sales window while using $PLAYBACK. I don't believe it was intended to be used this way. Please feel free to submit a suggestion to development IDEAS to add this functionality if it is important to you. The code solution I gave you will only be synchronized in real time.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          No its not too important, was just curious.

          Argh. Soon as I tunred computeOnClose back on it stopped working. Basically the study doesn't even run except once per bar in each time fame with this flag on? I need it on to compute values but at the same time I'd still like to get the latest time of the tick data streaming in. Hmmmm..

          Comment


          • #6
            Hello Geoff,

            Originally posted by glay
            No its not too important, was just curious.

            Argh. Soon as I tunred computeOnClose back on it stopped working. Basically the study doesn't even run except once per bar in each time fame with this flag on?
            That is the purpose of setComputeOnClose(). It forces the formula to only execute once per bar when each bar closes.


            I need it on to compute values but at the same time I'd still like to get the latest time of the tick data streaming in. Hmmmm..
            To have it both ways, what you do is look for BARSTATE_NEWBAR with getBarState(). This occurs on the first trade of each new bar. That is the same instance in which EFS knows that the prior bar just closed. Any calculation that you want to perform once per bar needs to be inside a newbar condition. The calculation then needs to reference the data on bar -1 rather than 0.

            This way the formula will continue to execute with each trade so any logic that needs to process on each trade can continue to do so.
            Jason K.
            Project Manager
            eSignal - an Interactive Data company

            EFS KnowledgeBase
            JavaScript for EFS Video Series
            EFS Beginner Tutorial Series
            EFS Glossary
            Custom EFS Development Policy

            New User Orientation

            Comment


            • #7
              Ahh didn't think about doing it that way. That way I could calculate my formulas on bar closes but yet still have tick data for time calculations and other sensitive objects... wonderful.. thx

              Comment


              • #8
                You're most welcome.
                Jason K.
                Project Manager
                eSignal - an Interactive Data company

                EFS KnowledgeBase
                JavaScript for EFS Video Series
                EFS Beginner Tutorial Series
                EFS Glossary
                Custom EFS Development Policy

                New User Orientation

                Comment

                Working...
                X