Announcement

Collapse
No announcement yet.

Get the time

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

  • Get the time

    What would be the easiest way to determine the current time and put in a form that can be evaluated?

    For example:

    ....
    if (vTime > 630 || vTime <= 730) {...}

    630 is 6:30am and 730 is 7:30am.

    Thank you.
    Mihai Buta

  • #2
    I do this

    function preMain()
    {
    var today;
    var CurMinutes;//0-59 minutes
    var CurTime; //hr*100+min
    var CurHours; //0-23 hours
    var CurSeconds;//0-59 seconds
    }
    function main()
    {
    today =new Date;
    CurHours =today.getHours();
    CurMinutes=today.getMinutes();
    CurTime =CurHours * 100 + CurMinutes * 1;
    CurSeconds=today.getSeconds();
    if(CurSeconds<10){CurSeconds="0"+CurSeconds;}

    if( CurTime >= StartTradingTime
    && CurTime <= EndTradingTime)
    ...
    }

    Comment


    • #3
      Thanks. I'll do it.
      Mihai Buta

      Comment


      • #4
        Note that dloomis' code retrieves the current time as it is set on your computer at the moment that this is run. If you want to retrieve the time of the current BAR, then use the:

        getHour()
        getMinute()
        getSecond() functions.

        Comment

        Working...
        X