i-DayOfWeek(1)

Download script
Author: ��� ����� �. aka KimIV
i-DayOfWeek(1)

This tool is designed for traders using the MetaTrader platform to visually identify specific days of the week on their trading charts. It simplifies the process of monitoring market history by highlighting a user-selected day with visual markers, making it easier to spot recurring patterns or trends that occur on particular days.

How the Logic Works

1. User Customization The script allows you to define two primary settings:

  • Target Day: You can choose which specific day of the week you want to track (e.g., every Monday, Wednesday, etc.).
  • Historical Depth: You can decide how far back into the past the tool should scan. You can set this to a specific number of candles or let it analyze the entire available history.

2. Automated Identification Instead of manually searching through charts, the script automatically scans the historical price data. It identifies every instance where the calendar day matches your chosen selection.

3. Dynamic Visual Markers Once the script finds a matching day, it places two arrows on the chart: one at the top and one at the bottom of the price range for that period. To ensure these markers are clearly visible and do not overlap with the actual price candles, the script features an intelligent spacing logic. It automatically calculates how far away from the price the arrows should sit based on the timeframe you are currently viewing (e.g., the spacing will be different on a 1-minute chart compared to a 4-hour chart).

4. On-Screen Information To provide extra clarity, the script also displays the name of the day you have selected directly on the chart interface. This serves as a constant reminder of which specific day's data is being highlighted.

Summary of Benefits

By automating this process, the tool eliminates the need for manual calculation. It provides a clean, visual map of your trading history, allowing you to quickly analyze how the market behaves on your chosen day across different weeks and months.

Price Data Components
Series array that contains the highest prices of each bar
13 Views
0 Downloads
0 Favorites
i-DayOfWeek(1)
//+------------------------------------------------------------------+
//|                                                  i-DayOfWeek.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//| 13.10.2005  Ïîêàçûâàåò âûáðàííûé äåíü íåäåëè                     |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LightBlue
#property indicator_color2 Salmon

//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int NumberDayOfWeek = 1;   // Íîìåð äíÿ íåäåëè
extern int NumberOfBars    = 0;   // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)

//------- Ãëîáàëüíûå ïåðåìåííûå --------------------------------------
int ArrowInterval, prevDay;

//------- Ïîêëþ÷åíèå âíåøíèõ ìîäóëåé ---------------------------------

//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double UpLine[];
double DnLine[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void init() {
  SetIndexBuffer(0, UpLine);
  SetIndexStyle (0, DRAW_ARROW);
  SetIndexArrow (0, 159);
  SetIndexEmptyValue(0, EMPTY_VALUE);

  SetIndexBuffer(1, DnLine);
  SetIndexStyle (1, DRAW_ARROW);
  SetIndexArrow (1, 159);
  SetIndexEmptyValue(1, EMPTY_VALUE);

  ArrowInterval = GetArrowInterval();
  Comment(NameDayOfWeek(NumberDayOfWeek));
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void deinit() {
  Comment("");
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
void start() {
  double dMax, dMin;
  int    loopbegin, nsb, shift;

 	if (NumberOfBars==0) loopbegin = Bars - 1;
  else loopbegin = NumberOfBars - 1;

  for (shift=0; shift<=loopbegin; shift++) {
    if (prevDay!=TimeDay(Time[shift])) {
      nsb=iBarShift(NULL, PERIOD_D1, Time[shift]);
      dMax=iHigh(NULL, PERIOD_D1, nsb)+ArrowInterval*Point;
      dMin=iLow (NULL, PERIOD_D1, nsb)-ArrowInterval*Point;
    }
    if (TimeDayOfWeek(Time[shift])==NumberDayOfWeek) {
      UpLine[shift] = dMax;
      DnLine[shift] = dMin;
    }
    prevDay=TimeDay(Time[shift]);
  }
}

//+------------------------------------------------------------------+
//| Âîçâðàùàåò èíòåðâàë óñòàíîâêè ñèãíàëüíûõ óêàçàòåëåé              |
//+------------------------------------------------------------------+
int GetArrowInterval() {
  int p = Period();

  switch (p) {
    case 1:     return(5);
    case 5:     return(7);
    case 15:    return(10);
    case 30:    return(15);
    case 60:    return(20);
    case 240:   return(30);
    case 1440:  return(40);
    case 10080: return(150);
    case 43200: return(250);
  }
}

//+------------------------------------------------------------------+
//| Âîçâðàùàåò íàèìåíîâàíèå äíÿ íåäåëè                               |
//+------------------------------------------------------------------+
string NameDayOfWeek(int ndw) {
  if (ndw==0) return("Âîñêðåñåíüå");
  if (ndw==1) return("Ïîíåäåëüíèê");
  if (ndw==2) return("Âòîðíèê");
  if (ndw==3) return("Ñðåäà");
  if (ndw==4) return("×åòâåðã");
  if (ndw==5) return("Ïÿòíèöà");
  if (ndw==6) return("Ñóááîòà");
}
//+------------------------------------------------------------------+

Comments