Why my Copy functions fail on tester ?

 
>_<

all the procedures the EA performs to copy large quantities of buffers and prices, works fine in demo mode.
BUT
the same procedure fails each and every time in tester.

how to copy large number of buffers/prices in tester successfully ? (~ 350,000 buffer doubles)

I guess the problem is, my code uses while loops and sleep function to collect and store all buffers data, and sleep function fails to make the desired delay in tester.
so what option do I have ?
 

Do you find something in the tester's log?

Use the visual mode and show the relevant variable with Comment() to find out where and why you code hangs.

 
Code2219 or probably 2319:
>_<

all the procedures the EA performs to copy large quantities of buffers and prices, works fine in demo mode.
BUT
the same procedure fails each and every time in tester.

how to copy large number of buffers/prices in tester successfully ? (~ 350,000 buffer doubles)

I guess the problem is, my code uses while loops and sleep function to collect and store all buffers data, and sleep function fails to make the desired delay in tester.
so what option do I have ?

There is no need for sleep function. Fix your code.

Please show your code if you need coding help.

 

@Alain Verleyen

this is the code , manages to collect data and fill arrays successfully in demo, in 2 to 20 seconds. (depending on history download etc...)

int try= 1;
bool Copy_Done = false;
while(try<=100 && !Copy_Done)
{
        int copied_elements = 0;
        copied_elements += CopyOpen(_Symbol, PERIOD_H1, 1, 15000, A);
        copied_elements += CopyHigh(_Symbol, PERIOD_H1, 1, 15000, B);
        copied_elements +=  CopyLow(_Symbol, PERIOD_H1, 1, 15000, C);
        copied_elements += CopyTime(_Symbol, PERIOD_H1, 1, 15000, D);
        copied_elements += CopyBuffer(i1_H1, 0, 1, 15000, Z1);
        copied_elements += CopyBuffer(i2_H1, 0, 1, 15000, Z2);
        copied_elements += CopyBuffer(i3_H1, 0, 1, 15000, Z3);
        copied_elements += CopyBuffer(i4_H1, 0, 1, 15000, Z4);
        copied_elements += CopyBuffer(i5_H1, 0, 1, 15000, Z5);
        try++;
        if(copied_elements != 135000) Sleep((101-try)*10);      // max aggregate time delay : 50500 ms
        else Copy_Done = true;
}


is it a good idea to add this logical OR to while condition, so the while becomes :

while( (try<=100 && !Copy_Done) || (MQLInfoInteger(MQL_TESTER) && !Copy_Done) )
{
  //....
}
 
Carl Schreiber:

Do you find something in the tester's log?

Use the visual mode and show the relevant variable with Comment() to find out where and why you code hangs.

it shows the copying loop (the whole while()...) takes 10ms to be done, and of course fails to copy all elements, each time.
 
Code2219 or probably 2319:

@Alain Verleyen

this is the code , manages to collect data and fill arrays successfully in demo, in 2 to 20 seconds. (depending on history download etc...)


is it a good idea to add this logical OR to while condition, so the while becomes :

It will never succeed. The problem is with the Strategy Tester you will never get 15,000 H1 candles as history is limited to 1 year (it's very approximative I have seen 1,5 years). So you will get around 6,000 H1 candles at the start, but never 15,000. If you absolutely need 15,000 candles data, start earlier your backtest and then wait to have enough candles.

A problem of your code is you don't check for error code. Also the recommended way to deal with Copyxxx error is the return and wait the next tick (eventually a timer if you don't want to rely on a new tick), Sleep() is undesirable.

 
Alain Verleyen:

It will never succeed. The problem is with the Strategy Tester you will never get 15,000 H1 candles as history is limited to 1 year (it's very approximative I have seen 1,5 years). So you will get around 6,000 H1 candles at the start, but never 15,000. If you absolutely need 15,000 candles data, start earlier your backtest and then wait to have enough candles.

A problem of your code is you don't check for error code. Also the recommended way to deal with Copyxxx error is the return and wait the next tick (eventually a timer if you don't want to rely on a new tick), Sleep() is undesirable.

thanks, got it fixed.
Reason: