4100: ERR_SOME_FILE_ERROR

 

I got this error in my code and I'm really not sure how to proceed. It is really some file error, after all. :)


The culprit seems to be in this part of the code:

                        if(TimeStamp != iTime(SymbolArray[i],Periods[PeriodIndex], 0) ){    //this conditon should be met on the first start() iteration

                                TimeStamp = iTime(SymbolArray[i],Periods[PeriodIndex], 0);

                                LastTickString = MakeInfoString(SymbolArray[i],Periods[PeriodIndex] ,0);
                                if( FileWrite(Handle, LastTickString)< 0 )                     
                                  Print("Error in NewBar section FileWrite(): " + GetLastError() );   //"Some file error" here. lol.
                                
                        }       

LOG:
2013.09.09 02:28:14	WriteAllChartsToCSV USDJPY.,H1: Error in NewBar section FileWrite(): 4100         (same error over and over)

Also, the full code is attached for your perusal.


Any advice would be most appreciate...

 
BenLinus:


I got this error in my code and I'm really not sure how to proceed. It is really some file error, after all. :)


The culprit seems to be in this part of the code:

Also, the full code is attached for your perusal.


Any advice would be most appreciate...

Where do you have MT4 installed ? https://www.mql5.com/en/forum/140698
 
RaptorUK:
Where do you have MT4 installed ? https://www.mql5.com/en/forum/140698


In Program files. I tried installing in c:\MT Installs\ but that didn't help. I still got the same error.


Even tried another broker in c:\MT Installs\, and same error 4100.

 
Is there a way to get some more information about the error. "Some File Error" is not a very informative description.
 

Update:

I disabled init(), since it works fine. I want to deal with only start() for now.

When I change the code to make it handle only the first period of the first symbol, like so:

for(int i =0; i< 1; i++){                       //for one symbol


                for(int PeriodIndex=0; PeriodIndex<1 ; PeriodIndex++ ){ 
                      blah blah...


First start(): it creates the file (provided it is not there) and it writes the correct line in the first loop.

Second start(): Error 4100

Third start():Error 4100

...so on and so forth


?!


Btw, the files are being closed before exiting start().

 
BenLinus:
Is there a way to get some more information about the error. "Some File Error" is not a very informative description.
OK, let me see if I understand what you are doing . . . . for each tick you are trying to write to 168 files on my Terminal . . . the first run of start() should write the current values for bar 0, to do that shouldn't you seek to the end of the file ? I added this and your, modified, code now locks up my Terminal . . . wouldn't this be more suited to an EA ?
 
RaptorUK:
OK, let me see if I understand what you are doing . . . . for each tick you are trying to write to 168 files on my Terminal . . . the first run of start() should write the current values for bar 0, to do that shouldn't you seek to the end of the file ? I added this and your, modified, code now locks up my Terminal . . . wouldn't this be more suited to an EA ?

OK, as an EA there are no reported errors and the Terminal does not lock up . . . the updates per tick do not update but add to the end of the file, I assume your seek is wrong.

Your check for new bar can't work . . .

//----------Check for new bar -----------||
if(TimeStamp != iTime(SymbolArray[i],Periods[PeriodIndex], 0) ){    //this conditon should be met on the first start() iteration

. . . you need a TimeStamp for each symbol and timeframe

 
One other thing, when you first call this stuff for a Symbol and timeframe you haven't accessed recently you are going to get a CSV file full of zeros, if you want to avoid this you will need to check for error 4066 and wait for the data to arrive from your Broker. Search the forum for 4066 you will find a few recent posts.
 
RaptorUK:
OK, let me see if I understand what you are doing . . . . for each tick you are trying to write to 168 files on my Terminal . . . the first run of start() should write the current values for bar 0, to do that shouldn't you seek to the end of the file ? I added this and your, modified, code now locks up my Terminal . . . wouldn't this be more suited to an EA ?


Thanks for checking RaptorUK.

I neglected to get back to the end of file after GetLastLine(), which returns the pointer to where it was -- I guess the beginning. After I seeked to the end, it seems to work fine as an indicator in my terminal. There are no reported errors -- except if the files are not there and it tries to delete them (minor thing).


In init(): It prints 2000 lines per timeframe per symbol.

in start(): it reads the last line in each file, and decide if it should replace it or print a new line.


I'm not sure why it behaves differently as an EA.


It is not giving me the error 4100, but there is still a bug in start (). I will post in another thread.

 
RaptorUK:

OK, as an EA there are no reported errors and the Terminal does not lock up . . . the updates per tick do not update but add to the end of the file, I assume your seek is wrong.

Your check for new bar can't work . . .

. . . you need a TimeStamp for each symbol and timeframe


I think that is taken care of when I read the last line in the text and extract the timestamp
 
RaptorUK:
One other thing, when you first call this stuff for a Symbol and timeframe you haven't accessed recently you are going to get a CSV file full of zeros, if you want to avoid this you will need to check for error 4066 and wait for the data to arrive from your Broker. Search the forum for 4066 you will find a few recent posts.

Thanks,. I'll keep that in mind.
Reason: