friday_line

Download script
Author: Urain
friday_line

This tool is designed to automatically organize your trading charts by highlighting the transition between different weeks. It works by scanning your historical price data and placing visual markers on the exact moment a new week begins.

How the Logic Works

1. Automated Scanning The script looks back through your trading history—either across the entire available chart or for a specific number of bars that you choose to define. It examines the date and day of the week for every candle in that range.

2. Identifying Weekends The core logic functions by detecting "jumps" in the calendar. When the script notices a gap where the day of the week changes by more than one (for example, jumping from a Friday to a Monday), it identifies that specific point as the start of a new trading week.

3. Visual Placement Once a new week is identified, the tool draws a vertical line on your chart at that exact timestamp. This allows you to see clearly where one week ends and the next begins, making it easier to track weekly price action or perform multi-week analysis.

Key Features & Customization

  • Visual Styling: You have full control over how these markers appear. You can choose the specific color of the lines (such as Red) and the line style (solid, dashed, etc.) to ensure they suit your chart's aesthetic without cluttering your view.
  • Smart Management: To keep your chart clean, the tool is programmed to manage its own markings. It assigns a unique name to every line it creates based on its specific date and time. When you remove the tool, it is designed to delete only the lines it created, leaving any of your other manual drawings untouched.
  • Efficiency: The script is designed to run once upon initialization. This prevents the platform from constantly recalculating the lines every second, ensuring that your trading platform remains fast and responsive.
6 Views
0 Downloads
0 Favorites
friday_line
/*///+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
Indicator shows a vertical lines at last week bar .
Counted_Bars - number of bars in the calculation, 0 means all bars.
type_line - type line.
Color - color line.
Indicator runs once, to run again make reinitialization.
Indicator deletes only its own lines, the lines are names using the bar dates.
/*///+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
//+------------------------------------------------------------------+
//|                                                 Friday_Lines.mq4 |
//|                                                            Urain |
//+------------------------------------------------------------------+
#property copyright "Urain"
#property link      ""
 
#property indicator_chart_window
extern int   Counted_Bars=0;
extern int   type_line=0;
extern color Color=Red;
string Name[]; int j=0;
bool f=1;
//+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
 
int init()
{//+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
 if(Counted_Bars==0)Counted_Bars=Bars-1;
return(0);
}//+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
 
int deinit()
{//+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
 for(int i=0;i<j;i++)ObjectDelete(Name[i]); 
return(0);
}//+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
 
int start()
{//+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
 if(!f)return(0); f=0;
 for(int i=Counted_Bars;i>0;i--)
    if(TimeDayOfWeek(Time[i])-TimeDayOfWeek(Time[i-1])>1)
       VLine(i);
         
return(0);
}//+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
 
void VLine(int ls)
{//+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 string name= Times( ls);
 j++; ArrayResize(Name,j); Name[j-1]= name;
 if(ObjectFind( name)==-1)ObjectCreate(name, OBJ_VLINE,0,Time[ls],0);
 ObjectSet(name, OBJPROP_BACK,1);
 ObjectSet(name, OBJPROP_TIME1, Time[ls]);
 ObjectSet(name, OBJPROP_COLOR, Color);
 ObjectSet(name, OBJPROP_STYLE, type_line);
return(0);
}//+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
string Times(int Sdvig, bool time=false)
{//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       string YEAR   = TimeYear( Time[Sdvig]);
       string DAY    = TimeDay( Time[Sdvig]);
       string HOUR   = TimeHour( Time[Sdvig]);
       string MINUTE = TimeMinute( Time[Sdvig]);
       int month = TimeMonth( Time[Sdvig]);
       string MONTH;
       switch(month)
             {case 1: MONTH = "jan";break;
              case 2: MONTH = "feb";break;
              case 3: MONTH = "mar";break;
              case 4: MONTH = "apr";break;
              case 5: MONTH = "may";break;
              case 6: MONTH = "jun";break;
              case 7: MONTH = "jul";break;
              case 8: MONTH = "aug";break;
              case 9: MONTH = "sep";break;
              case 10: MONTH = "oct";break;
              case 11: MONTH = "nov";break;
              case 12: MONTH = "dec";break;              
              default: MONTH = "---";break;
             }
        if(TimeHour( Time[Sdvig])<10) HOUR= "0"+HOUR;     
        if(MINUTE=="0")MINUTE="00";
 if(time)return(HOUR+":"+MINUTE);                   
 else return(YEAR+"   "+MONTH+" "+DAY+"   "+HOUR+":"+MINUTE);
}//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Comments