Login Page - Create Account

Support Board


Date/Time: Sat, 12 Jul 2025 00:47:39 +0000



EOD or holiday detection for auto trading?

View Count: 626

[2022-05-16 19:09:45]
User316362 - Posts: 211
I have an auto trader that trades everyday. I cancel any open orders programmatically at 16:00EST. I could also use the Global Profit/Loss Management to flatten orders at a specific time.

My problem comes in when we have a short day that ends at say 13:00 EST.

I'm in need of a way to get the "end of Day" programmatically to be able to flatten any remaining open orders on say a short trading day.

Does Sierra keep track of the "EOD (end of trading day)" somewhere I can access to make sure there are no open orders left trading at the EOD. Of course, most all days are the same but holidays create a problem with open orders sometimes remaining.

Or even a "holiday/Short Day" indicator (isShortTradingDay()) so that the auto trader can detect and avoid trading on those days? I'm looking for an ACSIL solution or even a change to the "Global Profit/Loss" settings to select "EOD" versus a specific time.
Date Time Of Last Edit: 2022-05-16 20:40:30
[2022-05-16 21:43:38]
John - SC Support - Posts: 40857
Sorry, there is no indicator of when a day has ended. There is just the lack of trading.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2025-07-01 05:51:34]
Tony - Posts: 611
@User316362

You probably already figured it out, just in case, if
you still need a function to detect holidays, I recently
wrote a function, given a SCDateTime, return values:
0: Normal situation, market open from Sun.6pm to Fri.6pm Eastern
1: Market Closed
2: Market Open until 13:00 Eastern

if you live in Eastern time zone, you could add SCDateTime::HOURS(6)
to the variable "InputDateTime", then the detection is based on sessions,
instead of calendar days, that might be a better solution.


int HolidayCheck(SCDateTime InputDateTime)
{
  int year = InputDateTime.GetYear();
  int GF_Day {0};
  int GF_Month {0};
  int g = (int)(year % 19);
  int c = (int)(year / 100);
  int h = (int)((c - (int)(c / 4) - (int)((8 * c + 13) / 25) + 19 * g + 15) % 30);
  int i = h - (int)(h / 28) * (1 - (int)(h / 28) * (int)(29 / (h + 1)) * (int)((21 - g) / 11));
  GF_Day = i - (int)((year + (int)(year / 4) + i + 2 - c + (int)(c / 4)) % 7) + 26;
  GF_Month = 3;
  if (GF_Day > 31) {
    GF_Month++;
    GF_Day -= 31;
  }

  int Month {InputDateTime.GetMonth()};
  int Day {InputDateTime.GetDay()};
  int WeekDay {InputDateTime.GetDayOfWeek()};
  int ReturnValue {0};

  if (WeekDay != 6) {
    if (
      Month==1 && Day==1
      ||
      Month==1 && Day==2 && WeekDay==1
      ||
      Month==GF_Month && Day==GF_Day
      ||
      Month==7 && Day==4
      ||
      Month==11 && WeekDay==4 && Day>21 && Day<=28
      ||
      Month==12 && Day==25
      ||
      Month==12 && Day==24 && WeekDay==5
      ||
      Month==12 && Day==26 && WeekDay==1
    )
      ReturnValue = 1;

    if (
      Month==1 && WeekDay==1 && Day>14 && Day<=21
      ||
      Month==2 && WeekDay==1 && Day>14 && Day<=21
      ||
      Month==5 && WeekDay==1 && Day+7>31
      ||
      Month==6 && Day==19
      ||
      Month==6 && Day==18 && WeekDay==5
      ||
      Month==6 && Day==20 && WeekDay==1
      ||
      Month==7 && Day==3 && WeekDay>0 && WeekDay<6
      ||
      Month==7 && Day==5 && WeekDay==1
      ||
      Month==9 && WeekDay==1 && Day<=7
      ||
      Month==11 && WeekDay==5 && Day-1>21 && Day-1<=28
      ||
      Month==12 && Day==24 && WeekDay>0 && WeekDay<5
    )
      ReturnValue = 2;
  }

  return ReturnValue;
}

Date Time Of Last Edit: 2025-07-01 07:04:44

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account