Announcement

Collapse
No announcement yet.

Are seconds(0), minutes(0) true dataseries?

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

  • Are seconds(0), minutes(0) true dataseries?

    Hi,

    Are those functions true data series, like high(0) and low(0), in the sense that, DURING THE BAR, they report the actual seconds and minutes [of the last tick]?

    I need a confirmation because I have hard time testing it [reports only the time of the first tick of the bar].


    Thank you.
    Last edited by mbuta; 07-21-2008, 10:17 PM.
    Mihai Buta

  • #2
    And the answer is: No, they do NOT change during the bar, as one would expect from documentation. I wonder if they are the only ones.

    I don't know if it is a design error or made in purpose, but they are pretty much useles, as they are, for real time processing.

    They could have been the [only efficient] answer for skipping ticks in busy times.

    Note: I hope nobody will mention new Date object as efficient method, because it is not.
    Note: I also hope nobody will blame my computer or efs for the performance problem. My efs executes in about 0.14ms [average of 6x4 instances]. The real problem is that efs engine forces us to execute main on EVERY tick, even if it happened long time ago [so useless for any decision].
    Note3. I also tried seconds(0,inv("1S")). It is only somewhat better than creating Date object every tick.

    Sincerely,
    Mihai Buta

    Comment


    • #3
      Re: Are seconds(0), minutes(0) true dataseries?

      Hi Mihai,

      high(0), low(0), seconds(0) and minutes(0) return values, not series objects.

      high(), low(), seconds() and minutes() will return series objects, but the high() and low() series objects do not contain methods to access any time values. I'll show you how to use the second(inv("1S")) series to access time values (for a longer interval chart).

      second(0) and minute(0) will remain constant throughout the bar.

      Originally posted by mbuta
      Hi,

      Are those functions true data series, like high(0) and low(0), in the sense that, DURING THE BAR, they report the actual seconds and minutes [of the last tick]?
      ...

      Thank you.


      There are some techniques that can be implemented to create conditionals that will be satisfied every second. I enclosed an example below. Hopefully, the code is self explanatory and will be of some assistance.

      Whenever you skip efs execution, you will still have to return values to the chart.

      You will also have to ensure accurate values are returned the last tick before a new bar are returned to the chart.

      Originally posted by mbuta


      ...
      They could have been the [only efficient] answer for skipping ticks in busy times.
      ...

      PHP Code:
      /*********************************************************
      By Steve Hare © July 2008 
      Demonstration EFS showing how to efficiently use the second() series
      to obtain the Seconds of a different interval and use it in the primary efs 
      in a conditional. Run this in a chart where the native interval is 1 minute or greater.

      Use and/or modify this code freely. If you redistribute it
      please include this and/or any other comment blocks and a 
      description of any changes you make.  
      *****************************************************/

      function preMain(){
       
      //~ setPriceStudy(false);
       
      setPriceStudy(true);
       
      setStudyTitle("Second Series");
       
      setShowCursorLabel(false);
       
      setShowTitleParameters(false);
      }

      var 
      lastSec,sec1,bInit;
      var 
      count=0;

      function 
      main(){ 
       if(!
      bInit){ // !undefined evaluates to true 
        
      sec1=second(inv("1S")); // creates a series and assigns to a global variable
        
      debugPrintln("26: sec1 = "+sec1.getValue(0));
        
      bInit=true;
       }
       
       var 
      tmpSec=sec1.getValue(0);
       if(
      tmpSec!=lastSec){ // will be true every second
        // conditionals to minimize debug output, excessive use of debugPrintln will result in performance degradation
        
      count++;
        if(!(
      count%100)){ // will only debug output every 100th count
         
      debugPrintln("35: tmpSec = "+tmpSec+", count= "+count);
        }
        
      lastSec=tmpSec;
       }
       

      Comment


      • #4
        Hi Steve and good to hear from,

        I understand what you are saying and I will try it.

        I did not hink to declare it as a study first for many reasons:
        a/ Is listed as a data series, like open, close, etc. We never declare them, they are there and we just call the value we want.
        b/ Nowhere in the "documentation" is this necesity explained. You made it look so simple and obvious.
        c/ I was told before that lower interval studies return one value per bar anyway.


        I will try it and report if performance improves. Right now, I simply avoid "busy" symbols, or trade them blindly [which is stupid].

        Thank you Steve and kind regards to you.
        Mihai Buta

        Comment


        • #5
          Hi Mihai,

          Your most welcome, nice hearing from you as well. I hope the efs helps or otherwise gives you some ideas.

          I created another version of the efs that used the efsInternal() function to create an series that returned the barcount of the lower interval. It wasn't as quick as the Second Series.efs version I previously posted. Since it is a different technique to accomplish the same thing, I thought I'd post that too.

          After you satisfy yourself the example efs(s) work correctly, and want to run some performance tests, make sure you eliminate the unnecessary conditionals.

          Regarding your note on being told that the lower interval studies will return only one value per bar, it is true when loading historical data {by using getValue(0)}. However, when loading historical data, you can still access all of the lower interval data by using the getValue() method and previous index values. (e.g. (-1), (-2), (-3), etc).

          PHP Code:
          /*********************************************************
          By Steve Hare © July 2008 - BarCount Series.efs
          Demonstration EFS showing how to efficiently use efsInternal() 
          to create a series object representing the barcount of an
          external interval and use it in the primary efs in a conditional.
          Run this in a chart where the native interval is 1 minute or greater.

          Use and/or modify this code freely. If you redistribute it
          please include this and/or any other comment blocks and a 
          description of any changes you make.  
          *****************************************************/

          function preMain(){
           
          //~ setPriceStudy(false);
           
          setPriceStudy(true);
           
          setStudyTitle("BarCount Series");
           
          setShowCursorLabel(false);
           
          setShowTitleParameters(false);
          }

          var 
          lastBar,bar1,bInit;
           
          function 
          main(){ 
           if(!
          bInit){ // !undefined evaluates to true 
            
          bar1=efsInternal("IntervalBarCount",(inv("1S")));
            
          debugPrintln("26: bar1 = "+bar1.getValue(0));
            
          bInit=true;
           }
           var 
          tmpBar=bar1.getValue(0);
           if(
          tmpBar!=lastBar){
             
          // conditionals to minimize debug output, excessive use of debugPrintln will result in performance degradation
             
          if(!(tmpBar%100)){ // will only debug output every 100th bar from external interval
             
          debugPrintln("33: tmpBar = "+tmpBar);
            }
            
          lastBar=tmpBar;
           }
          }

          function 
          IntervalBarCount(){
           return 
          getCurrentBarCount();

          Comment


          • #6
            Hi Steve,

            Thank you again.

            As I run for performance, I go for the minimum solution that works. Here is how I did it: In Real Time, I allow 10 tick on every second and suppress the rest.

            The code is only couple of lines. The performance is better, I still get "freezes", but much shorter and recovers. I will watch it a few more days before deciding to improve more [allow even less tick/sec for active symbols, which I already have it calculated].

            I return the array calculated last time around and on NewBar I correct the last bar, to have the correct display. I need to do the same thing for Plot paints and Background, but no hurry.

            Thank you again for your help. I hope to be able to return the favor. Please do not hesitate to ask.

            Best regards,
            Mihai Buta

            Comment


            • #7
              Regarding the lower time intervals: This second("1S") is all I need.
              As you know, my approach is multiple intervals, starting from low ones.
              I run four time intervals on every chart and with two windows I cover from 5min all the way up to 20 days.

              I calculate Synchronized OB/OS [for all intervals I want to consider] and time the entry/exits from the lowes interval.


              Regards,
              Mihai Buta

              Comment

              Working...
              X