[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 672

 

Six months ago someone posted a script to print zig-zag values (time and rate) to a CSV file to work in EXCEL. Now I can't find it. Maybe someone has it?

 
Richie:

Six months ago someone posted a script to print zig-zag values (time and rate) to a CSV file to work in EXCEL. Now I can't find it. Maybe someone has it?

Discussed here and here and also this indicator.

 

ToLik_SRGV, thanks, I've read these threads. There was a script. Missing apparently a branch or post.

 
Richie:

ToLik_SRGV, thanks, I've read these threads. There was a script. Missed apparently branch or post.


Sergei, sometimes it's easier to write a script yourself than to look for it :)))

//+------------------------------------------------------------------+
//|                                               ZigZag_to_File.mq4 |
//|                               Copyright © 2010, Анатолий Сергеев |
//|                                            mql.sergeev@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Анатолий Сергеев"
#property link      "mql.sergeev@yandex.ru"
#property show_inputs

extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
extern string File_name = "";
extern bool isAllZigZagDate = false;

int Handle;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init(){
   if(File_name == "")File_name = Symbol() + Period() + "_ZigZag_Date";

   Handle = FileOpen(File_name + ".csv",FILE_WRITE | FILE_CSV);
   if(Handle == -1){
      Alert("Ошибка при открытии файла ", File_name + ".csv");
   }else{
      FileWrite(Handle,"Time;Open;Close;Low;High;ZigZag Date");
   }
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start(){
   double date;

   for(int shift = 0; shift <= Bars-1; shift++){
      date = iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, shift);
      if(date > 0){
         FileWrite(Handle,TimeToStr(Time[shift]),Open[shift],Close[shift],Low[shift],High[shift],date);
         if(!isAllZigZagDate)break;
      }else{
         continue;
      }
   }
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit(){
   FileClose(Handle);
}
//+------------------------------------------------------------------+
//| end                                                              |
//+------------------------------------------------------------------+

The isAllZigZagDate parameter defines whether only the last ZigZag point should be written (by default) or all history.

P.S.
Shall I throw it into the codebase so that I won't have to search for it later?

 
ToLik_SRGV: Sergei, sometimes it's easier to write a script yourself than to search :))) Parameter isAllZigZagDate defines to write only last ZigZag's point (by default) or all history.P.S. To throw in a codebase not to search then or it is not necessary?


Thank you, Anatoly. That's right, it's faster to write it yourself than to find it. Thanks for the script. Better of course to throw in the codebase, too, maybe someone else will be needed. Otherwise, branches are disappearing :). I also wrote mine, or rather "assembled from what was:

#property show_inputs
extern string ext="txt";
extern int last_bar=1;
extern int bars=1000;
extern int ExtDepth=24;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
extern int Kol=100;

int i,j;
double zz;

int start()
{
int h=FileOpen(Symbol()+Period()+"."+ext+"",FILE_WRITE|FILE_CSV,",");
  for(i=0,j=0;i<Bars && j<Kol;i++)
  {
    zz=iCustom(NULL,0,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,i);
    if(zz!=0)
    {
      FileWrite(h,TimeToStr(Time[i],TIME_DATE),TimeToStr(Time[i],TIME_MINUTES),i,zz);
      j++;   
    }
  }
FileClose(h);
return(0);
}
Files:
savezz.mq4  1 kb
 
My EA displays information in a separate indicator window. How can I make the data in this window be updated immediately when the TF changes and not with the arrival of a new tick?
 
artmedia70:
My EA displays the information in a separate indicator window. How to make, that at change of TF the data in the window would be updated immediately, and not with the arrival of a new tick?


Write a call for refreshing the necessary data in init()

ZS: at the weekend I wrote a full code of quotation unloader in the init, it worked fine without ticks - it just looped the unloading on start and received data

 
artmedia70:
My EA displays information in a separate indicator window. How can I make the data in the window update immediately when the TF changes and not with the arrival of a new tick?

Using the WindowRedraw() function;

 
IgorM:


Write a call to update required data in init()

HH: at the weekend I wrote a full code of quotation unloader in the init, it worked fine without ticks - it just looped unloading on start and received data

I.e. I need to add in the init() of EA a call of function to output the information in the indicator window?
 
ToLik_SRGV:

Using the WindowRedraw() function;

I have this function in the empty indicator window. But the data is updated only on a new tick.

#property indicator_separate_window
#property indicator_minimum 1
#property indicator_maximum 10
 
bool initFinished=false;
// добавляем переменную, которая будет запоминать состояние инициализации.
// false - инициализации еще не было
// true - была
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{

   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   ObjectsDeleteAll();
   // удаляем все объекты
   
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   if(initFinished==false)
   {
      IndicatorShortName("Info");
 
      int winID=WindowFind("Info");
   
      if(winID<0)
      {
         // если номер подокна равен -1, то возникла ошибка
         Print("Чёт не могу твоего окошечка найти, пошел я отсюдова");
         return(0);
      }  
//------------------------ Тут можно рисовать ------------------------- 
 
// ----------------------- Но не нужно... ----------------

//------------------------------------------------------------------------- 
      WindowRedraw();      
            
      initFinished=true;
     
   }
   
   return(0);
}
Reason: