invalid fileflush/file close

 
handle = FileOpen("Forex_EUR_USD.csv",FILE_CSV|FILE_WRITE, ';');
if (handle>0)
{
FileWrite(handle, ticket_six, OrderClosePrice(), Close[0], GetLastError(), OrderCloseTime());
FileFlush(handle);
FileClose(handle);

}



this is coming up with these warnings on the experts tab...


2008.11.20 10:27:57 testea: invalid handle 0 in FileClose

2008.11.20 10:27:57 testea: invalid handle 0 in FileFlush



2008.11.20 10:27:56 testea: handle 1 does not exist in FileClose

2008.11.20 10:27:56 testea: handle 1 does not exist in FileFlush

2008.11.20 10:27:56 testea: handle 1 does not exist in FileWrite



it will make on entry into the file correctly then start showing these errors. I have this same code in four spots in the ea, 2 for opening positions and 2 for closing.


edit-i think i found out why i was getting those errors, i had not placed the openfile correctly in a couple of spots. however, it seems that now it will not write more than one entry in the file, it seems to over lap each previous entry. any ideas why?





 

fwiw -

put in some prints to see what handle is.

Print("i am here..., handle=",handle);

.

IF have same code all over place... why?

better use one function do job - any data that diff, you could use parameters. at least that way, all file o/p in one spot only and much easier to debug etc. ie, you got 4 spots of same code = 4 spots u gotta maintain every time u make mod = pain-in-the-rear :)

ie, if only one file then just open once, write many, close once

.

ok, u not agree? but unless see ALL real code and the sequences of wat goes on, is hard to make accurate reply

Best2 U

 

I copied your code and launched. No problem.

Show the whole code.