Announcement

Collapse
No announcement yet.

Last Bar of Day for an Intraday Chart

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

  • Last Bar of Day for an Intraday Chart

    Below is a portion of the EFS code I built to determine the relationship of two indicators on an intraday chart at a specific time of day. I simultaneously use this code on four time frames for the equities markets. I also have my time templates set for equity RTH-East Coast (9:30-16:00)

    You’ll notice that I use getHour() == 15 and getMinute() == 58 in my code. This works great except when the last bar of the day is not the time I specify in the code.

    Therefore, is there a last bar of day function that knows which bar is the last bar of the day on an intraday chart?

    I know I’m going to have issues with this code on Good Friday and other days where the market closes before 4 PM EST.

    Thanks in advance.

    function main() {
    if (
    vToday < vExpire &&
    getInterval() == 2 &&
    vEMA50.getValue(MAStudy.MA) > vEMA200.getValue(MAStudy.MA) &&
    getHour() == 15 &&
    getMinute() == 58
    ) onAction1();

    //}}EFS_Expression_1

    //{{EFS_Expression_2

    if (
    vToday < vExpire &&
    getInterval() == 2 &&
    vEMA50.getValue(MAStudy.MA) < vEMA200.getValue(MAStudy.MA) &&
    getHour() == 15 &&
    getMinute() == 58
    ) onAction2();

    //}}EFS_Expression_2

  • #2
    To my knowledge the eSignal application doesn't have an exchange holiday schedule available through EFS or otherwise. Further, I don't believe even the exchange and per symbol session(s) start and end times are available for a typical week.

    This might sound simple to implement, until you consider all the exchanges eSignal provides, and that session time can vary on a per symbol basis (for example, with futures contracts).

    To get what you want, you might be able to retroactively access 2 bars prior to the 9:30am EST start of session bar. However, this would not work in realtime.

    The only other thing you could do is test for a holiday in your code and use an alternate closing time. Haven't tested it, but something like:
    PHP Code:
    // Note rawtime (0) returns seconds since 1970, 
    // while Date.getTime() return MILLIseconds since 1970.

    // Assuming the 24th is the last trading day before Christmas...
    var holidayDateStart = new Date ("December 24, 2010 00:00:00");
    var 
    holidayDateEnd = new Date ("December 25, 2010 00:00:00");

    function 
    main () {
        var 
    rawtime_0 rawtime (0);
        if ((
    rawtime_0 > (holidayDateStart.getTime() / 1000)) 
            && (
    rawtime_0 < (holidayDateEnd.getTime() / 1000))) {
            
    debugPrintln ("rawtime of " + new Date (rawtime_0 1000) + " has a shortened trading session.");
        }

    Comment

    Working...
    X