Announcement

Collapse
No announcement yet.

Delay time

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

  • Delay time

    I am wondering if anybody has a simple solution for a something like WAIT command.
    I need that after submitting an order the efs will wait X seconds and than continue.
    JR

  • #2
    I think you could use getValue("rawtime") in a loop... the loop would continue until x-number of seconds have passed.

    Chris

    Comment


    • #3
      Tx. I will try this.

      Comment


      • #4
        This will set a delay of a variable amount.

        var today;
        var CurMin;
        var CurSec;
        var cTimeSec;
        var cTimeSecOld;
        var delay=15; //seconds
        function main(){
        today =new Date;
        CurMin =today.getMinutes();
        CurSec =today.getSeconds();
        cTimeSec =CurMin*60+CurSec*1;
        if(cTimeSecOld==null){
        cTimeSecOld=cTimeSec}
        if(cTimeSec>cTimeSecOld+delay){

        //this is where the code you want to skip over should go

        debugPrintln("Delay is over");
        cTimeSecOld=cTimeSec;
        }
        debugPrintln("Delay ain't over "+cTimeSec+" "+cTimeSecOld);
        return;}

        Comment


        • #5
          FWIW, use David's idea. You don't want to loop inside the EFS for X seconds.

          m.
          Matt Gundersen

          Comment


          • #6
            There is an issue with the efs when the minutes roll over from 60 to 0, the following fixes that ..

            var today;
            var CurMin;
            var CurSec;
            var cTimeSec;
            var cTimeSecOld;
            var delay=15; //seconds
            function main(){
            today =new Date;
            CurMin =today.getMinutes();
            CurSec =today.getSeconds();
            cTimeSec =CurMin*60+CurSec*1;

            if(cTimeSec<cTimeSecOld){
            cTimeSec=cTimeSec+3600;
            }
            if(cTimeSecOld==null){
            cTimeSecOld=cTimeSec}
            if(cTimeSec>cTimeSecOld+delay){

            //this is where the code you want to skip over should go

            debugPrintln("Delay is over");
            cTimeSecOld=cTimeSec;
            }
            debugPrintln("Delay ain't over "+cTimeSec+" "+cTimeSecOld);
            return;}

            Comment


            • #7
              Thanks, I will do this with your efs.
              There is still one problem left.
              At the time that the market is not so active (at night) the 15 sec delay can be 30 or even few minutes because it waits for any movement in the security (future). If the security is not traded it will not count!

              JR

              Comment

              Working...
              X