i-dayofweek_205

Download script
Author: ��� ����� �. aka KimIV
i-dayofweek_205

This tool is designed for traders who need to visually identify specific days of the week on their trading charts. Rather than cluttering the screen with constant data, it acts as a selective marker that highlights only the day you choose (for example, every Friday or every Monday) across your historical price action.

Core Functionality

The script scans through your chart's history and looks for specific calendar dates. When it identifies a day that matches your chosen selection, it places visual markers—shaped like arrows—at the top and bottom of the price candles. This allows you to quickly glance at a long historical chart and see exactly where certain days of the week occurred without having to manually check the date on every single candle.

Key Features & Logic:

  • Customizable Day Selection: You can define which day of the week you want to highlight. The tool automatically translates your choice into a readable format on the screen so you know exactly which day is being displayed.
  • Dynamic Spacing: To ensure the markers are easy to see, the script automatically calculates the "buffer" or distance between the arrow and the candle. It adjusts this spacing based on the timeframe you are viewing (e.g., it places arrows further away on larger timeframes like daily charts and closer together on smaller timeframes like 1-minute charts) so that the visual data remains clear and uncluttered.
  • Historical Depth Control: You can choose how far back in time the script should look. You have the option to analyze your entire trading history or limit the markers to a specific number of past candles.
  • High/Low Placement: For every day that matches your criteria, the script calculates the highest and lowest prices reached during that period. It then places two markers: one slightly above the high and one slightly below the low, creating a clear "frame" around that day's price action.

Summary for the User

Essentially, this is a visual navigation aid. It transforms a dense sea of candles into an organized map, allowing you to pinpoint recurring weekly events or specific trading days instantly, helping you maintain better perspective on historical price movements.

Price Data Components
Series array that contains the highest prices of each bar
13 Views
0 Downloads
0 Favorites
i-dayofweek_205
//+------------------------------------------------------------------+
//|                                                  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 = 5;   // Íîìåð äíÿ íåäåëè
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(4);
    case 5:     return(5);
    case 15:    return(6);
    case 30:    return(8);
    case 60:    return(10);
    case 240:   return(20);
    case 1440:  return(40);
    case 10080: return(80);
    case 43200: return(150);
  }
}

//+------------------------------------------------------------------+
//| Âîçâðàùàåò íàèìåíîâàíèå äíÿ íåäåëè                               |
//+------------------------------------------------------------------+
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