Data Collection script Need some help - page 2

 

Hey you were right, sorry. I think me opening the files to view them for duplicate and updates actually made some of them stop updating. I didnt think to just watch the "date modified" of the files at first :D

I have just one last question. Can I leave this running over the weekend or will i have to stop it and restart on sunday market open?

Thanks again man you're a life saver!

 
It should be fine to leave over the weekend, since it only updates when there is a new bar to write. The only downside is that you'll be using cpu for nothing, so it would be better to come up with a function to determine if it's the weekend and how long till the markets open again, then set the program to sleep for that amount of time, but that's not really required.
 
Hey heelflip,
I finally got around to building the server gig this week and also brushed up on my SQL skills. I'd really love to make this wonderful script you wrote be able to write the data to an SQL database. I already figured out all the implementation details all thats left is to insert the following function into wherever it would normally write to the file:

ExecuteScalar("INSERT INTO [FOREX Data].[dbo].["+nameData+"]([Date],[Time],[High],[Low],[Close],[Open],[Volume]) VALUES (" +TimeToStr(iTime(symbol,TF,1), TIME_DATE)+ ", "+TimeToStr(iTime(symbol,TF,1), TIME_SECONDS)+", "+iHigh(symbol,TF,1)+", "+iLow(symbol,TF,1)+", "+iClose(symbol,TF,1)+", "+iOpen(symbol,TF,1)+", "+iVolume(symbol,TF,1)+";", 
                      "Provider=SQLOLEDB.1;User ID=sa; Password=********;Persist Security Info=True; Data Source=(local)\SQLEXPRESS;Initial Catalog=FOREX Data;" ); 

I tried to modify your script by replacing all the content enclosed in the following if statement with just the ExecuteScalar function above (whereas before you had put all the FileWriting details in there.)

if (GlobalVariableGet(symb_array[i]+timeframe_array[j]+"bars") != iBars(symb_array[i],StrToInteger(timeframe_array[j]))-1)      // if a new bar is received 

{

      ExecuteScalar("INSERT INTO [FOREX Data].[dbo].["+nameData+"]([Date],[Time],[High],[Low],[Close],[Open],[Volume]) VALUES (" + 
                    TimeToStr(iTime(symbol,TF,1), TIME_DATE) + ", "+TimeToStr(iTime(symbol,TF,1), TIME_SECONDS)+", "+iHigh(symbol,TF,1)+", "+iLow(symbol,TF,1)+
                    ", "+iClose(symbol,TF,1)+", "+iOpen(symbol,TF,1)+", "+iVolume(symbol,TF,1)+";", "Provider=SQLOLEDB.1;User ID=sa; Password=********;Persist Security Info=True; 
                                    Data Source=(local)\SQLEXPRESS;Initial Catalog=FOREX Data;" ); 
}  

However, this did not work, its doesnt seem to be writing to db. If its not too much would you be able to look back at this script you wrote and see if my modification actually derailed its writing/timing logic? I tried my best to follow the MQL and make the replacement (from file writing to database writing) as prudently as I can but it seems its not working. If you say my replacement is correct then I'll know I did something wrong in the implementation of ExecuteScalar rather than just an improper placement of the function within the script.

Thanks so much once more. Happy holiday season and a prosperous New Year to you and your family.

heelflip43:
It should be fine to leave over the weekend, since it only updates when there is a new bar to write. The only downside is that you'll be using cpu for nothing, so it would be better to come up with a function to determine if it's the weekend and how long till the markets open again, then set the program to sleep for that amount of time, but that's not really required.
 
Hey sorry for the late reply, been off the forums for a while. I've never come across ExecuteScalar before but i'm having a quick look now. One thing I could suggest is put the SQL into a separate string then Print that string and copy and paste into your database manager such as phpMyAdmin (I code in php) then see if it works correctly.
Reason: