MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
No Time to Follow the Markets? Use Trading Signals!

Too Many Files Opened.

Back to topics list To post a new topic, please log in or register
avatar
59
ForexSurfr 2012.02.04 18:49
 

Can someone help me with the below code? The problem I am having is that I am getting the error code "Too Many Files Opened". What doesn't make sense to me is that I have the FileOpen and FileClose on the outer block of code. Shouldn't the while be working properly?

//+------------------------------------------------------------------+
//|                                             CheckModeling#12.mq4 |
//|                                               mcertini@gmail.com |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+

extern string FileName1 = "EURUSD#1.txt";
extern string FileName2 = "EURUSD#2.txt";
extern string FileName3 = "EURUSD#3.txt";
extern string FileName4 = "EURUSD#4.txt";

extern string TextToAppend1 = "";
extern string TextToAppend2 = "1";

int count;

int handle1 = 0;
//handle1 = FileOpen(FileName1,FILE_CSV|FILE_READ|FILE_WRITE);

int start()
   {
   handle1 = FileOpen(FileName1,FILE_CSV|FILE_READ|FILE_WRITE);
   while(count < 10000000000)
      { 
      //handle1 = FileOpen(FileName1,FILE_CSV|FILE_READ|FILE_WRITE);
      if(count <= 2000000000000)
         {
         FileSeek(handle1,0,SEEK_END);
         FileWrite(handle1,count);
         FileFlush(handle1);
         }
      count = count + 1;
      Print(count);
      return(0);
      //FileClose(handle1);
      }      
   FileClose(handle1);   
   }
   

   

Attached files:
  checkmodelingr12.mq4  (1.19 KB)
 
MQL4 Language for Newbies. Custom Indicators (Part 2)
This is the fifth article from the series "MQL4 Languages for Newbies". Today we will learn to use graphical objects - a very powerful development tool that allows to widen substantially possibilities of using indicators. Besides, they can be used in scripts and Expert Advisors. We will learn to create objects, change their parameters, check errors. Of course, I cannot describe in details all objects - there are a lot of them. But you will get all necessary knowledge to be able to study them yourself. This article also contains a step-by-step guide-example of creating a complex signal indicator. At that, many parameters will be adjustable which will make it possible to change easily the appearance of the indicator.
avatar
14179
RaptorUK 2012.02.04 18:55 #
 
You Return before you close the file . . . . then on the next tick open the file again, etc, etc
avatar
59
ForexSurfr 2012.02.04 19:02 #
 
RaptorUK:
You Return before you close the file . . . . then on the next tick open the file again, etc, etc


Ah, I see.

Thanks.

Back to topics list  

To add comments, please log in or register