Download MetaTrader 5

my loop that writes to file stops working after a fiew hours

To add comments, please log in or register
How to use MQL5.community messages editor? Find out in the article!
Daniel Sic
1123
Daniel Sic 2015.03.17 08:26 
hi.

I need some help or clerefiance why my indicator does not work all around the clock. 

I have made a small indicator that is writing to a file every four minute. and I have a chrome extenssion that is reading this file. it works but after a fiew hours It stops working. 

this is how it's done. 
the Indicator is using OnTimer() event and have made the file write function (bool) that returns FileWriteStrings (%s...) 

when my timer is >4 minute it uses this function to write to the file. 
it's acctully tells my chrome extenssion to do a login on a website. but after a fiew hours it stops working. 

the timer tho is still running as it should because I have a Print that tells me when timer is > 4 and resets counting. 

Now. When this error occures I have tried to run the same file write function that I also have in a script and when I run the script it works (writes to file)..

I wounder why my indicator stops doing this after a couple of hours. is there some buffer that gets filled up? 

when I restart Metatrader it works again. 
any idies why this is? 
Stuart Browne
5794
Stuart Browne 2015.03.17 08:30  

Hi

Without providing the code, it's going to be a little difficult for anyone to provide meaningful help  .

Cheers

Daniel Sic
1123
Daniel Sic 2015.03.17 09:10  
Filter:

Hi

Without providing the code, it's going to be a little difficult for anyone to provide meaningful help  .

Cheers

the function looks like this

bool login(string url, string username, string password){
string file = "\\\\.\\pipe\\pipe11"; int file1 = FileOpen(file, FILE_WRITE|FILE_BIN); if (file1 == INVALID_HANDLE) { return false;
}
return FileWriteString(file1, StringFormat("%s,%s,%s,%s\r\n", "login", url, username, password));
}

now if I run this function over and over again its will stop work at some point of time (the loops is still going tho)

I haven't got the whole code on me right now but I don't think it's matter because I know that the loop is still going on and on but this function will stop working a fiew hours after I start the loop.

Any suggestions what may cause it to stop working or if I should write the fuction in another way
Alain Verleyen
Moderator
30704
Alain Verleyen 2015.03.20 17:48  

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


Alain Verleyen
Moderator
30704
Alain Verleyen 2015.03.20 17:48  
slicken:

the function looks like this


now if I run this function over and over again its will stop work at some point of time (the loops is still going tho)

I haven't got the whole code on me right now but I don't think it's matter because I know that the loop is still going on and on but this function will stop working a fiew hours after I start the loop.

Any suggestions what may cause it to stop working or if I should write the fuction in another way
You need to use FileClose() at some point.
To add comments, please log in or register