Problem Array datetime and iBarShift

 

I have this problem that gives me trouble for quite some days , I think it's pretty much a fact of the code structure, because in this case the shift of the news candle never increases . Because if the news comes out at 17:00 , at 17:01 the news candle will no longer 0 but will of course 1 ( M1 ) , whereas I always remains zero and I can not give him the proper functioning .

News[0] = D'2016.01.01 17:00:00';
News[1] = D'2016.01.02 17:30:00';
for(int i = 0; i <ArraySize(News); i++)
{
  CandleNews=iBarShift(Symbol(),PERIOD_CURRENT,News[i],false);
  if(CandleNews>2) 
  {
   OrderSend
  }
 return;
}
 
Please pay more attention when posting, I had to edit your post to make it readable, it was all on 1 line.
 
angevoyageur:
Please pay more attention when posting, I had to edit your post to make it readable, it was all on 1 line.

sorry . It is the first time I publish a question
 
Fondamental: whereas I always remains zero and I can not give him the proper functioning .
The code you posted contradicts your statement. Add print statement including your variables, or post the real code.
 
WHRoeder:
Fondamental: whereas I always remains zero and I can not give him the proper functioning .
The code you posted contradicts your statement. Add print statement including your variables, or post the real code.
//initialization function 
datetime News[2];
int Magic= 123;
int CandleNews;


//tick function
                                  // Array declaration
News[0] = D'2016.01.01 17:00:00';
News[1] = D'2016.01.02 17:30:00';

for(int i = 0; i <ArraySize(News); i++){

CandleNews=iBarShift(Symbol(),PERIOD_CURRENT,News[i],false);


  if(CandleNews>5)     //after 5 candles from the candle news opener order
  {
  OrderSend(Symbol(),OP_BUY,1.0,Ask,0,0,0,"ArrayDatetimeNews",Magic,0,Blue); 
  }
 return;
}

I already have an expert that open only one order on a news. But to make the backtest i need an array that open more orders on a list of news.

Ps.Sorry for my english but i'am italian 

 
I attach complete expert
Reason: