i_ParamonWorkTime
Download scriptThis script is designed as a visual trading tool for MetaTrader 4 that helps traders identify and navigate the primary active periods of the global financial markets. By highlighting specific time blocks on your price chart, it allows you to see exactly when major sessions—such as the London and New York openings and overlaps—occur over a historical timeframe.
Core Functionality
The tool automatically draws shaded rectangular zones over your trading chart. These zones act as a visual "map" of the trading day, dividing it into three distinct periods. Instead of forcing you to manually calculate times or look at a clock constantly, the script paints these sessions directly onto the price action, making it easier to recognize patterns that occur during high-volume hours versus quieter periods.
Key Features and Logic
- Customizable Session Windows: You can define three specific time blocks (Session 1, Session 2, and Session 3). Each session can be assigned its own unique start and end time, allowing you to tailor the tool to your specific trading style or preferred market regions.
- Visual Differentiation: Every session can be assigned a different color. This allows for an immediate visual distinction between, for example, the London morning, the heavy overlap period between London and New York, and the late-night New York session.
- Historical Overview: The script is capable of projecting these time zones back over a large number of past days (defaulting to 100). This provides a historical context, helping you see how price movements behaved during these specific windows in previous weeks or months.
- Dynamic Price Scaling: The script includes logic to determine the height of these shaded boxes. It can be configured to either dynamically adjust to the highest and lowest price points reached during that specific time block or set to a fixed relative scale, ensuring the zones are clearly visible without cluttering the chart.
- Smart Calendar Handling: The internal logic includes a "trade day" awareness system. It is designed to skip over weekends and correctly calculate dates to ensure that the highlighted boxes appear on valid trading days, providing a clean and professional look on your workspace.
How it helps you trade
By using this tool, you can quickly identify "high-probability" zones where volatility typically increases. It eliminates the guesswork of guessing which market is currently leading the price movement, allowing you to focus your attention on the sessions that matter most to your strategy.
//+------------------------------------------------------------------+
//| i-ParamonWorkTime.mq4 |
//| Êèì Èãîðü Â. aka KimIV |
//| http://www.kimiv.ru |
//| |
//| 23.11.2005 Èíäèêàòîð ðàáî÷åãî âðåìåíè Ïàðàìîíà. |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link "http://www.kimiv.ru"
#property indicator_chart_window
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int NumberOfDays = 100; // Êîëè÷åñòâî äíåé
extern string Begin_1 = "10:00"; // London open
extern string End_1 = "15:00"; // New York open
extern color Color_1 = Indigo;
extern string Begin_2 = "15:00"; // New York open and London session overlap starts
extern string End_2 = "19:00"; // London close
extern color Color_2 = Navy;
extern string Begin_3 = "19:00"; // London close
extern string End_3 = "23:00"; // New York close
extern color Color_3 = DarkSlateGray;
extern bool HighRange = False;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void init() {
DeleteObjects();
for (int i=0; i<NumberOfDays; i++) {
CreateObjects("PWT1"+i, Color_1);
CreateObjects("PWT2"+i, Color_2);
CreateObjects("PWT3"+i, Color_3);
}
Comment("");
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
void deinit() {
DeleteObjects();
Comment("");
}
//+------------------------------------------------------------------+
//| Ñîçäàíèå îáúåêòîâ èíäèêàòîðà |
//| Ïàðàìåòðû: |
//| no - íàèìåíîâàíèå îáúåêòà |
//| cl - öâåò îáúåêòà |
//+------------------------------------------------------------------+
void CreateObjects(string no, color cl) {
ObjectCreate(no, OBJ_RECTANGLE, 0, 0,0, 0,0);
ObjectSet(no, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(no, OBJPROP_COLOR, cl);
ObjectSet(no, OBJPROP_BACK, True);
}
//+------------------------------------------------------------------+
//| Óäàëåíèå îáúåêòîâ èíäèêàòîðà |
//+------------------------------------------------------------------+
void DeleteObjects() {
for (int i=0; i<NumberOfDays; i++) {
ObjectDelete("PWT1"+i);
ObjectDelete("PWT2"+i);
ObjectDelete("PWT3"+i);
}
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
void start() {
datetime dt=CurTime();
for (int i=0; i<NumberOfDays; i++) {
DrawObjects(dt, "PWT1"+i, Begin_1, End_1);
DrawObjects(dt, "PWT2"+i, Begin_2, End_2);
DrawObjects(dt, "PWT3"+i, Begin_3, End_3);
dt=decDateTradeDay(dt);
while (TimeDayOfWeek(dt)>5) dt=decDateTradeDay(dt);
}
}
//+------------------------------------------------------------------+
//| Ïðîðèñîâêà îáúåêòîâ íà ãðàôèêå |
//| Ïàðàìåòðû: |
//| dt - äàòà òîðãîâîãî äíÿ |
//| no - íàèìåíîâàíèå îáúåêòà |
//| tb - âðåìÿ íà÷àëà ñåññèè |
//| te - âðåìÿ îêîí÷àíèÿ ñåññèè |
//+------------------------------------------------------------------+
void DrawObjects(datetime dt, string no, string tb, string te) {
datetime t1, t2;
double p1, p2;
int b1, b2;
t1=StrToTime(TimeToStr(dt, TIME_DATE)+" "+tb);
t2=StrToTime(TimeToStr(dt, TIME_DATE)+" "+te);
b1=iBarShift(NULL, 0, t1);
b2=iBarShift(NULL, 0, t2);
p1=High[Highest(NULL, 0, MODE_HIGH, b1-b2, b2)];
p2=Low [Lowest (NULL, 0, MODE_LOW , b1-b2, b2)];
if (!HighRange) {p1=0; p2=2*p2;}
ObjectSet(no, OBJPROP_TIME1 , t1);
ObjectSet(no, OBJPROP_PRICE1, p1);
ObjectSet(no, OBJPROP_TIME2 , t2);
ObjectSet(no, OBJPROP_PRICE2, p2);
}
//+------------------------------------------------------------------+
//| Óìåíüøåíèå äàòû íà îäèí òîðãîâûé äåíü |
//| Ïàðàìåòðû: |
//| dt - äàòà òîðãîâîãî äíÿ |
//+------------------------------------------------------------------+
datetime decDateTradeDay (datetime dt) {
int ty=TimeYear(dt);
int tm=TimeMonth(dt);
int td=TimeDay(dt);
int th=TimeHour(dt);
int ti=TimeMinute(dt);
td--;
if (td==0) {
tm--;
if (tm==0) {
ty--;
tm=12;
}
if (tm==1 || tm==3 || tm==5 || tm==7 || tm==8 || tm==10 || tm==12) td=31;
if (tm==2) if (MathMod(ty, 4)==0) td=29; else td=28;
if (tm==4 || tm==6 || tm==9 || tm==11) td=30;
}
return(StrToTime(ty+"."+tm+"."+td+" "+th+":"+ti));
}
//+------------------------------------------------------------------+
Comments