RemainingTime_ja
Download scriptThis tool is designed as an on-screen visual aid for traders using the MetaTrader platform. Its primary purpose is to provide a real-time countdown, showing exactly how much time remains before the current trading candle closes and a new one begins.
How It Works
The script constantly monitors the current timeframe you are viewing (such as 1-minute, 15-minute, or 4-hour charts) and calculates the difference between the current time and the end of the active bar.
Instead of requiring you to manually calculate the remaining time, the script performs this math automatically in the background. It then translates those raw numbers into a readable format on your chart screen.
Dynamic Display Logic
The way the information is presented changes automatically based on the timeframe you have selected:
- For Shorter Timeframes (1 Hour and below): The display focuses on minutes and seconds, providing a quick glance at the remaining "ticks" of the current candle.
- For Longer Timeframes (Above 1 Hour): The script recognizes that the countdown will exceed 60 minutes. In these cases, it automatically adjusts the display to show hours, minutes, and seconds simultaneously. This ensures that you always have a clear understanding of the remaining duration without the numbers becoming confusing or oversized.
Customization Features
The tool is built to be user-friendly and adaptable to your specific trading layout. It allows for several visual adjustments:
- Positioning: You can define exactly where on the chart the timer appears using horizontal and vertical coordinates.
- Visual Style: You can customize the font size and the text color (e.g., changing it to white or any other preferred shade) to ensure it is easy to read against your specific background theme.
By providing this constant visual feedback, the tool helps traders better manage their entries and exits, ensuring they are aware of how much time is left in a price movement before the market resets to a new candle.
//+------------------------------------------------------------------+
//| ReminingTime_ja.mq4 |
//| googolyenfx |
//| http://googolyenfx.blog18.fc2.com/ |
//+------------------------------------------------------------------+
#property copyright "googolyenfx"
#property link "http://googolyenfx.blog18.fc2.com/"
#property indicator_chart_window
string ReminingTime_sname = "bars_remining_time";
extern int Corner = 0;
extern double LocationX = 0;
extern double LocationY = 20;
extern int FontSize = 10;
extern color FontColor = White;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete(ReminingTime_sname);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double g;
int m, s, k, h;
m = Time[0] + Period()*60 - TimeCurrent();
g = m/60.0;
s = m%60;
m = (m - m%60) / 60;
string text;
if (Period() <= PERIOD_H1) {
text = "cè " + m + " ª " + s + " b";
}
else {
if (m >= 60) h = m/60;
else h = 0;
k = m - (h*60);
text = "cè " + h + " Ô " + k + " ª " + s + " b";
}
ObjectCreate(ReminingTime_sname, OBJ_LABEL, 0, 0, 0);
ObjectSetText(ReminingTime_sname, text, FontSize, "Terminal", FontColor);
ObjectSet(ReminingTime_sname, OBJPROP_XDISTANCE, LocationX);
ObjectSet(ReminingTime_sname, OBJPROP_YDISTANCE, LocationY);
ObjectSet(ReminingTime_sname, OBJPROP_CORNER, Corner);
return(0);
}
//+------------------------------------------------------------------+
Comments