| New signals service! | |
|
|||||||
| 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 |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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);
}}
Am I on the right track, or is my code really fucked up? Thanks in advance, Johan |
|
|||
|
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. |
|
|||
|
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);
}
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: Isn't start() supposed to run on every tick? |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
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 |