Doda Dochian export data to excel

 

Hi,

This time, I try to export Doda Dochia level to Excel for a list of date recorded in date.txt file.

There are 5 parameters in the inputs menu of this indicator and I listed in the "extern int" below.

The output file create only value 0.000 for the Doda Dochia variable.

Could you please help me with that?

Thank you so much.

HHC 

 

extern string datefeed = "date.txt";

extern string doda = "Doda-Dochian_1";



extern int     ChannelPeriod = 28;

extern int     EMAperiod = 120;

extern int     StartEMAshift=6;

extern int     EndEMAshift=0;

extern int     angletreshold=0.32;



//+------------------------------------------------------------------+

//| script program start function                                    |

//+------------------------------------------------------------------+

int start()

{

  //------------------------------------------------------------------

  string file = Symbol() + "_" + GetTimeFrameName(0) + ".csv";

  int log = FileOpen(file, FILE_CSV|FILE_WRITE, ";");

  int log2 = FileOpen(datefeed, FILE_CSV|FILE_READ, ";");

  if (log < 0 || log2 < 0) return (0); 

  string buffer, buff;

  buffer = "Rate;TimeFrame;Date;Hour_Minute;Open;Close;High;Low;Up/Down";



  buffer = buffer + ";Doda";

  FileWrite(log, buffer);

  buff = "";

  int i = 0;

  while (!FileIsEnding(log2))

  {

    i++;

    buff = FileReadString(log2);

    if (buff == "") continue;

    datetime time = StrToTime(buff);

    int bar = iBarShift(NULL, 0, time);

    buffer = Symbol() + ";" + GetTimeFrameName(0) + ";" + TimeToStr(Time[bar], TIME_DATE) + ";" + TimeToStr(Time[bar], TIME_MINUTES)

           + ";" + DoubleToStr(Open[bar], Digits) + ";" + DoubleToStr(Close[bar], Digits) + ";" + DoubleToStr(High[bar], Digits) + ";" + DoubleToStr(Low[bar], Digits);

    if (Close[bar] > Open[bar]) buffer = buffer + ";1";

    else if (Close[bar] < Open[bar]) buffer = buffer + ";2";

    else buffer = buffer + ";0";

    buffer = buffer + ";" + DoubleToStr(getdoda( ChannelPeriod, EMAperiod, StartEMAshift, EndEMAshift, angletreshold, bar), Digits);

      

    FileWrite(log, buffer);

  }

  FileClose(log);

  FileClose(log2);

  MessageBox("Finished writing " + i + " rows into " + TerminalPath() + "\\experts\\files\\" + file);

  //------------------------------------------------------------------

  return(0);

}

//+--------define function----------------------------------------------------------+



double getdoda(int ChannelPeriod, int EMAperiod, int StartEMAshift, int EndEMAshift, int angletreshold, int shift)

{

double x= iCustom(NULL, 0,doda,   ChannelPeriod, EMAperiod, StartEMAshift, EndEMAshift, angletreshold,  shift);

return (x);



}

//+------------------------------------------------------------------+

string GetTimeFrameName(int TimeFrame)

{

  switch (TimeFrame)

  {

    case PERIOD_M1: return("M1");

    case PERIOD_M5: return("M5");

    case PERIOD_M15: return("M15");

    case PERIOD_M30: return("M30");

    case PERIOD_H1: return("H1");

    case PERIOD_H4: return("H4");

    case PERIOD_D1: return("D1");

    case PERIOD_W1: return("W1");

    case PERIOD_MN1: return("MN1");

    case 0: return(GetTimeFrameName(Period()));

  }

}

//+------------------------------------------------------------------+
Files:
 
scfx:

Hi,

This time, I try to export Doda Dochia level to Excel for a list of date recorded in date.txt file.

There are 5 parameters in the inputs menu of this indicator and I listed in the "extern int" below.

The output file create only value 0.000 for the Doda Dochia variable.

Could you please help me with that?

Your iCustom() call looks wrong,  you have included all the extern parameters but what buffer are you looking to get data from ?

double x= iCustom(NULL, 0,doda,   ChannelPeriod, EMAperiod, StartEMAshift, EndEMAshift, angletreshold,      shift);
 

Hi RapterUK,

I try all mode from 0 to 7 but the results are the same 0.0000.

Could you help me to find out the error?

 Thank you,

 HHC 

    buffer = buffer + ";" + DoubleToStr(getdoda( ChannelPeriod, EMAperiod, StartEMAshift, EndEMAshift, angletreshold,2, bar), Digits);
    
      
    FileWrite(log, buffer);
  }
  FileClose(log);
  FileClose(log2);
  MessageBox("Finished writing " + i + " rows into " + TerminalPath() + "\\experts\\files\\" + file);
  //------------------------------------------------------------------
  return(0);
}
//+--------define function----------------------------------------------------------+

double getdoda(int ChannelPeriod, int EMAperiod, int StartEMAshift, int EndEMAshift, int angletreshold, int mode, int shift)
{
double x= iCustom(NULL, 0,doda,   ChannelPeriod, EMAperiod, StartEMAshift, EndEMAshift, angletreshold, 2,  shift);
return (x);

}
 
scfx:

Hi RapterUK,

I try all mode from 0 to 7 but the results are the same 0.0000.

Could you help me to find out the error?

 Thank you,

 HHC 

Do you see anything wrong in this list of inputs ?

extern int     ChannelPeriod = 28;

extern int     EMAperiod = 120;

extern int     StartEMAshift = 6;

extern int     EndEMAshift = 0;

extern int     angletreshold = 0.32;
 
RaptorUK:

Do you see anything wrong in this list of inputs ?

 


Yes, I think I see it, didn't I? 

Thank you, Raptor UK.

But still error somewhere else.

Please help.

HHC 

extern int     ChannelPeriod = 28;

extern int     EMAperiod = 120;

extern int     StartEMAshift = 6;

extern double  EndEMAshift = 0;

extern double  angletreshold = 0.32;
 
scfx:


Yes, I think I see it, didn't I? 

Thank you, Raptor UK.

But still error somewhere else.

Please help.

A clue . . 

double getdoda(int ChannelPeriod, int EMAperiod, int StartEMAshift, int EndEMAshift,    int angletreshold,    int mode, int shift)
{
double x= iCustom(NULL, 0,doda,   ChannelPeriod, EMAperiod, StartEMAshift, EndEMAshift, angletreshold, 2,  shift);
return (x);

}
 
RaptorUK:

A clue . . 

 

Hi RaptorUK,

Is that what you mean?

I already change all systematically but no work.

extern string doda = "Doda-Dochian_1";
extern int     ChannelPeriod = 28;
extern int     EMAperiod = 120;
extern int     StartEMAshift=6;
extern double    EndEMAshift=0;
extern double     angletreshold=0.32;

buffer = buffer + ";" + DoubleToStr(getdoda(ChannelPeriod, EMAperiod, StartEMAshift, EndEMAshift, angletreshold,4, bar), Digits);
double getdoda(int ChannelPeriod, int EMAperiod, int StartEMAshift, double EndEMAshift, double angletreshold,int mode, int shift)
{
double x= iCustom(NULL, 0,doda,   ChannelPeriod, EMAperiod, StartEMAshift, EndEMAshift, angletreshold, mode,  shift);

return (x);
 
scfx:

Hi RaptorUK,

Is that what you mean?

I already change all systematically but no work.

Put this Indicator on a chart, look at the inputs,  they are all ints except the last,  that is the first key bit of information you need to keep in mind,  next open the Date Window and move your cursor along the bars from bar 0 to the left,  you will see that not all buffers have values for all bars . . .  so if you read some buffers where there are no values you may get 0.0 or EMPTY_VALUE.

Fix your code,  pass the correct values or the correct type.  Learn about the Indicator you are trying to use . . . 

Reason: