i-5DaysOfTheWeek

Download script
Author: � RickD 2006
i-5DaysOfTheWeek

This tool is designed to enhance the visual clarity of your trading charts by automatically labeling specific days of the week. Rather than cluttering your screen with unnecessary data, it focuses on organizing your timeline so you can easily identify where one day ends and another begins.

Core Functionality

The script scans your chart history to detect transitions between different calendar days. When it identifies a new day, it places a clear text label (such as "Mon", "Tue", etc.) directly above the price candles. This allows for a much more intuitive reading of market history, making it easier to track performance across specific trading sessions.

Key Features and Customization

The tool is highly flexible, offering several ways to tailor the visual experience to your personal preference:

  • Customizable Visibility: You have full control over which days are displayed. For example, if you only trade during certain weekdays, you can toggle the labels for those specific days on or off.
  • Visual Branding: Each day of the week can be assigned a unique color and text label, allowing you to distinguish between different trading days at a glance.
  • Display Settings: You can adjust the font size, style, and the exact vertical position (offset) of the labels to ensure they don't overlap with your price action or other indicators.
  • Timeframe Compatibility: The script is optimized for use on intraday timeframes (any timeframe smaller than a Daily chart), ensuring that the labels appear correctly as you scroll through historical data.

How it Works

The logic operates by constantly monitoring the "bars" on your chart. It looks back through the history—up to a limit you define—and identifies every point where the day of the week changes. Once a change is detected, the script checks your preferences and places the corresponding label. If you move to a different timeframe or remove the tool, it includes a cleanup routine to ensure old labels are wiped from your chart, keeping your workspace clean.

13 Views
0 Downloads
0 Favorites
i-5DaysOfTheWeek
//+------------------------------------------------------------------+
//|                                                      i-5days.mq4 |
//|                                          Copyright © 2007, RickD |
//|                                                   www.e2e-fx.net |
//+------------------------------------------------------------------+
#property copyright "© RickD 2006"
#property link      "www.e2e-fx.net"
//----
#define major   1
#define minor   0
//----
#property  indicator_chart_window
#property  indicator_buffers 0
//----
extern string __1__ = "";
extern int MaxDays = 20;
extern int FontSize = 16;
extern string FontName = "System";
extern int Offset = 16;
extern string __2__ = "";
extern string Text1 = "mon";
extern string Text2 = "tue";
extern string Text3 = "wed";
extern string Text4 = "thu";
extern string Text5 = "fri";
extern string __3__ = "";
extern color Color1 = DodgerBlue;
extern color Color2 = DeepPink;
extern color Color3 = ForestGreen;
extern color Color4 = Coral;
extern color Color5 = MediumPurple;
extern string __4__ = "";
extern bool ShowDay1 = true;
extern bool ShowDay2 = true;
extern bool ShowDay3 = true;
extern bool ShowDay4 = true;
extern bool ShowDay5 = true;
//----
string Text[5];
color Color[5];
bool ShowDay[5];
string prefix = "5days_";
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void init() 
  {
   Text[0] = Text1;
   Text[1] = Text2;
   Text[2] = Text3;
   Text[3] = Text4;
   Text[4] = Text5;
//----  
   Color[0] = Color1;
   Color[1] = Color2;
   Color[2] = Color3;
   Color[3] = Color4;
   Color[4] = Color5;
//----
   ShowDay[0] = ShowDay1;
   ShowDay[1] = ShowDay2;
   ShowDay[2] = ShowDay3;
   ShowDay[3] = ShowDay4;
   ShowDay[4] = ShowDay5;
//----
   clear();
   show();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void deinit() 
  {
   clear();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void start() 
  {
   show();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void show() 
  {
   int P = Period();
   if(P > PERIOD_D1) 
     return;
   string name = "";
   int cnt = MathMin(Bars, PERIOD_D1 / P*MaxDays);
   for(int i=0; i < cnt; i++) 
     {
       if(TimeDayOfWeek(Time[i]) != TimeDayOfWeek(Time[i+1]))
         {
           name = prefix + TimeToStr(Time[i]);
           int res = ObjectFind(name);
           if(res == -1) 
             {      
               int day = TimeDayOfWeek(Time[i]);
               if(!ShowDay[day-1]) 
                   continue;
               ObjectCreate(name, OBJ_TEXT, 0, Time[i], High[i] + 
                            Offset*Point);
               ObjectSetText(name, Text[day-1], FontSize, FontName, 
                             Color[day-1]); 
             }
         }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void clear() 
  {
   int P = Period();
   if(P > PERIOD_D1) 
       return;
   string name = "";
   int cnt = MathMin(Bars, PERIOD_D1/P*MaxDays);
   for(int i=0; i < cnt; i++) 
     {
       name = prefix + TimeToStr(Time[i]);
       int res = ObjectFind(name);
       if(res != -1) 
           ObjectDelete(name);
     }
  }
//+------------------------------------------------------------------+

Comments