SK-Days of Week

Download script
Author: Soheil
SK-Days of Week

This script is a visual tool designed for MetaTrader platforms to help traders easily identify the start of each trading day on their charts. It automates the process of labeling specific points in time, making it much easier to navigate historical price data.

Core Functionality

The primary purpose of this tool is to scan your price history and automatically place text labels (such as "Mon", "Tue", etc.) at the exact moment a new day begins. Instead of you having to manually identify where one day ends and another starts, the script handles this by checking the date and time of every candle on your chart.

Key Features

  • Automated Day Labeling: The script identifies the transition into each day of the week. When it detects the start of a new day (at 00:00 hours), it places a corresponding text label on the chart.
  • Customizable Visuals: You can personalize how these labels appear. The script allows you to define the font style, the size of the text, and specific colors for different days of the week. For example, you can set Monday to be Orange, Tuesday to be Red, and so on.
  • Smart Positioning: To ensure that the text labels do not overlap with the price candles, the script uses a dynamic positioning logic. It calculates the distance of the label from the high point of the candle based on market volatility (ATR). This ensures that the labels stay readable even during periods of high and low price movement.
  • Historical Depth: The tool can be configured to scan back through thousands of bars, providing a clear chronological map of past trading sessions.

How it Works for the User

Once applied to a chart, the script "walks" backward through your history. Every time it hits midnight on a new day, it creates a text object. Because it uses a calculation based on market volatility to place the text, the labels will hover neatly above the candles without cluttering the actual price action. When you remove the indicator from your chart, the script is designed to automatically clean up and delete these labels so your chart remains tidy.

Indicators Used
Indicator of the average true range
6 Views
0 Downloads
0 Favorites
SK-Days of Week
//+------------------------------------------------------------------+
//|                                                                  |
//|                                            ///SK-Days of Week/// |
//|                                        ///Developed by Soheil/// |
//|                                        ///Soheil.4x@Gmail.com/// |
//+------------------------------------------------------------------+
#property copyright "Soheil"
#property indicator_chart_window

//---- input parameters
extern int    BarCount=5000;
extern double TextDistance=14;
extern string Font="Britannic Bold";
extern int    FontSize=11;
extern color  TextColor_Mon=Orange;
extern color  TextColor_Tue=Red;
extern color  TextColor_Wed=DeepSkyBlue;
extern color  TextColor_Thr=LimeGreen;
extern color  TextColor_Fri=Violet;
extern color  TextColor_Sun=CLR_NONE;
extern color  TextColor_Sat=CLR_NONE;
//----Variables
int i,nCountedBars;
string dayW;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {  
   TextDistance=TextDistance/100;
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
    for (int i=0;i<Bars;i++){
    ObjectDelete("Mon"+iTime(Symbol(),0,i));
    ObjectDelete("Tue"+iTime(Symbol(),0,i));
    ObjectDelete("Wed"+iTime(Symbol(),0,i));
    ObjectDelete("Thr"+iTime(Symbol(),0,i));
    ObjectDelete("Fri"+iTime(Symbol(),0,i));
    ObjectDelete("Sat"+iTime(Symbol(),0,i));
    ObjectDelete("Sun"+iTime(Symbol(),0,i));
    }
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  { 
    nCountedBars=IndicatorCounted();
    if(nCountedBars<0 || BarCount<0) return(-1);

    i=BarCount-nCountedBars+2;
    while(i>=0)
     {
   
         if ( TimeDayOfWeek(Time[i])==1 && TimeHour(Time[i])==0 && TimeMinute(Time[i])==0) {
         dayW="Mon"+iTime(Symbol(),0,i);
         ObjectCreate(dayW,OBJ_TEXT,0,Time[i],High[i]+Fasele_ATR(TextDistance,i));
         ObjectSetText(dayW,"Mon",FontSize,Font,TextColor_Mon);
         ObjectSet(dayW, OBJPROP_PRICE1, High[i]+Fasele_ATR(TextDistance,i));
         }
         
         if ( TimeDayOfWeek(Time[i])==2 && TimeHour(Time[i])==0 && TimeMinute(Time[i])==0) {
         dayW="Tue"+iTime(Symbol(),0,i);
         ObjectCreate(dayW,OBJ_TEXT,0,Time[i],High[i]+Fasele_ATR(TextDistance,i));
         ObjectSetText(dayW,"Tue",FontSize,Font,TextColor_Tue);
         ObjectSet(dayW, OBJPROP_PRICE1, High[i]+Fasele_ATR(TextDistance,i));
         }
         
         if ( TimeDayOfWeek(Time[i])==3 && TimeHour(Time[i])==0 && TimeMinute(Time[i])==0) {
         dayW="Wed"+iTime(Symbol(),0,i);
         ObjectCreate(dayW,OBJ_TEXT,0,Time[i],High[i]+Fasele_ATR(TextDistance,i));
         ObjectSetText(dayW,"Wed",FontSize,Font,TextColor_Wed);
         ObjectSet(dayW, OBJPROP_PRICE1, High[i]+Fasele_ATR(TextDistance,i));
         }
         
         if ( TimeDayOfWeek(Time[i])==4 && TimeHour(Time[i])==0 && TimeMinute(Time[i])==0) {
         dayW="Thr"+iTime(Symbol(),0,i);
         ObjectCreate(dayW,OBJ_TEXT,0,Time[i],High[i]+Fasele_ATR(TextDistance,i));
         ObjectSetText(dayW,"Thr",FontSize,Font,TextColor_Thr);
         ObjectSet(dayW, OBJPROP_PRICE1, High[i]+Fasele_ATR(TextDistance,i));
         }
         
         if ( TimeDayOfWeek(Time[i])==5 && TimeHour(Time[i])==0 && TimeMinute(Time[i])==0) {
         dayW="Fri"+iTime(Symbol(),0,i);
         ObjectCreate(dayW,OBJ_TEXT,0,Time[i],High[i]+Fasele_ATR(TextDistance,i));
         ObjectSetText(dayW,"Fri",FontSize,Font,TextColor_Fri);
         ObjectSet(dayW, OBJPROP_PRICE1, High[i]+Fasele_ATR(TextDistance,i));
         }
         
         if ( TimeDayOfWeek(Time[i])==6 && TimeHour(Time[i])==0 && TimeMinute(Time[i])==0) {
         dayW="Sat"+iTime(Symbol(),0,i);
         ObjectCreate(dayW,OBJ_TEXT,0,Time[i],High[i]+Fasele_ATR(TextDistance,i));
         ObjectSetText(dayW,"Sat",FontSize,Font,TextColor_Sat);
         ObjectSet(dayW, OBJPROP_PRICE1, High[i]+Fasele_ATR(TextDistance,i));
         }
         
         if ( TimeDayOfWeek(Time[i])==0 && TimeHour(Time[i])==0 && TimeMinute(Time[i])==0) {
         dayW="Sun"+iTime(Symbol(),0,i);
         ObjectCreate(dayW,OBJ_TEXT,0,Time[i],High[i]+Fasele_ATR(TextDistance,i));
         ObjectSetText(dayW,"Sun",FontSize,Font,TextColor_Sun);
         ObjectSet(dayW, OBJPROP_PRICE1, High[i]+Fasele_ATR(TextDistance,i));
         }  
                               
      i--;
           
     }
     
   return(0);
  }
//+------------------------------------------------------------------+
//| Fasele ATR                                                       |
//+------------------------------------------------------------------+
double Fasele_ATR(double TextDistance,int t)
   {   
   double Fasele_ATR=TextDistance*iATR(NULL,PERIOD_D1,5,t);  
   return(Fasele_ATR);
   } 
//+------------------------------------------------------------------+
//| End of Program                                                   |
//+------------------------------------------------------------------+




Comments