Download MetaTrader 5

Expert array news for backtest

To add comments, please log in or register
MQL5.community allows users to store their source codes in MQL5 Storage. Try it!
Luca
21
Luca 2016.04.19 13:15 

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 .  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

//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;
}
To add comments, please log in or register