Bid_Line_v2
Download scriptThis custom indicator for the MetaTrader platform is designed to provide traders with a clean, real-time visual reference on their trading charts. It focuses on two primary functions: plotting a dynamic horizontal price line and displaying a live countdown timer.
Dynamic Price Line
The tool automatically draws a horizontal line on your chart to represent a specific price point. Rather than being a static line, it is "intelligent"—it tracks moving market data based on your preference. You can choose to have the line follow the current market price (such as the Ask, Bid, Open, High, or Low prices) or the closing price of the current candle.
Additionally, the script includes an offset feature. This allows you to shift the line's position slightly above or below the actual price point, providing extra breathing room or a specific buffer for your visual analysis. You also have full control over the aesthetic appearance, including the color and the style (solid, dashed, dotted, etc.) of the line.
Real-Time Countdown Clock
The indicator includes a built-in time tracking component that serves as a countdown. It calculates the remaining time based on the current timeframe of your chart (e.g., how many minutes are left in a 15-minute or 1-hour candle).
This clock appears directly on the chart and updates dynamically, showing the minutes and seconds remaining until the next candle opens. This helps traders keep track of expiration times or candle transitions at a glance without needing to look at the main time headers.
Summary of Features
- Flexible Price Tracking: Choose which price type (High, Low, Close, etc.) the line follows automatically.
- Visual Customization: Easily adjust colors and line styles to match your trading layout.
- Automatic Positioning: The script handles all the heavy lifting of updating the line's coordinates as the market moves.
- Candle Awareness: A live countdown helps synchronize your entries and exits with the current timeframe.
#property indicator_chart_window
extern string Line_Name = "Price_Line_1";
extern double offset = 0.000;
extern color Line_Color = DodgerBlue;
extern string SettingSplt1 = "=========================================";
extern int Line_Style = 0;
extern string StyleNumber = "ª[0=Solid] [1=Dash] [2=Dot] [3=DashDot] ";
extern string SettingSplt2 = "=========================================";
extern string Line_Position = "Close";
extern string PositionType = "ª[Ask] [Bid] [Close] [Open] [High] [Low]";
extern string SettingSplt3 = "=========================================";
extern color Clock_Color = Magenta;
extern bool Clock_Disp = true;
extern int Clock_Xpos = 6;
int init()
{
SetIndexLabel(0,NULL);
return(0);
}
int deinit()
{
ObjectDelete(Line_Name);
return(0);
}
int start()
{
if(ObjectFind(Line_Name) == -1){
ObjectCreate(Line_Name,OBJ_HLINE,0,0,LP(Line_Position));
ObjectSet(Line_Name,OBJPROP_COLOR,Line_Color);
}
ObjectSet(Line_Name,OBJPROP_PRICE1,LP(Line_Position));
ObjectSet(Line_Name, OBJPROP_STYLE, Line_Style);
CD(Clock_Disp);
return(0);
}
double LP(string Pt)
{
if(Pt=="CLOSE"||Pt=="Close"||Pt=="close")return((offset+Close[0]));
if(Pt=="ASK"||Pt=="Ask"||Pt=="ask")return((offset+Ask));
if(Pt=="BID"||Pt=="Bid"||Pt=="bid")return((offset+Bid));
if(Pt=="OPEN"||Pt=="Open"||Pt=="open")return((offset+Open[0]));
if(Pt=="HIGH"||Pt=="High"||Pt=="high")return((offset+High[0]));
if(Pt=="LOW"||Pt=="Low"||Pt=="low")return((offset+Low[0]));
return((offset+Close[0]));
}
void CD(bool flg)
{
if(flg)
{
double i = 0.0;
int m,s,k;
string Margin = "";
m=Time[0]+Period()*60-CurTime();
i=m/60.0;
s=m%60;
m=(m-m%60)/60;
i=(m/Period()) * 100.0;
ObjectDelete("time");
if(ObjectFind("time") != 0) {
for(int x=0; x<=(Clock_Xpos*2); x++) Margin = Margin + " ";
ObjectCreate("time", OBJ_TEXT, 0, Time[0], Close[0]);
ObjectSetText("time", Margin+"<"+m+":"+s+" / "+Period() , 8, "Arial", Clock_Color);
} else ObjectMove("time", 0, Time[0], Close[0]);
} else if(ObjectFind("time") >= 0) ObjectDelete("time");
}
Comments