Coloured_Days_on_Chart

Download script
Author: Copyright � 2008, Jason Robinson (jnrtrading).
Coloured_Days_on_Chart

This tool is designed to enhance the visual clarity of your trading charts by highlighting specific historical periods. Its primary purpose is to create a distinct visual background for recent trading days, making it easier to distinguish between different dates at a glance.

How the Logic Works

Data Collection The script begins by automatically gathering price data from the daily timeframe. It specifically looks back at a set number of days (which can be customized by the user) to identify where each day starts and ends, as well as the high and low price points for those periods.

Visual Mapping Once the data is collected, the tool draws rectangular boxes over the corresponding sections of your chart. These rectangles act as "background highlights" that cover the vertical range of the daily price movement (from the highest point to the lowest point of that specific day).

Dynamic Alternating Colors To ensure the chart remains readable and doesn't become a solid block of color, the script applies an alternating logic to the shading. It automatically toggles between two different colors for every consecutive day. This creates a striped effect (similar to a calendar), allowing you to easily track the passage of time and separate one trading session from the next without cluttering the workspace.

Automatic Maintenance The script is designed to be "clean." When it is removed from the chart or updated, it includes a routine to automatically delete the drawn boxes, ensuring that no leftover graphical objects remain on your screen.

9 Views
0 Downloads
0 Favorites
Coloured_Days_on_Chart
//+------------------------------------------------------------------+
//|                                  Coloured Days on Chart.mq4 v1.0 |
//|                   Copyright © 2008, Jason Robinson (jnrtrading). |
//|                                   http://www.spreadtrade2win.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Jason Robinson (jnrtrading)."
#property link      "http://www.spreadtrade2win.com"

#property indicator_chart_window
extern int No_of_days_to_colour = 20;
extern color Colour1 = LightGray;
extern color Colour2 = DarkGray;
double Days[][6];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
ArrayCopyRates(Days,Symbol(),PERIOD_D1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   for (int i = No_of_days_to_colour; i >= 0; i--) {
      ObjectDelete("Day"+i);
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//---
   
   for (int i = 0; i <= No_of_days_to_colour; i++) {
      ObjectCreate("Day"+i,OBJ_RECTANGLE,0,Days[i][0]+86400,Days[i][3],Days[i][0],Days[i][2]);
      if (i % 2 == 0)
         ObjectSet("Day"+i,OBJPROP_COLOR,Colour1);
      else
         ObjectSet("Day"+i,OBJPROP_COLOR,Colour2);
   }

   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments