TimeCurrentXR

Author: #Copyright � 2009, XrustSolution.#
TimeCurrentXR

This tool is designed as an on-screen visual dashboard for the MetaTrader platform. Its primary purpose is to provide traders with a real-time "countdown" or progress tracker across multiple timeframes simultaneously. Instead of forcing you to manually calculate how much time is left in a specific candle, this script automates that process and displays it clearly on your chart.

Core Functionality

The logic works by constantly monitoring the current server time and breaking it down into specific increments. It calculates the remaining progress for several popular trading timeframes, including:

  • M1 (1 Minute)
  • M5 (5 Minutes)
  • M15 (15 Minutes)
  • M30 (30 Minutes)
  • H1 (1 Hour)
  • H4 (4 Hours)
  • D1 (Daily)

How the Visuals Work

To give you an immediate sense of "time remaining" at a glance, the script uses a visual progress bar style. It utilizes a series of vertical bars to represent the passage of time:

  • || represents a smaller increment of time.
  • |||||||| represents a larger completion of a timeframe.

As time passes toward the close of a candle, these bars update dynamically. For example, if a timeframe is nearly finished, the bar will be full; if it has just started, the bar will be nearly empty.

Technical Logic Flow

  1. Time Monitoring: The script constantly checks the current seconds, minutes, and hours of the market's operating clock.
  2. Mathematical Calculation: It performs specific division and subtraction based on each timeframe’s requirements. For instance, it calculates the remainder of the current hour to determine where you are in the 60-minute cycle, or the remainder of the day for the 4-hour and daily cycles.
  3. Dynamic Rendering: Once the script determines the progress percentage, it draws a text label on your chart. It updates these labels instantly so that the "progress bars" move in sync with the live market clock.
  4. Automatic Cleanup: The script is designed to handle its own visual objects, ensuring that labels are created and updated correctly without cluttering the chart or leaving behind orphaned data.

User Experience

For the trader, this means you no longer have to do mental math to see how much time is left before a candle closes or an H4 period ends. By looking at the dashboard, you can see a live "loading bar" for every major timeframe, helping you better time your entries, exits, and news reactions.

10 Views
0 Downloads
0 Favorites
TimeCurrentXR
//+------------------------------------------------------------------+
//|                                                TimeCurrentXR.mq4 |
//|                                 Copyright © 2009, XrustSolution. |
//|                                        http://www.xrust.ucoz.net |
//+------------------------------------------------------------------+
#property copyright "#Copyright © 2009, XrustSolution.#"
#property link      "#http://www.xrust.ucoz.net#"
#property indicator_chart_window
extern color Col= Blue;      
string tm15="||      ";
string tm30="||||    ";
string tm45="||||||  ";
string tm60="||||||||";
//+------------------------------------------------------------------+
int deinit(){ObjectsDeleteAll(0,OBJ_LABEL);return;}
//+------------------------------------------------------------------+
int start()
  {string time;int min,y,x;
  SetLabel("TM",TimeToStr(TimeCurrent(),TIME_SECONDS)+"  ",Col,5,5,1,15);
  if(TimeSeconds(TimeCurrent())<15){time=tm15;}
  if(TimeSeconds(TimeCurrent())>=15&&TimeSeconds(TimeCurrent())<30){time=tm30;}
  if(TimeSeconds(TimeCurrent())>=30&&TimeSeconds(TimeCurrent())<45){time=tm45;}
  if(TimeSeconds(TimeCurrent())>=45){time=tm60;}
  SetLabel("M1", time+"M1  ",Col,5,25,1,15);
  if(TimeMinute(TimeCurrent())%5<2){time=tm15;}
  if(TimeMinute(TimeCurrent())%5>=2&&TimeMinute(TimeCurrent())%5<3){time=tm30;}
  if(TimeMinute(TimeCurrent())%5>=3&&TimeMinute(TimeCurrent())%5<4){time=tm45;}
  if(TimeMinute(TimeCurrent())%5>=4){time=tm60;}
  SetLabel("M5", time+"M5  ",Col,5,45,1,15);
  if(TimeMinute(TimeCurrent())<15){y=0;}
  if(TimeMinute(TimeCurrent())>=15&&TimeMinute(TimeCurrent())<30){y=1;}
  if(TimeMinute(TimeCurrent())>=30&&TimeMinute(TimeCurrent())<45){y=2;}
  if(TimeMinute(TimeCurrent())>=45){y=3;} 
  x=TimeMinute(TimeCurrent())-(y*15);
  if(x<4){time=tm15;}
  if(x>=4&&x<8){time=tm30;}
  if(x>=8&&x<12){time=tm45;}
  if(x>=12){time=tm60;}
  SetLabel("M15",time+"M15",Col,5,65,1,15);
  if(TimeMinute(TimeCurrent())<30){y=0;}else{y=1;}
  x=TimeMinute(TimeCurrent())-(y*30);
  if(x<8){time=tm15;}
  if(x>=8&&x<15){time=tm30;}
  if(x>=15&&x<22){time=tm45;}
  if(x>=22){time=tm60;}  
  SetLabel("M30",time+"M30",Col,5,85,1,15);
  if(TimeMinute(TimeCurrent())/15<1){time=tm15;}
  if(TimeMinute(TimeCurrent())/15>=1&&TimeMinute(TimeCurrent())/15<2){time=tm30;}
  if(TimeMinute(TimeCurrent())/15>=2&&TimeMinute(TimeCurrent())/15<3){time=tm45;}
  if(TimeMinute(TimeCurrent())/15>=3){time=tm60;}   
  SetLabel("H1", time+"H1  ",Col,5,105,1,15);
  if(TimeHour(TimeCurrent())<4){y=0;}
  if(TimeHour(TimeCurrent())>=4&&TimeHour(TimeCurrent())<8){y=1;}
  if(TimeHour(TimeCurrent())>=8&&TimeHour(TimeCurrent())<12){y=2;}
  if(TimeHour(TimeCurrent())>=12&&TimeHour(TimeCurrent())<16){y=3;}
  if(TimeHour(TimeCurrent())>=16&&TimeHour(TimeCurrent())<20){y=4;}
  if(TimeHour(TimeCurrent())>=20){y=5;}  
  x=TimeHour(TimeCurrent())-4*y;
  if(x<1){time=tm15;}
  if(x>=1&&x<2){time=tm30;}
  if(x>=2&&x<3){time=tm45;}
  if(x>=3){time=tm60;}  
  SetLabel("H4", time+"H4  ",Col,5,125,1,15);
  if(TimeHour(TimeCurrent())<6){time=tm15;}
  if(TimeHour(TimeCurrent())>=6&&TimeHour(TimeCurrent())<12){time=tm30;}
  if(TimeHour(TimeCurrent())>=12&&TimeHour(TimeCurrent())<18){time=tm45;}
  if(TimeHour(TimeCurrent())>=18){time=tm60;}  
  SetLabel("D1", time+"D1  ",Col,5,145,1,15);
  return(0);
  }
void SetLabel(string nm, string tx, color cl, int xd, int yd, int cr=0, int fs=9) {
  if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_LABEL, 0, 0,0);
  ObjectSetText(nm, tx, fs,"Arial");
  ObjectSet(nm, OBJPROP_COLOR    , cl);
  ObjectSet(nm, OBJPROP_XDISTANCE, xd);
  ObjectSet(nm, OBJPROP_YDISTANCE, yd);
  ObjectSet(nm, OBJPROP_CORNER   , cr);
  ObjectSet(nm, OBJPROP_FONTSIZE , fs);
  Sleep(100);
  WindowRedraw();
}

Comments