There are errors in your code.
Here's my code that adds to a file on every tick:
// Function WriteToFile ***********************
void WriteToFile(double val1, string str2)
{
int handle;
handle=FileOpen("Log.csv", FILE_CSV|FILE_WRITE|FILE_READ, '\t');
FileSeek(handle, 0, SEEK_END);
FileWrite(handle, TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS), DoubleToStr(val1, 4), str2);
FileClose(handle);
return(0);
}
//*********************************************
The file is saved to 'experts/files' folder
sg1
Thank you for your answer sg1, unfortunately I don't get it to work properly.
I combined your code with mine, and used it in an ea. The testing now takes a lot longer, so it's some data it's processing.. but i still get no file with the tickdata.
This is what the code looks like:
{
int handle;
handle=FileOpen("Breakout.csv",FILE_CSV|FILE_WRITE|FILE_READ,'\t');
FileSeek(handle, 0, SEEK_END);
FileWrite(handle,DoubleToStr(Bid, 4));
FileClose(handle);
}And then I just call in the start().
Do you know what causes the problem?
/Johan
Zupcon, it doesn't create a file at all.. and no, I don't have that file opened in excel (even if i've done that thing tons of times before :-))
I got the code working with some changes, but my next problem is that it wont re-run the code on every new tick being made..
See the other thread about that problem: https://www.mql5.com/en/forum/177044

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Trying to export tickdata during trades ONLY, for further analysis in excel:
I have written an ea, so when an position is taken, i want every tick or 1 minutebar-low to be exported inte an document.
I have never used the file-commands before, but I gave it a try:
{
int handle=FileOpen("Breakout-export.csv",FILE_WRITE|FILE_CSV,"\t");
if(handle>0){
// write header
FileWrite(handle,OrderSymbol(),OrderTicket(),Bid);
FileClose(handle);
}}The problem is that with this i don't get a file at all. I shuold be placed in the experts-folder, right?
Am I on the right track, or is my code really fucked up?
Thanks in advance,
Johan