Candle-Closing-Time-Remaining-lCCTRp
Download scriptThis tool is designed for traders who need real-time awareness of market timing. Its primary purpose is to calculate and display exactly how much time remains before the current price candle closes on your trading chart.
How It Works
The script constantly monitors the timeframe you are currently viewing (such as 1-minute, 5-minute, 1-hour, or daily charts). It calculates the difference between the total duration of that specific candle and the time that has already passed. This result is then displayed directly on your screen so you can see the countdown in real-time.
Key Features
- Dynamic Time Tracking: Depending on the timeframe you select, the tool automatically adjusts its calculation to show the remaining seconds or minutes.
- Multi-Timeframe Awareness: For longer periods like daily or weekly charts, the tool is smart enough to break down the remaining time into days as well as hours/minutes, ensuring you have a clear picture of the long-term outlook.
- Weekend Status: The script includes logic to recognize weekends. If the market is closed (Saturday or Sunday), it will display a specific notice letting you know that the market is currently inactive.
- Flexible Display Options: You can choose how and where the information appears. It allows for "Comment" style displays (standard text on the chart) or specific "Label" locations. It also gives you the option to see the current server time alongside the countdown.
User Experience
Whether you are a scalper looking at 1-minute charts or a swing trader watching daily movements, this tool eliminates the guesswork of manual time calculation. It provides a steady, live countdown that helps you manage your entries and exits more effectively by knowing exactly when the current price action will conclude.
//+------------------------------------------------------------------+
//| Candle Closing Time Remaining-(CCTR).mq4 |
//| Copyright 2013,Foad Tahmasebi |
//| Version 2.0 |
//| http://www.daskhat.ir |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013,Foad Tahmasebi"
#property link "http://www.daskhat.ir"
#property indicator_chart_window
//--- input parameters
extern int location=1;
extern int displayServerTime=0;
extern int fontSize=9;
extern color colour=Silver;
//--- variables
double leftTime;
string sTime;
int days;
string sCurrentTime;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
if(location != 0){
ObjectCreate("CandleClosingTimeRemaining-CCTR",OBJ_LABEL,0,0,0);
ObjectSet("CandleClosingTimeRemaining-CCTR",OBJPROP_CORNER,location);
ObjectSet("CandleClosingTimeRemaining-CCTR",OBJPROP_XDISTANCE,5);
ObjectSet("CandleClosingTimeRemaining-CCTR",OBJPROP_YDISTANCE,3);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("CandleClosingTimeRemaining-CCTR");
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
sCurrentTime=TimeToStr(TimeCurrent(),TIME_SECONDS);
leftTime =(Period()*60)-(TimeCurrent()-Time[0]);
sTime= TimeToStr(leftTime,TIME_SECONDS);
if(DayOfWeek()==0 || DayOfWeek()==6){
if(location == 0){
Comment("Candle Closing Time Remaining: " + "Market Is Closed");
}else{
ObjectSetText("CandleClosingTimeRemaining-CCTR", "Market Is Closed",fontSize,"verdana",colour);
}
}else{
if(Period() == PERIOD_MN1 || Period()==PERIOD_W1){
days =((leftTime/60)/60)/24;
if(location == 0){
if(displayServerTime == 0){
Comment("Candle Closing Time Remaining: " + days +"D - "+sTime);
}else{
Comment("Candle Closing Time Remaining: " + days +"D - "+sTime+ " ["+ sCurrentTime+"]");
}
}else{
if(displayServerTime == 0){
ObjectSetText("CandleClosingTimeRemaining-CCTR", days +"D - "+sTime,fontSize,"verdana",colour);
}else{
ObjectSetText("CandleClosingTimeRemaining-CCTR", days +"D - "+sTime+ " ["+ sCurrentTime+"]",fontSize,"verdana",colour);
}
}
}else{
if(location == 0){
if(displayServerTime == 0){
Comment("Candle Closing Time Remaining: " + sTime);
}else{
Comment("Candle Closing Time Remaining: " + sTime+ " ["+ sCurrentTime+"]");
}
}else{
if(displayServerTime == 0){
ObjectSetText("CandleClosingTimeRemaining-CCTR", sTime,fontSize,"verdana",colour);
}else{
ObjectSetText("CandleClosingTimeRemaining-CCTR", sTime + " ["+ sCurrentTime+"]" ,fontSize,"verdana",colour);
}
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments