barComplete
Download scriptThis tool is designed to provide a real-time visual representation of how much time has elapsed within the current active candle on your trading chart. Instead of forcing you to manually calculate the remaining time, it automatically tracks the progress and displays it directly on your screen.
Core Functionality
The script monitors the "life cycle" of the current price bar by calculating two main factors:
- Time Elapsed: It measures how much time has passed since the current candle opened compared to the total duration of that specific timeframe (e.g., 1 minute, 1 hour, etc.).
- Price Range: It identifies the highest and lowest price points reached during the current period.
Visual Indicators
The logic translates these calculations into three distinct visual elements on your chart:
- The Progress Bar: The script draws a dual-layered graphic. One layer represents the total potential height of the current candle's movement, while the other dynamically "fills up" based on the percentage of time that has passed. This allows you to see at a glance how far along the current period is.
- Dynamic Percentage Label: A text label appears next to the visual bar, showing the exact percentage of completion (e.g., "50%").
- Status Alerts: The script includes a smart monitoring feature where it checks if the time elapsed exceeds the standard duration of the candle. If the current time exceeds the expected period, the text automatically switches to a "LATE!" warning in red, notifying you that the data for the current bar may be delayed or irregular.
User Experience
The tool is designed to be intuitive and automated. It handles all the math behind the scenes—calculating price differences and time intervals—to provide a clean, real-time progress tracker. This helps traders better visualize the passage of time relative to price action without needing to perform manual calculations.
//+------------------------------------------------------------------+
//| barComplete.mq4 |
//| Copyright © 2009, Jason Muchow (airforcemook@hotmail.com) |
//| |
//+------------------------------------------------------------------+
extern bool text = true;
extern int width = 3;
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
ObjectDelete("barComplete_bg");
ObjectDelete("barComplete_p");
double top = WindowPriceMax(0);
double bottom = WindowPriceMin(0);
double difference = TimeCurrent() - Time[0];
double total = Period()*60;
double percent = difference / total;
//Print("This bar is " + percent + "% complete.");
double move = top - bottom;
double barHeightMax = bottom + (percent * move);
ObjectCreate("barComplete_bg",OBJ_RECTANGLE,0,Time[0]+5*Period()*60,top,Time[0]+(5+width)*Period()*60,top - (1-percent)*move);
ObjectSet("barComplete_bg",OBJPROP_COLOR,DarkGray);
ObjectCreate("barComplete_p",OBJ_RECTANGLE,0,Time[0]+5*Period()*60,bottom,Time[0]+(5+width)*Period()*60,barHeightMax);
ObjectSet("barComplete_p",OBJPROP_COLOR,Red);
ObjectDelete("barComplete_txt");
int p = percent*100;
string pText = p+"%";
ObjectCreate("barComplete_txt",OBJ_TEXT,0,Time[0]+(5+width+3)*Period()*60,(top+bottom)/2);
ObjectSetText("barComplete_txt",pText,12,"Arial",White);
if (p > 100) {
ObjectSetText("barComplete_txt","LATE!",12,"Arial",Red);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments