If you're looking to enhance your trading experience in MetaTrader 5, the Vertical Line Indicator is a handy tool that you’ll definitely want to have in your arsenal. This nifty indicator draws a vertical line (OBJ_VLINE) on your chart and moves it to a specified time—perfect for pinpointing important moments in your trading day!
Input Parameters:

You'll only need to set the hours and minutes in the Use only Hours and Minutes parameter to get started. The vertical line will be drawn for the current day, and each time a new day rolls around, the line automatically shifts to the new date at the specified hour and minute.
Check out the video:
One of the standout features of this indicator is its built-in protection against accidental deletion. There’s a timer that periodically checks if the vertical line is still on the chart. If it’s not found, a static variable named prev_date is reset to zero, ensuring your line is always where you expect it to be:
//+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- protection against unauthorized deletion if(ObjectFind(0,InpName)<0) { prev_date=0; VLineCreate(0,InpName,0,0.0,InpColor,InpStyle,InpWidth); } }
This logic will trigger the creation of a new vertical line in the OnCalculate() function:
if(prev_date==0) // first start { MqlDateTime str_input; TimeToStruct(InpTime,str_input); str_to_draw.hour=str_input.hour; str_to_draw.min=str_input.min; str_to_draw.sec=0; prev_date=StructToTime(str_to_draw); VLineMove(0,InpName,prev_date); return(rates_total); }
By incorporating the Vertical Line Indicator into your trading toolkit, you can easily keep track of key moments in the market. Happy trading!
Related Posts
- Mastering the MACD Candle Indicator for MetaTrader 4
- Unlock Trading Insights with Volume Profile + Range v6.0 for MetaTrader 5
- Hourly Buffers for Data Collection in MetaTrader 5: A Simple Guide
- Mastering the FE Fibonacci Expansion Indicator for MetaTrader 4
- Unlocking MetaCOT 2: Your Ultimate CFTC Indicator Toolkit for MT4