Vertical Line - MetaTrader 5 Script | Forex Indicator Download - MT4/MT5 Resources - MetaTrader 5 Resources

The indicator draws a vertical line (OBJ_VLINE) and then moves it to the specified time (hours and minutes).
Input parameters :

Use Hours and Minutes Only " Use Hours and Minutes Only " range.
The vertical line is drawn for the current day. If a new day starts, the row will be moved to the new day and set to the specified hour and minute.
The indicator has built-in protection against accidental deletion of vertical lines: a timer periodically checks whether the line exists on the chart. If a vertical line (OBJ_VLINE) is not found, the static variable "prev_date" declared at the global program level is reset to zero:
//+------------------------------------------------------------------+ //|Timer function | //+------------------------------------------------------------------+ blank timer () { //--- prevent unauthorized deletion if ( object lookup ( 0 ,Inp name) < 0 ) { Previous date = 0 ; VLine creation ( 0 , Inp name, 0 , 0.0 , Inp color, Inp style, Inp width); } }
This will cause a new vertical line to be created in OnCalculate():
if (previous date == 0 ) // first start { Mql date time string input; BuildTime (InpTime, str_input); str_to_draw.hour=str_input.hour; str_to_draw.min=str_input.min; str_to_draw.sec= 0 ; PreviousDate = struct to time (str_to_draw); V line movement ( 0 ,InpName,prev_date); return (rate_total); }
Attachment download
📎 vertical_line.mq5 (14.81 KB)
Source: MQL5 #18449
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •