Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-17-2007, 11:41 AM
Junior Member
 
Join Date: Dec 2006
Posts: 13
Flirrrt is on a distinguished road
Problem with FileWrite etc..

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:

Code:
 if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
         {
         
         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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-17-2007, 01:37 PM
sg1 sg1 is offline
Banned
 
Join Date: Jun 2006
Posts: 16
sg1 is on a distinguished road
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

Last edited by sg1; 05-17-2007 at 01:42 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-17-2007, 03:24 PM
Junior Member
 
Join Date: Dec 2006
Posts: 13
Flirrrt is on a distinguished road
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:

Code:
 void WriteToFile()
        {
         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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-17-2007, 05:05 PM
zupcon's Avatar
Senior Member
 
Join Date: Dec 2005
Location: Malta
Posts: 201
zupcon is on a distinguished road
Quote:
Originally Posted by Flirrrt

Do you know what causes the problem?

/Johan
Code looks OK,

does it create a file, but the file is empty ?, if so sure that you dont already have the file open in excel, or any other editor, as that can cause problems.

regards
zu
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-17-2007, 06:32 PM
Junior Member
 
Join Date: Dec 2006
Posts: 13
Flirrrt is on a distinguished road
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: Isn't start() supposed to run on every tick?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with .ex4................. EFX General Discussion 4 10-21-2006 07:23 AM
problem with EVERY #MTF indicators iGoR Indicators - Metatrader 4 10 08-16-2006 06:07 AM
Backtesting Problem juanchoc Expert Advisors - Metatrader 4 3 05-23-2006 03:26 PM
My First EA problem demag Questions 4 02-10-2006 08:18 AM
I've a Problem here hellkas Metatrader 4 6 11-04-2005 12:30 AM


All times are GMT. The time now is 10:46 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.