//+------------------------------------------------------------------+ //| Time_H1.mq5 | //| avoitenko | //| https://www.mql5.com/ru/users/avoitenko | //+------------------------------------------------------------------+ #property copyright "" #property link "https://www.mql5.com/ru/users/avoitenko" #property version "1.01" #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 input uint barsToProcess=24; input color colir=clrGray; datetime time[]; //+------------------------------------------------------------------+ int OnInit() //+------------------------------------------------------------------+ { // ArraySetAsSeries(time,true); return(0); } //+------------------------------------------------------------------+ void OnDeinit(const int reason) //+------------------------------------------------------------------+ { for(uint i=0;i<barsToProcess;i++) { ObjectDelete(0,"Line "+DoubleToString(i,0)); } } //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) //+------------------------------------------------------------------+ { uint limit; if(prev_calculated>rates_total || prev_calculated<=0) limit=rates_total-1; else limit=rates_total-prev_calculated; if(limit>barsToProcess)limit=barsToProcess; if(CopyTime(_Symbol,PERIOD_H1,0,limit,time)!=limit) return(0); for(uint i=0; i<limit; i++) { string name="Line "+IntegerToString(i); if(ObjectFind(0,name)<0) ObjectCreate(0,name,OBJ_VLINE,0,time[i],0); ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_DASHDOTDOT); ObjectSetInteger(0,name,OBJPROP_COLOR,colir); ObjectSetInteger(0,name,OBJPROP_TIMEFRAMES,OBJ_PERIOD_M5); } //---- return(rates_total); } //+------------------------------------------------------------------+
Thanks for the code, :) it is working
One small issue, the indicator doesn't update it self for the next day or coming hours.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi guys,
I've converted mq4 to mq5, here is the code, however,
I'm not able to make it work
here is the final result, vertical lines indicating each hour.
here is the original code
here is my effort on conversion