Announcement

Collapse
No announcement yet.

Time

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

  • Time

    Good Morning,

    I would like to read two times into an EFS. The first is the last time on an EFS tick chart. Is "getSeconds" the correct function to read the EFS time?

    The second time is the time on the computer. What function would be used to read the computer seconds in a way that it could be used as a variable?

    Best Regards,

    Alan

  • #2
    Alan
    To retrieve the bar time you can use the hour(), minute() and second() functions (see the respective links for the required syntax).
    To retrieve the computer time instead you neeed to use the Date Object.
    Enclosed below is a basic example of both bar time and computer time. If you search the forums you should find several threads that include detailed examples on how to retrieve/manipulate the time using either method.
    Alex

    PHP Code:
    function preMain(){
        
    setPriceStudy(true);
        
    setShowCursorLabel(false);
    }
     
    function 
    main(){
     
        
    //to retrieve bar time
        
    var BarTime padTime(hour(0))+":"+padTime(minute(0))+":"+padTime(second(0));
        
    //to retrieve computer time
        
    var myDate = new Date();
        var 
    PCTime padTime(myDate.getHours())+":"+padTime(myDate.getMinutes())+":"+padTime(myDate.getSeconds());
            
        
    drawTextRelative(0BottomRow1"Bar Time is: "+BarTimeColor.bluenull
                         
    Text.PRESET|Text.RIGHT"Arial"12"bartime");
        
    drawTextRelative(0BottomRow2"Computer Time is: "+PCTimeColor.bluenull
                         
    Text.PRESET|Text.RIGHT"Arial"12"pctime");
     
        return;
    }
     
    function 
    padTime(input){
        if(
    input<10
            var 
    ret "0"+input;
        else 
            var 
    ret input;
        return 
    ret;

    Comment


    • #3
      Alex,

      Thank you for the detailed responce.

      I am trying to create an alert program which lets me know if the data feed is lagging or has stopped completely due to a problem with the exchange. If the times differ by more than 20 seconds, an alarm would sound.

      I modified your code to calculate the seconds only and plotted them on a 1T chart of $INDU. It appears when a bar is plotted, the times are updated and remain almost identical. Is there any way in EFS to calculate the difference between these values if the data feed is cut off and the next bar does not get posted because there is no data?

      If the answer is no, could the calculation be done in Excell or Lotus where the the sheat reads a static value from EFS since there is no data feed and the sheet reads the PC time which continues to change?

      If the answer is yes, how do I export the bar time from EFS and read it into Excell or Lotus?

      As always, you support is greatly appreciated.

      Best Regards,

      Alan

      Comment


      • #4
        Alan
        The simplest way I can think of to compute the difference between bar time and computer time is to convert both to rawtime as I do in the enclosed revision of the script I posted earlier (note that I am also displaying the computer and bar times as hh:mm:ss only for comparison purposes)

        PHP Code:
        function preMain(){
            
        setPriceStudy(true);
            
        setShowCursorLabel(false);
        }
         
        function 
        main(){
         
            
        //to retrieve bar time
            
        var xTime getValue("Time");
            var 
        BarRawTime parseInt(xTime.getTime()/1000);
            var 
        BarTime padTime(xTime.getHours())+":"+padTime(xTime.getMinutes())+":"+padTime(xTime.getSeconds());
            
        //to retrieve computer time
            
        var myDate = new Date();
            var 
        PCRawTime parseInt(myDate.getTime()/1000);
            var 
        PCTime padTime(myDate.getHours())+":"+padTime(myDate.getMinutes())+":"+padTime(myDate.getSeconds());
               
         
            
        drawTextRelative(0BottomRow3"Bar Time is: "+BarTime+"  "+BarRawTimeColor.bluenull
                             
        Text.PRESET|Text.RIGHT"Arial"12"bartime");         
            
        drawTextRelative(0BottomRow2"Computer Time is: "+PCTime+"  "+PCRawTimeColor.bluenull
                             
        Text.PRESET|Text.RIGHT"Arial"12"pctime");
                      
            var 
        TimeDiff = (PCRawTime-BarRawTime);
            
        drawTextRelative(0BottomRow1"Time Difference is: "+TimeDiff+" seconds"Color.bluenull
                             
        Text.PRESET|Text.RIGHT"Arial"12"difftime");                 
         
            return;
        }
         
        function 
        padTime(input){
            if(
        input<10
                var 
        ret "0"+input;
            else 
                var 
        ret input;
            return 
        ret;



        However because an efs will only execute on a trade the computer time in the efs will not be updated if trades are not being received at your end hence I don't think you would be able to determine within the efs that the data feed has stopped.
        As to doing this in Excel it may be possible but I would not know how it could be accomplished.
        Alex

        Comment


        • #5
          Alex,

          Thank you for the assistance.

          Best Regards,

          Alan

          Comment


          • #6
            Alan
            My pleasure
            Alex

            Comment

            Working...
            X