i-days_of_the_week

Download script
Author: � RickD 2006
i-days_of_the_week

This tool is designed as a visual aid for MetaTrader users to improve the readability of their trading charts by automatically labeling specific days of the week. Instead of requiring manual entry, the script scans your price history and places text markers directly on the candles to help you identify which day is which at a glance.

How it Works

The script functions by scanning the price history on your current chart. It identifies the transition between different trading days and places a corresponding label (e.g., "mon", "tue", etc.) above the high point of each new day's candle.

Key features of the logic include:

  • Customizable Visibility: You have the flexibility to choose which specific days you want to see on your chart. By default, you can toggle individual days (Monday through Friday) on or off, allowing you to declutter the workspace and only highlight the information most relevant to your trading strategy.
  • Visual Customization: The script allows for high levels of personalization regarding the aesthetic of your workspace. You can modify the font type, adjust the size of the labels, and set a specific offset so that the text appears clearly above the price action without overlapping the candles.
  • Color Coordination: To make the chart easier to read quickly, each day of the week can be assigned a unique color. This creates a consistent visual language where you can instantly recognize a "Friday" or "Tuesday" based on the color coding provided.
  • Timeframe Awareness: The script is designed to work intelligently with your chart settings. It automatically calculates how many days to display based on your chosen "MaxDays" limit and ensures that labels are only drawn on appropriate timeframes (Daily and below), preventing clutter on higher-level charts like Weekly or Monthly views.
  • Automatic Cleanup: To ensure your platform remains fast and organized, the script includes a cleanup routine. When you remove the indicator or change settings, it automatically wipes the previous labels from your chart so that no "ghost" text remains behind.
9 Views
0 Downloads
0 Favorites
i-days_of_the_week
//+------------------------------------------------------------------+
//|                                                      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 = 60;
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 = false;
extern bool ShowDay2 = false;
extern bool ShowDay3 = false;
extern bool ShowDay4 = false;
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