problem with iCustom response

 

Hello, I try to get data from custom indicator (CustomIndicator), which shows a histogram of values between -2000 and 2000. I don't have source code of CustomIndicator

The code of script is as follows. As an example I used also other indicators (Stochastik and Williams). The resulting file mt5export.csv has correct values for Stochastik and Williams, but strange values for CustomIndicator, for example '0.0000000000', '-1809763237966210544315555930765042774681059328.0000000000' or even '14157495007440318255220461244635233750276190992296988497933634536158460323864765893608118071358733691783097890112221762587271787859631941052368234162851957343624540101891009798444483629279084544.0000000000'

I am not good at mql5, so I don't understand how to debug it and what is going wrong. 

How to get correct values of CustomIndicator?


// Export Indicator values
extern string IndExportFileName = "mt5export.csv";
extern int  trainSize = 200;

MqlRates srcArr[];
double StochKArr[], StochDArr[], WilliamsRArr[], CustomIndicatorArr[];


void OnStart()
  {
//---
   ArraySetAsSeries(srcArr, true);   
   ArraySetAsSeries(StochKArr, true);   
   ArraySetAsSeries(StochDArr, true);   
   ArraySetAsSeries(WilliamsRArr, true);
   ArraySetAsSeries(CustomIndicatorArr, true);
         
   int copied = CopyRates(Symbol(), Period(), 0, trainSize, srcArr);
   
   if (copied!=trainSize) { Print("Not enough data for " + Symbol()); return; }
   
   int hStochastic = iStochastic(Symbol(), Period(), 8, 5, 5, MODE_EMA, STO_LOWHIGH);
   int hWilliamsR = iWPR(Symbol(), Period(), 21);
   int hCustomIndicator = iCustom(Symbol(),Period(),"CustomIndicator name");
   
   CopyBuffer(hStochastic, 0, 0, trainSize, StochKArr);
   CopyBuffer(hStochastic, 1, 0, trainSize, StochDArr);
   CopyBuffer(hWilliamsR, 0, 0, trainSize, WilliamsRArr);
   CopyBuffer(hCustomIndicator , 0, 0, trainSize, CustomIndicatorArr);
    
   int hFile = FileOpen(IndExportFileName, FILE_CSV | FILE_ANSI | FILE_WRITE | FILE_REWRITE, ",", CP_ACP);
   
   FileWriteString(hFile, "DATE,TIME,CLOSE,StochK,StochD,Williams,CustomIndicator\n");
   
   Print("Exporting indicator data to " + IndExportFileName);
   
   for (int i=trainSize-1; i>=0; i--)
      {
         string candleDate = TimeToString(srcArr[i].time, TIME_DATE);
         string candleTime = TimeToString(srcArr[i].time, TIME_MINUTES);
         FileWrite(hFile, candleDate, candleTime, DoubleToString(srcArr[i].close), 
                                                  DoubleToString(StochKArr[i], -10),
                                                  DoubleToString(StochDArr[i], -10),
                                                  DoubleToString(WilliamsRArr[i], 10),
                                                  DoubleToString(CustomIndicatorArr[i], 10)
                                                  );
      }
      
   FileClose(hFile);   
     
   Print("Indicator data exported."); 
  }
//+------------------------------------------------------------------+
 
   int hFile = FileOpen(IndExportFileName, FILE_CSV | FILE_ANSI | FILE_WRITE | FILE_REWRITE, ",", CP_ACP);

REwrite isn't defined for FileOpen. Since you are writing the file completely, you don't want read.
          File Functions / FileOpen - Reference on algorithmic/automated trading language for MetaTrader 5
          File Functions / FileCopy - Reference on algorithmic/automated trading language for MetaTrader 5

 
William Roeder:

REwrite isn't defined for FileOpen. Since you are writing the file completely, you don't want read.
          File Functions / FileOpen - Reference on algorithmic/automated trading language for MetaTrader 5
          File Functions / FileCopy - Reference on algorithmic/automated trading language for MetaTrader 5

I think this issue does not result in wrong values, or I am wrong?