error 4401

 
i purchased an indicator and i'm getting an error message 4401 how do i fix this 
 
man1980:
i purchased an indicator and i'm getting an error message 4401 how do i fix this 
a quick search seems to show it is a coding problem. report it to the seller.
 
Michael Charles Schefe #:
a quick search seems to show it is a coding problem. report it to the seller.
i did 
 
Contact the developer and/or seller and ask them for help.
 
Damiem Marchand De Campos #:
Contact the developer and/or seller and ask them for help.
i contacted him and he said it's a mt5 issue 
 
man1980 #:
i contacted him and he said it's a mt5 issue 

History Access

ERR_HISTORY_NOT_FOUND

4401

Requested history not found

(Runtime Errors - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL5 Reference). 

 
Ryan L Johnson #:

History Access

ERR_HISTORY_NOT_FOUND

4401

Requested history not found

(Runtime Errors - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL5 Reference). 

So how do you fix these code errors 
 
man1980 #:
So how do you fix these code errors 
coding of the ea.
 
man1980 #:
So how do you fix these code errors 

Forum on trading, automated trading systems and testing trading strategies

CopyRates Error 4401 when fetching data for non chart symbol

Lorentzos Roussos, 2024.10.07 17:10

try to wait until it loads 

consult the following code 

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot PctDelta
#property indicator_label1  "PctDelta"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
  input string otherSymbol="GBPJPY";//other symbol
  input int minBars=6000;//min bars to load 
//--- indicator buffers
  double PctDeltaBuffer[];

bool nativeLoaded=false,otherLoaded=false;
int OnInit()
  {
//--- indicator buffers mapping
  SetIndexBuffer(0,PctDeltaBuffer,INDICATOR_DATA);
  nativeLoaded=false;
  otherLoaded=false;
//---
   return(INIT_SUCCEEDED);
  }

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
  if(nativeLoaded&&otherLoaded){


  return(rates_total);
  }else{
  if(SymbolIsSynchronized(_Symbol)){nativeLoaded=true;
  if(SymbolIsSynchronized(_Symbol)){
    //load the other symbol 
      MqlRates otherBars[];
      int loadedBars=CopyRates(otherSymbol,_Period,0,minBars,otherBars);
      if(loadedBars>0){
        Comment("Loaded bars "+IntegerToString(loadedBars));
        if(loadedBars>=minBars){
          //1st calc 
            int from=rates_total-1-minBars;
            int to=rates_total-2;
            for(int i=from;i<=to;i++){
               //find bar in other symbol
                 int f=findInRatesByTime(otherBars,time[i],false);
                 if(f!=-1){
                   double this_change=(close[i]-open[i])/open[i];
                   double that_change=(otherBars[f].close-otherBars[f].open)/otherBars[f].open;
                   PctDeltaBuffer[i]=this_change-that_change;
                   }
               }  
          otherLoaded=true;
          return(rates_total);        
          }
        }
    }}
  }
  return(0);
  }
  
int findInRatesByTime(MqlRates &rates[],
                      datetime toFind, 
                      bool acceptOldest){
int found=-1;
if(ArraySize(rates)>1){
bool ascending=(bool)(rates[0].time<rates[ArraySize(rates)-1].time);
for(int i=0;i<ArraySize(rates);i++){
if(rates[i].time==toFind){found=i;break;}
if(i>0&&ascending&&acceptOldest&&rates[i].time>toFind&&rates[i-1].time<toFind){found=i;break;}
if(i<(ArraySize(rates)-1)&&!ascending&&acceptOldest&&rates[i].time<toFind&&rates[i+1].time>toFind){found=i;break;}
}
}
return(found);
}