Differences representing 3 or 5 decimals symbols

 

I am trying to export symbol rates to a CSV file using this code, that works fine for symbols that work with 3 decimals (like CADJPY), but not for those that work with 5 decimals (like AUDCAD):


void OnStart() {
        
   string symbolName = Symbol(); //o _Symbol
   ENUM_TIMEFRAMES period = Period(); //o _Period
   string periodName = EnumToString(period);         
   int decimals =(int)SymbolInfoInteger(symbolName, SYMBOL_DIGITS);
      
   string fileName = symbolName + "_" + periodName + ".csv";
   int fileHandle = FileOpen(fileName, FILE_WRITE|FILE_CSV); 
   
   if (fileHandle != INVALID_HANDLE) { 
   
      MqlRates bars[];
      ArraySetAsSeries(bars, true);
      int numBars = CopyRates(symbolName, period, 0, Bars(symbolName, period), bars);
   
      for (int i = 0; i < numBars; i++) {
         FileWrite(fileHandle, 
            DoubleToString(NormalizeDouble(bars[i].open, decimals), decimals), 
            DoubleToString(NormalizeDouble(bars[i].high, decimals), decimals), 
            DoubleToString(NormalizeDouble(bars[i].low, decimals), decimals), 
            DoubleToString(NormalizeDouble(bars[i].close, decimals), decimals)
            );    
      }         
      FileClose(fileHandle); 
   }
   
}


Any help will be appreciated, thanks!

 
This is an Excel issue. If I open the CSV with a plain text editor I see it correctly