Announcement

Collapse
No announcement yet.

Getting Current Time on Daily Chart

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

  • Getting Current Time on Daily Chart

    I use the below on intraday charts to retrieve the current bar time:

    var vTime = (getHour()*100)+ getMinute(); // get current time

    This expression does not actually return the current time, but rather the start time of the current bar.

    This technique doesn't work on a Daily chart because there is only one bar. So you always get the start time of the day.

    How would one retrieve the actual current time so it can be compared to a preset time and then make something happen on a Daily chart?

    For example
    if (vTime > XX) Do Y;

    bigtee

  • #2
    bigtee
    Here is one way of retrieving the current system time. The resulting value should be hhmmss
    Alex

    PHP Code:
    var vDate = new Date();

        var 
    vHr vDate.getHours()+"";
        if (
    vHr <10
            
    vHr 0+vHr;

        var 
    vMin vDate.getMinutes()+"";
        if (
    vMin 10
            
    vMin 0+vMin

        
    var vSec vDate.getSeconds()+"";
        if(
    vSec 10
            
    vSec 0+vSec;

        var 
    vTime vHr+vMin+vSec

    Comment


    • #3
      Thanks Alex.
      This works. I now get the correct time.

      FYI, what I am attempting to do is force a timed recalculation of an efs on a Daily chart. It is fairly compute intensive, and I don't need it to update every tick, so I am trying to make it recalculate at specific times throughout the day, like maybe every hour on the hour. It should work now but I won't know for sure until Monday.

      Thanks again.

      bigtee

      Comment

      Working...
      X