lookback limits in init? - page 2

 
diagonAlley:

This looks quite a weird thing. Is there a limit (=1000) into the time series access? Quite a bug, in the case! Is some MetaQuotes developer around?

Bye and thanks again.

DA

Quite a bug indeed unless we are both missing something very obvious . . I tried it on build 399 too, same result.
 
RaptorUK:
Quite a bug indeed unless we are both missing something very obvious . . I tried it on build 399 too, same result.
for(int k = 1440; k >= 0; k--)

In the tester the initial limit is 100.

Don't hard code numbers. Use Bars

 
Looks like the code does work on Live/Demo . . .
 
WHRoeder:

In the tester the initial limit is 100.

Don't hard code numbers. Use Bars


RaptorUK: obviously! It can be that we are missing something trivial. MetaQuotes developers: no offense intended!

And indeed: on live/demo the EA works properly.

WHRoeder:

very interesting input here. Could you please elaborate a bit?

Where did you find these specs about the tester? If the limit is 100, why do I get results back up to 1000?

What do you mean by "using Bars"?

The limitation in the tester is indeed something quite annoying for me. The original project is one where I would like to analyze data (tick data, actually) by feeding them through an EA. With such a limitation I see life quite hard. Any suggestion?

Thanks a lot

DA

 
I wonder why there is no mention of this limitation in this document . . . https://www.mql5.com/en/articles/1512
 
RaptorUK:
I wonder why there is no mention of this limitation in this document . . . https://www.mql5.com/en/articles/1512


Hi Raptor,

yes, very very bad... Life would be so much easier for us poor coders, with precise and complete specs, sometimes...!

I have found the crazy solution, in the absence of any further hint from WHRoeder. Yes, because I NEED this solution for the tester, not for the life stream. And here we go: it's really crazy.

//This is an EA
bool initialize  = true;
int  cheatTester = 0;

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   if(initialize)
      {
       static datetime newBar = 0;
       while(cheatTester <= 2880)
             {
              if(newBar != iTime(Symbol(), PERIOD_M1, 0))
                 {
                  newBar = iTime(Symbol(), PERIOD_M1, 0);
                  cheatTester++;
                  // let the program run idle till 2 days of data are loaded
                 }
              return(0);
             }
       
       Print("Time of cycle start: ", TimeToStr(Time[0], TIME_DATE|TIME_MINUTES));
       
       for(int k = 1440; k >= 0; k--)
         {
          
          Print(TimeToStr(iTime(Symbol(), PERIOD_M1, k), TIME_DATE|TIME_MINUTES));
          Print("Bars ago: ", k, "; Open, High, Low, Close: ", DoubleToStr(iOpen(Symbol(), PERIOD_M1, k), Digits), ", ", 
                 DoubleToStr(iHigh(Symbol(), PERIOD_M1, k), Digits), ", ", 
                 DoubleToStr(Low[k], Digits), ", ", DoubleToStr(Close[k], Digits));
          }
       initialize = false; 
      }   
//----
   return(0);
  }
//+------------------------------------------------------------------+

This is the log output (generated by backtesting M1 from 2011.11.29):

20:55:36 TestDataStream EURUSD,M1: loaded successfully
20:55:36 TestDataStream test started
20:55:36 2011.12.01 00:00  TestDataStream EURUSD,M1: Time of cycle start: 2011.12.01 00:00
20:55:36 2011.12.01 00:00  TestDataStream EURUSD,M1: 2011.11.30 00:00
20:55:36 2011.12.01 00:00  TestDataStream EURUSD,M1: Bars ago: 1440; Open, High, Low, Close: 1.33152, 1.33161, 1.33124, 1.33155
20:55:36 2011.12.01 00:00  TestDataStream EURUSD,M1: 2011.11.30 00:01
20:55:36 2011.12.01 00:00  TestDataStream EURUSD,M1: Bars ago: 1439; Open, High, Low, Close: 1.33154, 1.33162, 1.33131, 1.33139
20:55:36 2011.12.01 00:00  TestDataStream EURUSD,M1: 2011.11.30 00:02
20:55:36 2011.12.01 00:00  TestDataStream EURUSD,M1: Bars ago: 1438; Open, High, Low, Close: 1.33140, 1.33161, 1.33116, 1.33116
20:55:36 2011.12.01 00:00  TestDataStream EURUSD,M1: 2011.11.30 00:03
20:55:36 2011.12.01 00:00  TestDataStream EURUSD,M1: Bars ago: 1437; Open, High, Low, Close: 1.33118, 1.33122, 1.33111, 1.33111
20:55:36 2011.12.01 00:00  TestDataStream EURUSD,M1: 2011.11.30 00:04
20:55:36 2011.12.01 00:00  TestDataStream EURUSD,M1: Bars ago: 1436; Open, High, Low, Close: 1.33112, 1.33118, 1.33111, 1.33115.....

Well: you see what I do! I simply "cheat" the tester waiting that it runs idle the first 2880 bars (they could be less probably), i.e. two days (of minute bars) days. Then, when it starts looking back, somehow it has already loaded all the bars it should work on.

The side effect is that your "real" testing starts two days after the date you set in the tester, but, who cares? You just set the tester two days before the date you want to start testing.

If you (or others) have additional ideas on how to make it in a more efficient and elegant way: welcome to all the suggestions to this small dumb here!

A corollary: you see this is now an EA without init() and deinit(). After this experience I don't know if I'll trust the built in again in my coding career (well: at least init(); deinit() is somehow more interesting and it makes sense the 2.5 seconds timeout. About limitation to cycles... well: let's keep finger crossed!).

Is there any gentle soul able to tell me why the hell in the development of the tester that maximum lookback at sart up was introduced? If the history database contains those data, why should we be limited in accessing them?

May I say that, from my dumb viewipoint this looks quite... (may I?) useless (I wanted to use another word... let's keep politically correct).

Bye

DA

 
Ah I see . . . thanks for sharing your solution, it makes total sense now. :-)