This script is designed to function as a comprehensive real-time dashboard for traders, providing an at-a-glance overview of multi-timeframe data and global market sessions directly on the trading chart. Instead of forcing you to switch between different windows to see how various time periods are performing, it aggregates that information into a single, organized display.
The logic of the script can be broken down into three main components:
Multi-Timeframe (MTF) Monitoring
The core functionality tracks eight different timeframes simultaneously (ranging from 5-minute intervals up to monthly charts). For each timeframe, the tool calculates and displays:
- Price Movement: It determines if the current price is moving up or down compared to the opening price of that specific period. To make this visually intuitive, it changes the text color dynamically: Green for upward movement, Red for downward movement, and Gray for neutral/flat movement.
- Time Remaining: It calculates exactly how much time is left before the current candle or period closes (e.g., "how many minutes remain until the next hourly candle?").
- Live Labels: It automatically labels each line of data so you can clearly identify which timeframe corresponds to which piece of information.
Global Market Session Tracker
The script includes a specialized section that monitors major global financial hubs. It displays the operating hours for four key regions: London, New York (NYC), Sydney, and Tokyo.
- Active Status: The logic checks the current time against the standard operating hours of these markets. If a market is currently open, the text will appear in White; if it is closed, the text turns Gray.
- Weekend Awareness: The script is programmed to recognize weekends, ensuring the session status correctly reflects when global markets are inactive.
Dynamic Clock and Time Conversion
To ensure the data is accurate regardless of your local settings, the script includes:
- GMT Synchronization: It allows for a manual offset (GMT Plus) so that the time displayed matches the specific timezone requirements of the user.
- Formatted Timekeeping: It displays a real-time clock and converts market opening/closing times into readable "time remaining" formats, helping traders stay synchronized with global price action.
Summary of User Experience
For a visitor or trader, this means you don't have to manually monitor multiple tabs. You can look at one corner of your screen to see the "pulse" of the market—instantly knowing which timeframes are trending, how much time is left in the current candle, and which international markets are currently active and trading.
//+---------------------------------------------------------------+
//| MTF info |
//| http://www.currencylabs.com |
//| (C) _mikkom |
//+---------------------------------------------------------------+
#property copyright "Mikko"
#property link "noneOfYOurBusiness"
#property indicator_chart_window
#property indicator_buffers 0
string name;
extern int gmtPlus = -1;
int init() {
IndicatorBuffers(0);
name = "Mikko mtf info";
IndicatorShortName(name);
return(0);
}
int deinit() {
clear();
return(0);
}
int start() {
int period[9];
int untilClose[9];
int lastMove[10];
int lastValue[10]; // int to disable display of decimals
period[0] = PERIOD_M1; // NOTE: Not used
period[1] = PERIOD_M5;
period[2] = PERIOD_M15;
period[3] = PERIOD_M30;
period[4] = PERIOD_H1;
period[5] = PERIOD_H4;
period[6] = PERIOD_D1;
period[7] = PERIOD_W1;
period[8] = PERIOD_MN1;
for(int j=1; j<=8; j++) {
int per = period[j];
/** Doesn't work correctly! **/
lastValue[j] = (iClose(Symbol(),per,0)-iOpen(Symbol(),per,0))/Point;
untilClose[j] = period[j]*60-(TimeCurrent()-iTime(Symbol(),per,0));
}
clear();
for(int i=1; i<=8; i++) {
int move = lastValue[i];
string id;
int win = 0;
double hh = (WindowPriceMax(win)-WindowPriceMin(win))/10;
id = name+"_time_"+i;
ObjectCreate(id, OBJ_LABEL, win, 0, 0);
ObjectSetText(id, timeRemaining(untilClose[i]), 8);
ObjectSet(id, OBJPROP_CORNER, 1);
ObjectSet(id, OBJPROP_XDISTANCE, 85);
ObjectSet(id, OBJPROP_YDISTANCE, 10 + (8-i) * 15);
id = name+"_value_"+i;
ObjectCreate(id, OBJ_LABEL, win, 0, 0);
ObjectSetText(id, ""+lastValue[i], 8);
ObjectSet(id, OBJPROP_CORNER, 1);
ObjectSet(id, OBJPROP_XDISTANCE, 10);
ObjectSet(id, OBJPROP_YDISTANCE, 10 + (8-i) * 15);
id = name+"_title_"+i;
ObjectCreate(id, OBJ_LABEL, win, 0, 0);
ObjectSetText(id, period_text(period[i]), 8);
ObjectSet(id, OBJPROP_CORNER, 1);
ObjectSet(id, OBJPROP_XDISTANCE, 45);
ObjectSet(id, OBJPROP_YDISTANCE, 10 + (8-i) * 15);
if(move > 0) {
ObjectSet(name+"_time_"+i, OBJPROP_COLOR, Green);
ObjectSet(name+"_value_"+i, OBJPROP_COLOR, Green);
ObjectSet(name+"_title_"+i, OBJPROP_COLOR, Green);
//SetIndexStyle(i-1,DRAW_LINE,EMPTY,1,Green);
} else if(move < 0) {
ObjectSet(name+"_time_"+i, OBJPROP_COLOR, Red);
ObjectSet(name+"_value_"+i, OBJPROP_COLOR, Red);
ObjectSet(name+"_title_"+i, OBJPROP_COLOR, Red);
//SetIndexStyle(i-1,DRAW_LINE,EMPTY,1, Red);
} else {
ObjectSet(name+"_time_"+i, OBJPROP_COLOR, Gray);
ObjectSet(name+"_value_"+i, OBJPROP_COLOR, Gray);
ObjectSet(name+"_title_"+i, OBJPROP_COLOR, Gray);
}
}
datetime gmt = TimeCurrent() + gmtPlus * 60 * 60;
id = "time";
ObjectCreate(id, OBJ_LABEL, win, 0, 0);
ObjectSetText(id, digits2(TimeHour(gmt))+":"+digits2(TimeMinute(gmt))+":"+digits2(TimeSeconds(gmt)), 8);
ObjectSet(id, OBJPROP_CORNER, 1);
ObjectSet(id, OBJPROP_XDISTANCE, 10);
ObjectSet(id, OBJPROP_YDISTANCE, 10 + 9 * 15);
ObjectSet(id, OBJPROP_COLOR, White);
// Session times from: http://www.babypips.com/school/market_hours.html
id = "session_london";
ObjectCreate(id, OBJ_LABEL, win, 0, 0);
ObjectSetText(id, openTime(gmt,8,16)+" London 8:00 - 17:00", 8);
ObjectSet(id, OBJPROP_CORNER, 1);
ObjectSet(id, OBJPROP_XDISTANCE, 10);
ObjectSet(id, OBJPROP_YDISTANCE, 10 + 11 * 15);
if(!weekend(gmt) && TimeHour(gmt) >= 8 && TimeHour(gmt) < 17) {
ObjectSet(id, OBJPROP_COLOR, White);
} else {
ObjectSet(id, OBJPROP_COLOR, Gray);
}
id = "session_us";
ObjectCreate(id, OBJ_LABEL, win, 0, 0);
ObjectSetText(id, openTime(gmt,13,22)+" Nyc 13:00 - 22:00", 8);
ObjectSet(id, OBJPROP_CORNER, 1);
ObjectSet(id, OBJPROP_XDISTANCE, 10);
ObjectSet(id, OBJPROP_YDISTANCE, 10 + 12 * 15);
if(!weekend(gmt) && TimeHour(gmt) >= 13 && TimeHour(gmt) < 22) {
ObjectSet(id, OBJPROP_COLOR, White);
} else {
ObjectSet(id, OBJPROP_COLOR, Gray);
}
id = "session_sydney";
ObjectCreate(id, OBJ_LABEL, win, 0, 0);
ObjectSetText(id, openTime(gmt,22,8)+" Sydney 22:00 - 8:00", 8);
ObjectSet(id, OBJPROP_CORNER, 1);
ObjectSet(id, OBJPROP_XDISTANCE, 10);
ObjectSet(id, OBJPROP_YDISTANCE, 10 + 13 * 15);
if(!weekend(gmt) && (TimeHour(gmt) >= 22 || TimeHour(gmt) < 8)) {
ObjectSet(id, OBJPROP_COLOR, White);
} else {
ObjectSet(id, OBJPROP_COLOR, Gray);
}
id = "session_tokyo";
ObjectCreate(id, OBJ_LABEL, win, 0, 0);
ObjectSetText(id, openTime(gmt,0,9)+" Tokyo 0:00 - 9:00", 8);
ObjectSet(id, OBJPROP_CORNER, 1);
ObjectSet(id, OBJPROP_XDISTANCE, 10);
ObjectSet(id, OBJPROP_YDISTANCE, 10 + 14 * 15);
if(!weekend(gmt) && TimeHour(gmt) >= 0 && TimeHour(gmt) < 9) {
ObjectSet(id, OBJPROP_COLOR, White);
} else {
ObjectSet(id, OBJPROP_COLOR, Gray);
}
return(0);
}
void clear() {
for(int i = 0; i <= 8; i++) {
ObjectDelete(name+"_time_"+i);
ObjectDelete(name+"_value_"+i);
ObjectDelete(name+"_title_"+i);
}
ObjectDelete("session_tokyo");
ObjectDelete("session_london");
ObjectDelete("session_us");
ObjectDelete("time");
}
string period_text(int p) {
switch(p) {
case PERIOD_M1: return("M1"); break;
case PERIOD_M5: return("M5"); break;
case PERIOD_M15: return("M15"); break;
case PERIOD_M30: return("M30"); break;
case PERIOD_H1: return("H1"); break;
case PERIOD_H4: return("H4"); break;
case PERIOD_D1: return("D1"); break;
case PERIOD_W1: return("W1"); break;
case PERIOD_MN1: return("MN1"); break;
}
}
string digits2(int num) {
if(num < 10)
return("0"+num);
else
return(num);
}
string openTime(datetime gmt, int openHour, int closeHour) {
if(!weekend(gmt) && openHour > closeHour && (TimeHour(gmt) <= closeHour || TimeHour(gmt) > openHour)) {
return ((closeHour-TimeHour(gmt)-1)+":"+digits2(60-TimeMinute(gmt)));
} else
if(!weekend(gmt) && TimeHour(gmt) >= openHour && TimeHour(gmt) < closeHour) {
return ((closeHour-TimeHour(gmt)-1)+":"+digits2(60-TimeMinute(gmt)));
}
return("closed");
}
bool weekend(datetime gmt) {
return(TimeDayOfWeek(gmt) == 0 || TimeDayOfWeek(gmt) == 6);
}
string timeRemaining(datetime t) {
if(t/60/60 > 1) {
return (DoubleToStr(t/60/60,0)+":"+DoubleToStr(t/60%60,0)+":"+DoubleToStr(t%60,0));
} else {
return (DoubleToStr(t/60,0)+":"+DoubleToStr(t%60,0));
}
}
Comments