Download MetaTrader 5
To add comments, please log in or register
MQL5 Cloud Network speeds up calculations. Try it!
Luca
21
Luca 2016.04.18 19:11 

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;
}
Alain Verleyen
Moderator
28524
Alain Verleyen 2016.04.18 20:34  
Please pay more attention when posting, I had to edit your post to make it readable, it was all on 1 line.
Luca
21
Luca 2016.04.18 23:41  
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
whroeder1
13596
whroeder1 2016.04.19 01:59  
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.
Luca
21
Luca 2016.04.19 09:32  
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 

Luca
21
Luca 2016.04.19 15:32  
I attach complete expert
/
To add comments, please log in or register