Announcement

Collapse
No announcement yet.

Seconds

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

  • Seconds

    I have the following EFS, which I would like to access the time (in seconds) on the clock. However, all I get are that the function "seconds()" or "getSeconds()" returns zero.
    What am I doing wrong? It should be a number from 0 to 59, no?

    JOHN
    Attached Files

  • #2
    John
    You need to use the date object Try the following
    Alex

    PHP Code:
    var today = new Date();
    vTemp today.getSeconds();

    Alert.addToList("Seconds = " vTemp); 

    Comment


    • #3
      Alex,

      A thousand "thank you's"... that's perfect!

      JOHN

      Comment


      • #4
        John
        You are most welcome
        Alex

        Comment


        • #5
          Backtesting

          Alex,

          I am using that Date function (mentioned prior on this thread). It works great real-time. But, it does not seem to work in backtesting. Am I doing something wrong, or is that function only applicable in real-time?

          JOHN

          Comment


          • #6
            John
            The date object is only applicable to real time
            Alex

            Comment


            • #7
              Thanks, Alex, that explains why it isn't workting.

              Is there a way around this for BackTesting?

              I am interested in taking signals from my system only during certain times of the day, so I am looking for a way to code that into my STRATEGY.

              JOHN

              Comment


              • #8
                John
                In that case you would use bar time rather than system time (as in the following example)
                Alex

                PHP Code:
                if((getHour()*100)+getMinute() > 945 && (getHour()*100)+getMinute() < 1230)){
                     if(
                your_condition == true){
                          
                Strategy.doLong(...)
                //etc 

                Comment


                • #9
                  Gotchya... I'll do that instead.

                  Thnx

                  JOHN

                  Comment


                  • #10
                    Alex,

                    OK, now I've coded my EFS Strategy with a routine that uses BAR TIME and another routine that uses SYSTEM TIME. Doing it this way, I have to manually cange my EFS for when I am in backtesting mode, versus when I am in real-time mode. Furthermore, when I load a chart up for real-time data, the old signals do not appear .

                    Is there an elegant way to tap some built-in function that I can use something like this:

                    if (SpecialFunctionTrue) {
                    DoRealTimeMethodForReadingBarTime }

                    else {
                    DoTheBackTestingMethodForReadingBarTime }

                    That way, when I turn on my charts, my EFS Strategy would show both the prior trades that happened, and, also capture the new ones as they come in.

                    JOHN

                    Comment


                    • #11
                      John
                      Not sure I understand why you would need to use the date object when in real time.
                      Regardless what you could do is create two sets of conditions within the same efs, the first one based on bar time and the second on system time. Then you would enclose them in an if else statement as shown in the example below.
                      I believe that will provide you with what you you are trying to accomplish
                      Alex

                      PHP Code:
                      if(getCurrentBarIndex()<0){
                           
                      //your bar time code
                      }else{
                           
                      //your system time code

                      Comment


                      • #12
                        Alex,

                        FWIW, as per your prior post (on 9/12) on this thread, it was my understanding that, in real time , i HAD to use the Date Object.

                        Am I wrong in that ?

                        JOHN

                        Comment


                        • #13
                          John
                          That is not what I said. I said that the date object is only applicable to real time ie you can use it only in real time.
                          I did not say you had to use the date object for real time.
                          Alex

                          Comment


                          • #14
                            Ahhhhhh.... sorry for my mis-understanding.

                            And thnx for your clarification.

                            JOHN

                            Comment

                            Working...
                            X