awo Holidays

Download script
Author: AWo
awo Holidays

This script is designed to provide traders with a clear visual and informational overview of market schedules, specifically highlighting weekends and public holidays. It automates the process of identifying whether the market is currently in a "working" state or if it is affected by specific regional closures.

Core Functionality

1. Automated Calendar Tracking The script references an external data file (a CSV document) containing a list of international holidays. By cross-referencing this file with the current market symbol and date, the tool can automatically detect specific public holidays that might affect trading liquidity or price action.

2. Visual Chart Marking The tool draws distinct vertical lines on your trading chart to separate different days. These lines serve as visual anchors:

  • Current Day Markers: It creates a visual boundary for the current day's activity.
  • Previous Period Markers: It highlights the transition from the previous day.
  • Dynamic Coloring: The script intelligently changes the color of these lines based on the market status. For example, it uses different colors to distinguish between standard workdays, weekends (Saturdays and Sundays), and specific holiday periods.

3. Real-Time Status Dashboard In addition to the visual lines, the script generates a text summary directly on your chart screen. This "Status Dashboard" provides a quick glance at the following:

  • The status of the previous day.
  • The status of today.
  • A multi-day lookback (showing the status of the last 4 days).

For each of these days, it explicitly labels whether the day was a workday or a weekend, and specifically identifies if it was a "Fiesta" (holiday) along with the specific country name provided in your data file.

4. User Customization & Cleanup The tool is designed to be user-friendly by allowing for specific visual preferences, such as the number of lines displayed and the specific colors used for workdays versus holidays. Furthermore, it includes a "cleanup" feature that ensures your chart remains tidy by automatically removing the drawn lines when you remove the script from the platform.

Summary of Benefits

By using this script, you no longer need to manually check external calendars to see if markets are closed or operating on reduced schedules. It provides an immediate, color-coded visual environment that helps you stay aware of market holidays and weekend transitions at a glance.

Miscellaneous
Uses files from the file systemIt reads information from a file
8 Views
0 Downloads
0 Favorites
awo Holidays
//+------------------------------------------------------------------+
//|                                                 awo Holidays.mq4 |
//|                                                              AWo |
//|                                                     a-wo@mail.ru |
//+------------------------------------------------------------------+
#property copyright "AWo"
#property link      "a-wo@mail.ru"

extern int Numbers_of_Lines=3;
extern bool Del_Lines_If_Deinit=true;
extern string FileName="holidays.csv";
extern color clrWork=LightBlue;
extern color clrWE=Blue;
extern color clrHLD=DarkOrange;

int tm24h=86400, tm1h=3600;

//+------------------------------------------------------------------+
//| Ô ÄÀÒÀ ÄÍß, poz - ïîçèöèÿ äíÿ >0 â ïðîøëîì, <0 â áóäóùåì, ( -2 - ïîñëåçàâòðà, 1 - â÷åðà )
//+------------------------------------------------------------------+
datetime Data( int poz ) { return ( TimeCurrent( )-tm24h*poz ); }
string DataString( int poz ) { return ( TimeToStr(Data(poz),TIME_DATE) ); }

   
//+------------------------------------------------------------------+
//| Ô Âûõîäíûå, poz - ïîçèöèÿ äíÿ >0 â ïðîøëîì, <0 â áóäóùåì, ( -2 - ïîñëåçàâòðà, 1 - â÷åðà )
//+------------------------------------------------------------------+

string isWeekEnd( int poz )
      {
      int N; string DOW;
       N=TimeDayOfWeek(Data(poz));
   if( N==0 ) DOW="sunday";
   if( N==1 || N==2 || N==3 || N==4 || N==5 ) DOW="workday";
   if( N==6 ) DOW="saturday";
      return(DOW);
      }

//+------------------------------------------------------------------+
//| Ô CÒÀÒÓÑ ÄÍß, poz - ïîçèöèÿ äíÿ >0 â ïðîøëîì, <0 â áóäóùåì, ( -2 - ïîñëåçàâòðà, 1 - â÷åðà )
//+------------------------------------------------------------------+

string isFiesta( int poz )
      {
   string sDT, sCountry, sSymb, sHoliday, tomorrow="";
   int handle= FileOpen(FileName,FILE_CSV|FILE_READ,';');

   while (FileIsEnding(handle)==false)
            {
         sDT=        FileReadString(handle,0);
         sCountry=   FileReadString(handle,0);
         sSymb=      FileReadString(handle,0);
         sHoliday=   FileReadString(handle,0);

         if (sDT==DataString(poz) && StringFind(Symbol(),sSymb,0)!=-1) break;
            }
               FileClose(handle) ;
      if (sDT==DataString(poz)) tomorrow = sHoliday+" in "+sCountry;
      return (tomorrow);
      }



//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

void start()
  {
  
   string nmSwapLine="SWAP "+DataString(-1)+" "+isWeekEnd(-1)+" "+isFiesta(-1);
   string nmDayLine="DAY "+DataString(-1)+" "+isWeekEnd(-1)+" "+isFiesta(-1);

   ObjectCreate(nmSwapLine,OBJ_TREND,0,TimeCurrent( )+tm24h-tm1h*3,WindowPriceMax(),TimeCurrent( )+tm24h-tm1h*3,WindowPriceMin(),0,0);
   ObjectCreate(nmDayLine,OBJ_TREND,0,TimeCurrent( )+tm24h,WindowPriceMax(),TimeCurrent( )+tm24h,WindowPriceMin(),0,0);

                                    ObjectSet(nmSwapLine,OBJPROP_WIDTH,2);
                                    ObjectSet(nmSwapLine,OBJPROP_TIMEFRAMES,OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|OBJ_PERIOD_M30|OBJ_PERIOD_H1|OBJ_PERIOD_H4);
   if ( isWeekEnd(-1)=="workday" )  ObjectSet(nmSwapLine,OBJPROP_COLOR,clrWork);
   else                             ObjectSet(nmSwapLine,OBJPROP_COLOR,clrWE);
   if ( isFiesta(-1)!="" )          ObjectSet(nmSwapLine,OBJPROP_COLOR,clrHLD);

                                    ObjectSet(nmDayLine,OBJPROP_STYLE,STYLE_DOT);
                                    ObjectSet(nmDayLine,OBJPROP_TIMEFRAMES,OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|OBJ_PERIOD_M30|OBJ_PERIOD_H1);
   if ( isWeekEnd(-1)=="workday" )  ObjectSet(nmDayLine,OBJPROP_COLOR,clrWork);
   else                             ObjectSet(nmDayLine,OBJPROP_COLOR,clrWE);
   if ( isFiesta(-1)!="" )          ObjectSet(nmDayLine,OBJPROP_COLOR,clrHLD);


    
  Comment( "\n","Â÷åðà      ",        isWeekEnd(1)+  " ("+isFiesta(1)+ ")",
           "\n","Ñåãîäíÿ   ",      isWeekEnd(0)+  " ("+isFiesta(0)+ ")",
           "\n","Çàâòðà     ",       isWeekEnd(-1)+ " ("+isFiesta(-1)+")",
           "\n","ïÇàâòðà    ",      isWeekEnd(-2)+ " ("+isFiesta(-2)+")",
           "\n","ïïÇàâòðà   ",     isWeekEnd(-3)+ " ("+isFiesta(-3)+")"    );

  }

void deinit() {   if ( Del_Lines_If_Deinit==true ) ObjectsDeleteAll(0,OBJ_TREND);  }
      

Comments