请教怎样添加时段分隔线?

 

MT4在低于H1的周期里会按照1天自动分隔

如果想按照小时整点分隔怎么办?

插入循环线的方法不好用

因为一旦K线有缺失分隔就不准了

求助各位高手了

祝您新年好运,财源广进!

 
//+------------------------------------------------------------------+
//|                                                     间隔指标.mq4 |
//|                                          LIU                SONG |
//|                         liusongwh@qq.com            qq:569638390 |
//+------------------------------------------------------------------+
#property copyright "LIU                SONG"
#property link      "liusongwh@qq.com            qq:569638390"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 C'118,9,130'
#property indicator_color2 C'28,10,192'
#property indicator_width1 2
#property indicator_width2 2
#property indicator_style1 STYLE_DOT
#property indicator_style2 STYLE_DOT
static datetime OnceBar = 0;
double Buffer0[];
double Buffer1[];
extern bool hua=false;
extern int  shu=5000;
extern int  zhi=240;
extern int  ss=0;
extern int  xx=0;
color  cr[3]={      C'90,12,254',
                    C'204,0,0',
                    C'0,136,62',
                    C'255,199,51',
                    };


int init()
{
//---- indicator line
  SetIndexStyle(0,DRAW_LINE,STYLE_DOT);
  SetIndexBuffer(0,Buffer0);
  SetIndexStyle(1,DRAW_LINE,STYLE_DOT);
  SetIndexBuffer(1,Buffer1);
  

//----
return(0);
}
int start()
  {
   if(newbar()){
 
  for (int uu =shu ; uu>0;uu--) {
  Buffer0[uu]=EMPTY_VALUE;
  Buffer1[uu]=EMPTY_VALUE;
 }
int i=0;
for ( int s = 0 ; s <= shu ; s++){
int  time=(Time[0]+Period()*60*365)-Period()*60*s;

if(time%(zhi*60)==0){
double     t_t=time+Period()*60*xx;
int pos=iBarShift(Symbol(),0,t_t,false);
  if(t_t<=iTime(Symbol(),0,0))Buffer0[pos]=iHigh(Symbol(),0,iBarShift(Symbol(),0,t_t,false)+1);
  if(t_t<=iTime(Symbol(),0,0))Buffer1[pos]=iLow(Symbol(),0,iBarShift(Symbol(),0,t_t,false)+1);
  if(hua){
ObjectCreate("huav4"+i,OBJ_VLINE,0,0,t_t);
ObjectSet("huav4"+i,OBJPROP_COLOR,cr[(i+ss)%4]);
ObjectSet("huav4"+i,OBJPROP_STYLE,STYLE_DOT);
ObjectSet("huav4"+i,OBJPROP_TIME1,t_t);
ObjectSet("huav4"+i,OBJPROP_WIDTH,0);
}
i++;
}// 15end
}//ss end

for (uu =shu ; uu>0;uu--) {
  if(Buffer0[uu]==EMPTY_VALUE)Buffer0[uu]=Buffer0[uu+1];
  if(Buffer1[uu]==EMPTY_VALUE)Buffer1[uu]=Buffer1[uu+1];
 }
}
   return(0);
  }
//+------------------------------------------------------------------+


bool newbar(){
  int shift, i;
   for (shift=iBars(Symbol(),0)-1; shift>=0; shift--)
     if (OnceBar != iTime(Symbol(),0,0))
      {
      OnceBar = iTime(Symbol(),0,0);
return (true);
      }
  }