Problems with copybuffer

 
 ret = CopyBuffer(Handle_Long,0,0,5,EMA200);
   
   if(ret <= 0 )
    {
     err = GetLastError();
     errortext = " copyBuffer MA long failed A3 ret = " + DoubleToString(ret,0) + " err: " + DoubleToString(err,0)+ " Pair: " + Pair;
     Print(errortext);
    }
   Print(" initial Copybuffer " + Pair + "  ret:  " + ret);
   
   while(ret<=0)
    {
     Sleep(100);
     ret = CopyBuffer(Handle_Long,0,0,5,EMA200);
     if(ret > 0) break; 
     cntr++;
     if(cntr>5) break;
    }
   Print( cntr + " tries for Copybuffer " + Pair +  "  ret:  " + ret);
   if(ret<0)
    {
     err = GetLastError();
     prms.Active[indx] = 0;            //Cannot trade this pair
     errortext = errortext + " copyBuffer MA long failed A3 ret = " + DoubleToString(ret,0) + " err: " + DoubleToString(err,0)+ " Pair: " + Pair;
     errorindicator = -9;
     Print(errortext);
     return false;
    } 

On some pairs I get problems creating a buffer for moving average. It is multicurrency EA.  Error 4806,  data not found.

I even tried with some retry code but it does not help, see below.  Are there any other means of getting to this data.

 

Solved.

Not enough historical data.

Open a window (In my case it was GBPJPY)

For all relevant time frames:

Set so window do not automatically jumps to the last bar

press PgUp until enough historical data can be seen on screen.


I knew all this. I did not think it was needed when programmatically getting historical data since it is done automatically when doing optimization runs.

I do opt run on one computer and test on another

So another solution is to run an optimization run on the MT5 where you will run the EA.

 
ingvar_e:

Solved.

Not enough historical data.

Open a window (In my case it was GBPJPY)

For all relevant time frames:

Set so window do not automatically jumps to the last bar

press PgUp until enough historical data can be seen on screen.


I knew all this. I did not think it was needed when programmatically getting historical data since it is done automatically when doing optimization runs.

I do opt run on one computer and test on another

So another solution is to run an optimization run on the MT5 where you will run the EA.

You can also load history by script, see CheckLoadHistory().
 
angevoyageur:
You can also load history by script, see CheckLoadHistory().

Thanks!

Thats a new one for me.