Script modification, exporting only close price to csv without any commas

 

I found a script that exports X amount of candles, history. that's what it spits out:

2019.07.22,16:56,1,1.24840,1.24856,1.24837,1.24855,


but i want only close price without any commas, what do i have to delete for it works? all my attempts failed or result in the script not working anymore :((


//--------------------------------
//----
 int handle;
 
 //number of bars to export per Symbol
 int maxBars = 2000;
 //test first on several pairs
string Currencies[] = {"EURUSD","GBPUSD"};
 
 
 // then add more in the same format
// string Currencies[] = {"AUDUSD","EURUSD","GBPJPY","GBPUSD","EURJPY","EURGBP","USDCHF","USDJPY","AUDJPY","CHFJPY","CADJPY","GBPCAD","EURAUD","USDCAD","EURCAD","NZDUSD","NZDJPY"};
string dSymbol;

//+------------------------------------------------------------------+
//|  start function                                    |
//+------------------------------------------------------------------+
int start(){
 int count = ArraySize(Currencies);
 for (int ii=0; ii<count; ii++){
 dSymbol = Currencies[ii];   
 handle = FileOpen("Hist_"+dSymbol+"_"+GetPeriodName()+".csv", FILE_BIN|FILE_WRITE);

if(handle < 1){
 Print("Err ", GetLastError());
return(0);
}
 WriteTABLEHeader();

for(int i = 0; i < maxBars - 1; i++){
 WriteRow(i);
}
 FileClose(handle);
}
 Alert("Done."+TimeMonth(TimeLocal())+TimeDay(TimeLocal())+TimeYear(TimeLocal()) +"_"+TimeHour(TimeLocal())+TimeMinute(TimeLocal()));

  return(0);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteString(string txt){
   FileWriteString(handle, txt,StringLen(txt));
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteTABLEHeader(){
 WriteString("Date,");
 WriteString("Time,");
 WriteString("DayOfWeek,");
 WriteString("Open,");
 WriteString("High,");
 WriteString("Low,");
 WriteString("Close,");
 WriteString("Volume,");
 WriteString("\n");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteRow(int i){
 
 double  dSymTime, dSymOpen, dSymHigh, dSymLow, dSymClose, dSymVolume;
 double  dSymHigh_D1,dGap;
 int dDayofWk,iDigits;
 string bandDistance;
 double dClose, dOpen,Poin,dblPoints;
 dSymTime = (iTime(dSymbol,Period(),i));
 dDayofWk = (TimeDayOfWeek(dSymTime));
 WriteString(TimeToStr(dSymTime, TIME_DATE ));
 WriteString(",");
 if(Period() < PERIOD_H4){
 WriteString(TimeToStr(Time[i], TIME_MINUTES)+","+dDayofWk+",");
}
 iDigits=MarketInfo(Symbol(),MODE_DIGITS);
 dSymOpen = (iOpen(dSymbol,Period(),i));
 dSymHigh = (iHigh(dSymbol,Period(),i));
 dSymHigh_D1 = (iHigh(dSymbol,Period(),i));
 dSymLow = (iLow(dSymbol,Period(),i));
 dSymClose = (iClose(dSymbol,Period(),i));
 dSymVolume = (iVolume(dSymbol,Period(),i));
 WriteString(DoubleToStr(dSymOpen, iDigits)+",");
 WriteString(DoubleToStr(dSymHigh, iDigits)+",");
 WriteString(DoubleToStr(dSymLow, iDigits)+",");
 WriteString(DoubleToStr(dSymClose, iDigits)+",");
 WriteString("\n");
 }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string GetPeriodName(){

   switch(Period()){
     
       case PERIOD_D1:  return("Day");
       case PERIOD_H4:  return("4_Hour");
       case PERIOD_H1:  return("Hour");
       case PERIOD_M1:  return("Minute");
       case PERIOD_M15: return("15_Minute");
       case PERIOD_M30: return("30_Minute");
       case PERIOD_M5:  return("5_Minute");
       case PERIOD_MN1: return("Month");
       case PERIOD_W1:  return("Week");
     }
  }
 
bosslife:

I found a script that exports X amount of candles, history. that's what it spits out:

2019.07.22,16:56,1,1.24840,1.24856,1.24837,1.24855,


but i want only close price without any commas, what do i have to delete for it works? all my attempts failed or result in the script not working anymore :((


//+------------------------------------------------------------------+
//|                                                       sadasd.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
int handle;
 
 //number of bars to export per Symbol
 int maxBars = 2000;
 //test first on several pairs
string Currencies[] = {"EURUSD.","GBPUSD"};
 
 
 // then add more in the same format
// string Currencies[] = {"AUDUSD","EURUSD","GBPJPY","GBPUSD","EURJPY","EURGBP","USDCHF","USDJPY","AUDJPY","CHFJPY","CADJPY","GBPCAD","EURAUD","USDCAD","EURCAD","NZDUSD","NZDJPY"};
string dSymbol;

//+------------------------------------------------------------------+
//|  start function                                    |
//+------------------------------------------------------------------+
int start(){
 int count = ArraySize(Currencies);
 for (int ii=0; ii<=count; ii++){
 dSymbol = Currencies[ii];   
 handle = FileOpen("Hist_"+dSymbol+"_"+GetPeriodName()+".csv", FILE_BIN|FILE_WRITE);

if(handle < 1){
 Print("Err ", GetLastError());
return(0);
}
 WriteTABLEHeader();

for(int i = 0; i < maxBars - 1; i++){
 WriteRow(i);
}
 FileClose(handle);
}
 Alert("Done."+TimeMonth(TimeLocal())+TimeDay(TimeLocal())+TimeYear(TimeLocal()) +"_"+TimeHour(TimeLocal())+TimeMinute(TimeLocal()));

  return(0);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteString(string txt){
   FileWriteString(handle, txt,StringLen(txt));
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteTABLEHeader(){
 WriteString("Date,");
 WriteString("Time,");
 WriteString("DayOfWeek,");
 WriteString("Close,");
 WriteString("Volume");
 WriteString("\n");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteRow(int i){
 
 double  dSymTime, dSymClose, dSymVolume;
 double  dSymHigh_D1,dGap;
 int dDayofWk,iDigits;
 string bandDistance;
 double dClose, dOpen,Poin,dblPoints;
 dSymTime = (iTime(dSymbol,Period(),i));
 dDayofWk = (TimeDayOfWeek(dSymTime));
 WriteString(TimeToStr(dSymTime, TIME_DATE ));
 WriteString(",");
 if(Period() < PERIOD_H4){
 WriteString(TimeToStr(Time[i], TIME_MINUTES)+","+dDayofWk+",");
}
 iDigits=MarketInfo(Symbol(),MODE_DIGITS);
 dSymClose = (iClose(dSymbol,Period(),i));
 dSymVolume = (iVolume(dSymbol,Period(),i));
 WriteString(DoubleToStr(dSymClose, iDigits)+",");
 WriteString("\n");
 }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string GetPeriodName(){

   switch(Period()){
     
       case PERIOD_D1:  return("Day");
       case PERIOD_H4:  return("4_Hour");
       case PERIOD_H1:  return("Hour");
       case PERIOD_M1:  return("Minute");
       case PERIOD_M15: return("15_Minute");
       case PERIOD_M30: return("30_Minute");
       case PERIOD_M5:  return("5_Minute");
       case PERIOD_MN1: return("Month");
       case PERIOD_W1:  return("Week");
     }
     return "";
}  

Greetings mate, this worked for me and it showed only close prices. The KEY DIFFERENCE is the NAME OF THE CURRENCY. In my script, I changed it to "EURUSD." since that is how my broker names it on my MT4. Hope this helps.

Best Regards,

Lord Odin

 
Lord Odin:

Greetings mate, this worked for me and it showed only close prices. The KEY DIFFERENCE is the NAME OF THE CURRENCY. In my script, I changed it to "EURUSD." since that is how my broker names it on my MT4. Hope this helps.

Best Regards,

Lord Odin


hey Lord

wow thank you so much!! i will test it.

Reason: