Announcement

Collapse
No announcement yet.

getBarStateSymbol() vs rawtime()

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

  • getBarStateSymbol() vs rawtime()

    To detect a new bar (BARSTATE_NEWBAR) in a different series (to the chart), ie "xSeries=sym("symbol,interval")", the proper siolution would seem to be use getBarStateSymbol("symbol,interval");, not getBarStateSymbol(xSeries); note, and test against BARSTATE_NEWBAR.

    But a quick timing check seems to indicate that testing "rawtime(0,xSeries) != mtLastRT" performs almost three times as fast and on my machine saves almost .1ms per iteration.
    As far as I can tell this will do the same job. Anyone got better info or see a flaw?

  • #2
    Hi Dave,

    You could try something similar like this. It may be a bit quicker...
    PHP Code:
    //~ inside a bInit Statement or equivalent...
    if(!bInit){
     var 
    xSeries=sym("symbol,interval");
     var 
    rawtimeX rawtime(xSeries);
     
    rawTS=getSeries(rawtimeX); //~ global variable
     
    bInit=true;
    }
    //~ then... 
    mtRT=rawTS.getValue(0);
    if(
    mtRT!==mtLastRT){
     
    mtLastRT=mtRT;
     
    //~ etc....

    Comment


    • #3
      Steve, thanks, I did write a longer reply touching on this curious getSeries() function I've never properly understood, but I seem to have lost it, may start again another time.

      Comment

      Working...
      X