ATM_ShowTime

Download script
Author: Copyright � 2006 Accrete LLC.
ATM_ShowTime

This script is designed as a visual aid for traders using the MetaTrader platform. Its primary purpose is to provide a real-time countdown, informing you exactly how much time remains before the current candle closes.

How it Works

The tool functions by calculating the difference between the current market time and the specific time at which the next candle is scheduled to begin. It automatically detects your current chart timeframe (such as 1-minute, 5-minute, or 1-hour charts) and performs the following logic:

  • Time Calculation: The script looks at the opening time of the current candle and adds the duration of your chosen timeframe to it. By subtracting the current system time from this result, it determines the precise remaining seconds.
  • Unit Conversion: It then breaks down that remaining time into hours and minutes so that the information is easy for a human to read at a glance.
  • Visual Display: Instead of showing up in a complex data table, the script creates three distinct text labels directly on your chart window.

What You See on Your Chart

When you apply this script to an empty chart, it generates a clean, readable display:

  1. The Countdown: A large, bold numerical value (highlighted in Aqua) shows the remaining time for the candle to complete.
  2. Descriptive Labels: It includes secondary text that clarifies what the numbers mean (e.g., "Candle Close in" and "Minutes"), ensuring you don't have to guess what the data represents.

Key Benefit

The logic is built to be completely dynamic. Because it constantly recalculates the difference between the "next candle time" and the "current time," the countdown updates live on your screen. This allows you to monitor price action more effectively by knowing exactly how much "room" is left in the current trading period before a new candle forms.

Price Data Components
Series array that contains open time of each bar
7 Views
0 Downloads
0 Favorites
ATM_ShowTime
//+------------------------------------------------------------------+
//| ShowTime.mq4  Place in emplty chart to show time to candle close |
//| You may also wish to make a template with all parameters set so  |
//| all colors are same as background. So as to only show clock.     |
//|         Copyright © 2006 Accrete LLC. www.accrete.com            |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2006 Accrete LLC."
#property link      "http://www.accrete.com"

#property indicator_separate_window

double s1[];

string  ln_txt[13],        
        buff_str = "";
        
int     
        nTime = 0,
        CurPeriod = 0,
        nDigits = 0,
        i = 0;

int init()
  {
IndicatorShortName("ATM_ShowTime");

    return(0);
  }
    
 int start()
 {  
	double g;
   int m,s,k;
   m=Time[0]+Period()*60-CurTime();
   g=m/60.0;
   s=m%60;
   m=(m-m%60)/60;

   g=NormalizeDouble(g,1);
   for (k=1;k<=Bars-1;k++) s1[k]=0.0000001;
   for (k=1;k<=2;k++) s1[k]=g;

  
    ObjectCreate("lab6", OBJ_LABEL, WindowFind("ATM_ShowTime"), 0, 0);
        ObjectSetText("lab6",DoubleToStr(m,-4),20, "Arial Bold", Aqua);
        ObjectSet("lab6", OBJPROP_CORNER, 0);
        ObjectSet("lab6", OBJPROP_XDISTANCE, 90);
        ObjectSet("lab6", OBJPROP_YDISTANCE, 20);

    ObjectCreate("lab8", OBJ_LABEL, WindowFind("ATM_ShowTime"), 0, 0);
        ObjectSetText("lab8","Candle CLose in ", 9, "Arial Bold", Black);
        ObjectSet("lab8", OBJPROP_CORNER, 0);
        ObjectSet("lab8", OBJPROP_XDISTANCE, 65);
        ObjectSet("lab8", OBJPROP_YDISTANCE, 0);     
        
    ObjectCreate("lab9", OBJ_LABEL, WindowFind("ATM_ShowTime"), 0, 0);
        ObjectSetText("lab9"," Minutes", 9, "Arial Bold", Black);
        ObjectSet("lab9", OBJPROP_CORNER, 0);
        ObjectSet("lab9", OBJPROP_XDISTANCE, 85);
        ObjectSet("lab9", OBJPROP_YDISTANCE, 50);
        
//End Data Window     

//---- End Of Program
  return(0);
  }
//+------------------------------------------------------------------+

Comments