Announcement

Collapse
No announcement yet.

getValue("raw time")

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

  • getValue("raw time")

    hi Jason.

    I have an efs that looks like the following...

    var cRT=0;
    preMain() {

    ...
    }

    main() {
    var toUpdate=0;
    if (cRT==0) {cRT=getValue("raw time"); toUpdate=1;}
    else if ((cRT+30)>=getValue("raw time"); toUpdate=0;}
    else if ((cRT+30)<getValue("raw time");cRT==getValue("raw time"); toUpdate=1;}
    debugPrintln(cRT);
    if (toUpdate==1) {
    ...
    }

    }


    the problem is cRT never gets changed since the first iteration through main ().... and I tried to use date.getSeconds() and still it does not get updated...what am I doing wrong?

    Thanks.

  • #2
    Hi Alex,

    would you take a look at my problem posted here ...thank you.

    Comment


    • #3
      z11
      Try replacing "raw time" with "rawtime". If the problem persists you may need to post the entire script.
      For more information on "time" and "rawtime" see Date/Time Functions under EFS Function Reference in the EFS KnowledgeBase
      Alex

      Comment


      • #4
        hi Alex
        I beg your pardon ... I had a typo in the post ...I meant to say "rawtime" NOT "raw time"...so that is not the problem.

        Would you confirm my understanding of getValue("rawtime"):
        in each iteration of main(), this call should return a different value if time elapsed is more than 1 second? btw, I do not have SetComputeOnClose in preMain.. so it should be called on each tick in this efs....

        Thanks.

        Comment


        • #5
          Z11,

          rawtime will return the time at the start of the new bar for each tick...so the same time will be reported until a bar completes.

          G
          Garth

          Comment


          • #6
            z11
            "rawtime" returns the timestamp at the beginning of the bar.
            If you want the actual time you need to use the date object
            Alex

            Comment


            • #7
              Thanks for the clarification ...
              as I had mentioned in the first post, I did try to use the date object...

              so in place of cRT=getValue("rawtime");

              I tried:

              var cDate=new Date();
              var cRT = cDate.getSeconds();

              and that did not change the value of cRT in subsequent iterations of main() after the initial run through (as seen from debugPrintln)..

              still confused....

              Comment


              • #8
                z11
                As far as I can see that segment of code is working fine (see image below)
                Alex

                Comment


                • #9
                  Ok the comple efs code structure as follows...

                  var gvUpdateRawTime=0;
                  var gvUpdate=0;
                  var cRT=0;

                  function preMain() {
                  setStudyTitle("Sys1");
                  setCursorLabelName("Sys1");
                  setPriceStudy(false);
                  }

                  function main() {

                  var nIndex = getCurrentBarIndex();

                  if (nIndex < -1) return;
                  else {
                  var cDate=new Date();
                  cRT=cDate.getSeconds();

                  // cRT=getValue("rawtime");

                  if (gvUpdateRawTime==0) {
                  gvUpdateRawTime=cRT;
                  gvUpdate=1;
                  }
                  else if ((gvUpdateRawTime+30)<=cRT) {
                  gvUpdateRawTime=cRT; gvUpdate=1;
                  }
                  else if ((gvUpdateRawTime+30)>cRT) gvUpdate=0;

                  if (gvUpdate==1) {
                  debugPrintln("getting the globals at " +cRT);
                  }

                  debugPrintln("got the globals at "+cRT);
                  }

                  ...and cRT value never changes after the first iteration when the EFS is loaded....why?

                  Comment


                  • #10
                    Z11,

                    you need to call the date object each time you want the time. The only way it is not changing time is that you only called it once. Course, we could tell you exactly what the problem is... oops, look at that, it appears you have. I would say now, looking at your code, that your problems are with your logic and that you are having certain conditionals met unexpectedly.

                    Anyways, here is a link to my fileshare area where I have posted some of my code. There are one or two efs's there that exersizes a number methods of obtaining time.

                    Regarding your logic, I would strongly urge you to try my trace utility on my fileshare as well (in debug tools). The output goes to a file that can be opened from the advanced chart. It helps me greatly, maybe it will help you as well. I am off for a while, good luck.

                    Comment


                    • #11
                      Gentlemen,

                      the problem is resovled ...somehow as I had not changed anything from the code I posted...but it is not longer a problem..
                      Thanks Steve for pointing out your fileshare utilities....will go study them....

                      the grateful but still a bit puzzled ... but happy...

                      Comment

                      Working...
                      X