Login Page - Create Account

Support Board


Date/Time: Fri, 03 Apr 2026 22:27:03 +0000



Post From: Study for Holiday Reminder

[2026-04-03 18:16:34]
Tony - Posts: 713
I wrote a study for holiday reminder, so you will never have to worry that you would forget a holiday when market is closed (or close early), it reminds you on the holiday and one day ahead. i.e. said "Close Tomorrow" yesterday, and says "Close Today" right now. (I am writing this message on Good Friday)

Sorry, the message "close 10 am" is for Pacific, I am too lazy to change it, too much work (different daylight saving schedules etc.), you can always make the change yourself based on your local time zone.

In case you need instructions on how to build custom studies from source code, here is the link: How to Build an Advanced Custom Study from Source Code


#include "sierrachart.h"

SCDLLName("HolidayCheck")

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==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
      ||
      Month==7 && Day==4 && WeekDay>0
      ||
      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;
}


SCSFExport scsf_TemplateFunction(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    sc.GraphName = "Holiday Check";
    sc.GraphRegion = 0;
    sc.AutoLoop = 1;
    sc.UpdateAlways = 1;
    
    sc.Input[0].Name = "Vertical Position";
    sc.Input[0].SetInt(92);

    sc.Input[1].Name = "Horizontal Position";
    sc.Input[1].SetInt(120);

    sc.Input[2].Name = "Font Size";
    sc.Input[2].SetInt(12);

    sc.Input[3].Name = "Font Color";
    sc.Input[3].SetColor(127,127,255);
    
    sc.Input[4].Name = "Flash Message";
    sc.Input[4].SetYesNo(0);
    
    return;
  }
  
    int CheckToday {HolidayCheck(sc.CurrentSystemDateTime)};
    int CheckTomorrow {HolidayCheck(sc.CurrentSystemDateTime+SCDateTime::DAYS(1))};
    SCString MessageString {""};
    MessageString.Format("\n");
    if (CheckToday == 1)
      MessageString.AppendFormat("[ Close Today ]\n\n");
    if (CheckToday == 2)
      MessageString.AppendFormat("[ Until 10 am Today ]\n\n");
    if (CheckTomorrow == 1)
      MessageString.AppendFormat("[ Close Tomorrow ]");
    if (CheckTomorrow == 2)
      MessageString.AppendFormat("[ Until 10 am Tomorrow ]");
    
    if (!(sc.CurrentSystemDateTime.GetSecond()%5) && sc.Input[4].GetYesNo())
      MessageString.Format("\n");
      

    s_UseTool Tool;
    Tool.Clear();
    Tool.ChartNumber = sc.ChartNumber;

    Tool.LineNumber = 74191;
    Tool.DrawingType = DRAWING_TEXT;
    Tool.UseRelativeVerticalValues = 1;

    Tool.BeginDateTime = sc.Input[1].GetInt();
    Tool.EndDateTime = sc.Input[1].GetInt();
    Tool.BeginValue = sc.Input[0].GetInt();
    Tool.EndValue = sc.Input[0].GetInt();
    Tool.FontSize = sc.Input[2].GetInt();
    Tool.Color = sc.Input[3].GetColor();
    Tool.AddMethod = UTAM_ADD_OR_ADJUST;
    Tool.Text = MessageString;

    sc.UseTool(Tool);

}

Date Time Of Last Edit: 2026-04-03 18:31:45