CandleTimeV
Download scriptThis script is designed to act as a real-time visual countdown timer for traders using the MetaTrader 4 platform. Its primary purpose is to provide a clear, instant notification of how much time remains before the current candlestick finishes and a new one begins on the chart.
Core Functionality
The logic operates by constantly calculating the difference between the current clock time and the exact moment the current candle is scheduled to close. It takes the timeframe you are currently viewing (such as 1-minute, 5-minute, or 1-hour charts) into account to ensure the countdown is perfectly synchronized with your specific trading perspective.
How it Works
- Time Calculation: The script monitors the "live" time and compares it against the metadata of the current candle. It automatically breaks this difference down into minutes and seconds.
- Dynamic Display: As time passes, the numbers update automatically. The script ensures that single-digit numbers are formatted correctly (for example, showing "05" instead of just "5") to maintain a clean and professional appearance on your screen.
- Visual Customization: The script offers two ways to display this information depending on your preference:
- Chart Label: By default, it places a vertical text label directly on the price chart near the current candle's closing price. This allows you to see the countdown while simultaneously watching price action.
- Comment Box: Alternatively, it can be configured to display the time remaining in a small text box in the corner of the screen, which is ideal for traders who prefer a less cluttered visual workspace.
Key Features for Traders
- Vertical Orientation: The on-chart text is rotated at a 90-degree angle, allowing it to sit neatly next to the candles without overlapping other price data.
- Fully Customizable Aesthetics: You can easily adjust the font style, the size of the text, and the color (e.g., Aqua) to ensure the information stands out clearly against your specific chart background.
- Automatic Cleanup: The script is designed to be "clean." When you remove the indicator from your chart, it automatically deletes the text objects, ensuring no leftover markings remain on your screen.
//====================================================================
// CandleTimeV.mq4
// by Derk Wehler
// derkwehler@gmail.com
// Version "V" has text vertical @ 90 degrees
//====================================================================
#property copyright "Copyright © 2005, Derk Wehler"
#property link "http://www.ArrogantFxBastards.com"
#property indicator_chart_window
extern bool UseComment = false;
extern color TextColor = Aqua;
extern int TextSize = 8;
extern string TextFont = "Verdana";
double s1[];
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete("time");
return(0);
}
//+------------------------------------------------------------------+
int start()
{
double i;
int m, s;
string output;
m = Time[0] + Period() * 60 - CurTime();
i = m / 60.0;
s = m % 60;
m = (m - m % 60) / 60;
output = m + ":";
if(m<10) output="0"+output;
if(s<10) output=output+"0"+s+" left to bar end";
else output=output+s+" left to bar end";
if (UseComment) Comment(output);
else
{
ObjectDelete("time");
ObjectCreate("time", OBJ_TEXT, 0, Time[0], Close[0]+0.0005);
ObjectSetText("time", output, TextSize, TextFont, TextColor);
ObjectSet("time",OBJPROP_ANGLE,90);
}
return(0);
}
//+------------------------------------------------------------------+
Comments