ZigZag_to_File

Author: Copyright � 2010, �������� �������
Miscellaneous
Uses files from the file systemIt issuies visual alerts to the screenIt writes information to file
0 Views
0 Downloads
0 Favorites
ZigZag_to_File
//+------------------------------------------------------------------+
//|                                               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;
extern string Delimiter = ";";
extern bool isLocal_RU = true;

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, Delimiter);
   if(Handle == -1){
      Alert("Îøèáêà ïðè îòêðûòèè ôàéëà ", File_name + ".csv");
   }else{
      FileWrite(Handle,"Time;Open;High;Low;Close;ZigZag Date");
   }
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start(){
   double date;
   int status;
   for(int shift = 0; shift <= Bars-1; shift++){
      date = iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, shift);
      if(date > 0){
         if(isLocal_RU){
            status = FileWrite(
               Handle,
               TimeToStr(Time[shift]),
               StringSetChar(DoubleToStr(Open[shift], Digits), StringFind(DoubleToStr(Open[shift], Digits), "."), ','),
               StringSetChar(DoubleToStr(High[shift], Digits), StringFind(DoubleToStr(High[shift], Digits), "."), ','),
               StringSetChar(DoubleToStr(Low[shift], Digits), StringFind(DoubleToStr(Low[shift], Digits), "."), ','),
               StringSetChar(DoubleToStr(Close[shift], Digits), StringFind(DoubleToStr(Close[shift], Digits), "."), ','),
               StringSetChar(DoubleToStr(date, Digits), StringFind(DoubleToStr(date, Digits), "."), ',')
            );
         }else{
            FileWrite(Handle,TimeToStr(Time[shift]),Open[shift],Close[shift],Low[shift],High[shift],date);
         }
         if(!isAllZigZagDate)break;
      }else{
         continue;
      }
   }
   if(status > 0)Alert("Äàííûå óñïåøíî çàïèñàíû. \nÌåñòî ñîõðàíåíèÿ - \n", TerminalPath(), "\\experts\\files\\", File_name, ".csv \nÑêðèïò çàâåðøèë ðàáîòó.");
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit(){
   FileClose(Handle);
}
//+------------------------------------------------------------------+
//| end                                                              |
//+------------------------------------------------------------------+



Comments