Announcement

Collapse
No announcement yet.

Finding first bar of day

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

  • Finding first bar of day

    Hi,
    I am based in the UK and running EFS scripts against intraday charts with a GMT defined template that runs from 14:30 to 21:00 hours in the UK. I need to be able to identify the first bar of the day and the last bar of the day. Code below to do this.

    var nInterval = getInterval(0);
    var nHour = getHour(0);
    var nMinute = getMinute(0);

    if (nHour == 14 && nMinute == 30) firstbarofday = true;
    else firstbarofday = false;

    if ((nHour == 20) && (nMinute == 60 - nInterval)) lastbarofday = true;
    else lastbarofday = false;

    I have hit a problem with British Summer Time. For the week of 27 Oct 08 to 31 Oct 08 the UK clocks went back but the US clocks did not.

    My charts automatically showed bars from 13:30 to 19:00 for that week without having to change the time template.

    With my code above I am missing the firstbar of day at 13:30 and picking it up an hour later at 14:30 and I am not picking up the last bar of day at all.

    Any suggestions of how to code this to correctly pick up the right bars?

  • #2
    Re: Finding first bar of day

    richthomas
    I am assuming that this would be used in the context of a back test given that you posted your question in the EFS Back Testing forum
    In this case you could define the first and last bars simply by looking for a change of bar date rather than a specific time ie
    PHP Code:
    if(day(0)!=day(-1)) //if current bar's date is not equal to prior bar's date - first bar
    if(day(0)!=day(1)) //if current bar's date is not equal to next bar's date - last bar 
    Note that the latter condition would only work in back testing historical data where the following bar is a known entity
    Alex


    Originally posted by richthomas
    Hi,
    I am based in the UK and running EFS scripts against intraday charts with a GMT defined template that runs from 14:30 to 21:00 hours in the UK. I need to be able to identify the first bar of the day and the last bar of the day. Code below to do this.

    var nInterval = getInterval(0);
    var nHour = getHour(0);
    var nMinute = getMinute(0);

    if (nHour == 14 && nMinute == 30) firstbarofday = true;
    else firstbarofday = false;

    if ((nHour == 20) && (nMinute == 60 - nInterval)) lastbarofday = true;
    else lastbarofday = false;

    I have hit a problem with British Summer Time. For the week of 27 Oct 08 to 31 Oct 08 the UK clocks went back but the US clocks did not.

    My charts automatically showed bars from 13:30 to 19:00 for that week without having to change the time template.

    With my code above I am missing the firstbar of day at 13:30 and picking it up an hour later at 14:30 and I am not picking up the last bar of day at all.

    Any suggestions of how to code this to correctly pick up the right bars?

    Comment


    • #3
      Finding first bar of day

      Thanks Alex.
      That does the job.

      Comment


      • #4
        Re: Finding first bar of day

        richthomas
        You are most welcome
        Alex


        Originally posted by richthomas
        Thanks Alex.
        That does the job.

        Comment

        Working...
        X