Author: � RickD 2006
5days_v1

This tool is designed to enhance the visual clarity of your trading charts by automatically labeling the specific days of the week. Rather than forcing you to manually identify dates or navigate complex timeframes, it acts as an automated organizational overlay that simplifies your historical data analysis.

Core Functionality

The script scans your chart and identifies the transition points between different days. When it detects a new day beginning, it places a clean, readable text label (such as "mon", "tue", etc.) directly above the price action at the start of that period. This allows you to quickly orient yourself when scrolling back through historical price movements.

Key Features and Customization

The logic is built to be highly flexible, allowing you to tailor the visual experience to your specific preference:

  • Timeframe Compatibility: The script is optimized to work on intraday timeframes (like 1-hour or 15-minute charts). It intelligently recognizes when to display labels based on daily transitions.
  • Visual Branding: You have full control over the aesthetic presentation. You can customize the font type, size, and position offset to ensure the labels do not interfere with your price candles or other indicators.
  • Color Coding: To make navigation even faster, the script supports unique colors for different days of the week. This creates a distinct visual "rhythm" on your chart, helping you instantly recognize different trading sessions at a glance.
  • Selective Visibility: Not all days need to be highlighted. The logic includes a toggle system that allows you to show or hide specific days of the week, letting you focus only on the trading periods that matter most to your strategy.
  • Automated Maintenance: The script handles its own cleanup. It dynamically manages the labels on your screen, ensuring that as new data populates the chart, the environment remains organized and free of redundant information.

User Benefit

By automating the labeling of timeframes, this tool reduces cognitive load. Instead of manually counting candles to figure out what day a specific price move occurred, you can instantly see the chronological flow of the market, allowing for more efficient backtesting and trend analysis.

11 Views
0 Downloads
0 Favorites
5days_v1

#property copyright "© RickD 2006"
#property link      "www.e2e-fx.net"


#property  indicator_chart_window
#property  indicator_buffers 0

extern string __1__ = "";

extern int MaxDays = 20;
extern int FontSize = 10;
extern string FontName = "Verdana";
extern int Offset = 15;

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 = DeepPink;
extern color Color2 = Aquamarine;
extern color Color3 = Yellow;
extern color Color4 = DodgerBlue;
extern color Color5 = Coral;

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 prefix = "5days_";
  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