Announcement

Collapse
No announcement yet.

Reset Tick Count

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

  • Reset Tick Count

    Hi,

    is it possible to reset the tick count back to zero at the open each day?

    There are 2 reasons for wanting to do this:

    1. I note that the bar shape can change depending on the data starting point when using tick charts;
    2. I want a fresh tick count when the markets startup to feed calculations;

    Currently I load 600 bars which can be done using a time template but this does not ensure I get a tick count starting from zero at the open. The inconsistnecy can affect post analysis as the bar shape may change if you close and reopen the chart at a later point in time, eg several hours later.

    Is this possible?

    Daniel
    DPLNeural
    www.expersignal.com

  • #2
    Hello Daniel,

    I assume you're storing the tick count with a global variable. Counting ticks can only be done in real time. So when you reload a chart, or study, the count after the initial load will reflect the number of bars in your chart, not the total ticks. Once the formula starts processing real time data you can count ticks. So as long as you start your formula before the open you can do the following to reset at the open.

    PHP Code:
    if (getBarState() == BARSTATE_NEWBAR && (getDay(0) != getDay(-1)) ) {
      
    nTick 0;
    }

    nTick++; 
    You should also set your time template to restrict the time to the trading session of the security you're following. Otherwise, you need to change the condition to check for the start time of the bar that is equal to or greater than the start time for the session.

    PHP Code:
    var nStart 930  // global

    // inside main()

    if (getBarState() == BARSTATE_NEWBAR) {   
       var 
    nBarTime = (getHour(0)*100 getMinute(0));
       if (
    nBarTime >= nStart) {
          
    nTick 0;
       }
       
       
    nTick++; 
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment

    Working...
    X