- March 24, 2014
- Posted by: Forex Wiki Team
- Category: Expert Advisor
Name: |
|
||
Author: | komposter (2008.01.28 12:01) | ||
Rating: | 7 | ||
Downloaded: | 5142 | ||
Download: |
|
||
The Expert Advisor collects tick history for specified symbols into csv-files. The file name is formed from the security name and current date ("Symbol_Year.Month.csv"). The files are saved in the directory "path_to_terminal\experts\files\[Ticks]\Server name\". External variables:
File examples: 2006.06.21 11:14:39;1.2634 2006.06.21 11:14:48;1.2633 2006.06.21 11:14:50;1.2634 2006.06.21 11:14:52;1.2633 --------------------------Connection lost 2006.06.21 11:18:13;1.2634 2006.06.21 11:18:23;1.2633 2006.06.21 11:18:29;1.2634 2006.06.21 11:18:37;1.2633 2006.06.21 04:06:15;1.2618 2006.06.21 04:06:36;1.2617 2006.06.21 04:06:38;1.2618 2006.06.21 04:06:41;1.2617 2006.06.21 04:06:42;1.2618 --------------------------Expert was stoped 2006.06.21 08:18:22;1.2618 2006.06.21 08:18:27;1.2619 2006.06.21 08:18:31;1.2618 2006.06.21 08:18:31;1.2619 2006.06.21 08:18:32;1.2621 |
|||
thk for share,.but why it only works on the symbol EURUSD, and it does not work on another chart?
03.12.2011 07:20 sponsca
Unfortunately depending on currency you put this EA on it has potential to loose lots of ticks of other currencies. I solved that problem by putting my EA on each currency I want to record, it gives much more reliable recording. //+------------------------------------------------------------------+ //|                                        Tick_recorder_v2.mq4      | //|                                                                  | //|                                                                  | //+------------------------------------------------------------------+ #property copyright "Jake" #property link      "" #property show_inputs extern  string realfolder="real"; extern  string testfolder="test"; int        fh; datetime    lasttime; double      volume,lastvolume; //+------------------------------------------------------------------+ //| expert initialization function                                  | //+------------------------------------------------------------------+ int init() { //----   if(StringLen(StringTrimRight(realfolder))==0)realfolder="real";   if(StringLen(StringTrimRight(testfolder))==0)testfolder="test";   lasttime=StrToTime(TimeYear(TimeCurrent()-DayOfWeek()*60*60*24)+"."+TimeMonth(TimeCurrent()-DayOfWeek()*60*60*24)+"."+TimeDay(TimeCurrent()-DayOfWeek()*60*60*24));   if(IsTesting())   {       fh=FileOpen(file_name()+"_ticks.tic",FILE_WRITE|FILE_BIN);       FileClose(fh);   }   fh=FileOpen(file_name()+"_ticks.tic",FILE_WRITE|FILE_READ|FILE_BIN);   if(fh==-1) {Print("cannot open file");return(-1);}   bool b=FileSeek(fh,0,SEEK_END);   lastvolume=Volume[0]; //----   return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function                                | //+------------------------------------------------------------------+ int deinit()   { //----   FileFlush(fh);   FileClose(fh);      //----   return(0);   } //+------------------------------------------------------------------+ //| expert start function                                            | //+------------------------------------------------------------------+ int start() {   if(fh==-1) {Print("no file");return(-1);}   datetime currenttime=StrToTime(TimeYear(TimeCurrent()-DayOfWeek()*60*60*24)+"."+TimeMonth(TimeCurrent()-DayOfWeek()*60*60*24)   +"."+TimeDay(TimeCurrent()-DayOfWeek()*60*60*24));   if(lasttime<currenttime)   {       lasttime=currenttime;       FileFlush(fh);       FileClose(fh);       if(IsTesting())       {         fh=FileOpen(file_name()+"_ticks.tic",FILE_WRITE|FILE_BIN);         FileClose(fh);       }       fh=FileOpen(file_name()+"_ticks.tic",FILE_WRITE|FILE_READ|FILE_BIN);   }        //----   if(lastvolume>Volume[0])   {       lastvolume=Volume[0];       volume=Volume[0];   }   else   {       volume=Volume[0]-lastvolume;       lastvolume=Volume[0];   }   if(volume==0)volume=1;   int k=FileWriteInteger(fh,TimeCurrent());   int l=FileWriteDouble(fh,Bid);   int m=FileWriteDouble(fh,Ask);   int n=FileWriteDouble(fh,volume); //----   return(0); } string file_name() {   int day1,month1;   string year=TimeYear(lasttime);   month1=TimeMonth(lasttime);   if(month1<10)string month="0"+month1; else month=month1;   day1=TimeDay(lasttime);   if(day1<10)string day="0"+day1; else day=day1;   string filename=(Symbol()+StringTrimRight("\\ ")+year+StringTrimRight("\\ ")+Symbol()+year+month+day);   if(IsTesting())   {       filename=StringTrimRight(testfolder+"\\ ")+filename;   }   else   {       filename=StringTrimRight(realfolder+"\\ ")+filename;   }   return(filename); } //+------------------------------------------------------------------+ 23.11.2010 10:21 Jake2701
Hi komposter, Thanks for your TickSave code. It appears to work fine under Windows XP, but not under Vista. There, I think it would need some rights to create the directories and files. Could you adapt the code for Vista? Also, I would like to have some volume information. However, I think MT4 does not provide volumes at the tick level. Is this correct? Is there a way around, perhaps? Thank you & regards, Andrei 13.04.2009 13:48 acimponeriu
Works perfect for me, you might want to check under your install folder, it will be in \experts\files\[Ticks]
19.03.2008 06:40 Nudge
This is a great idea, unfortunately, I can't get it to do anything! Maybe something wrong with the code or with the way I installed it, but its not creating any .csv files anywhere on my pc.
|