The problem I would see is how do you know when the process writing the file is not still writing the file when the EA tries to open it ?
RaptorUK:
The problem I would see is how do you know when the process writing the file is not still writing the file when the EA tries to open it ?
The problem I would see is how do you know when the process writing the file is not still writing the file when the EA tries to open it ?
ok, how aboout deleting the file, & new file instanceis created.
MMB:
ok, how about having a FLAG to indicate the file is written?
MMB: ok, how about having a FLAG to indicate the file is written?
// ----------------------------------------------------------------------------------------------------------------------------- void InitNews(string& news[][],int timeZone, string newsUrl) { if(DoFileDownLoad()) //Added to check if the CSV file already exists { DownLoadWebPageToFile(newsUrl); //downloading the CSV file lastUpdate=TimeCurrent(); } if(CsvNewsFileToArray(news) == 0) return(0); NormalizeNewsData(news,timeZone); } // ----------------------------------------------------------------------------------------------------------------------------- bool DoFileDownLoad() // If we have recent file don't download again { int handle; datetime time = TimeCurrent(); handle=FileOpen(NewsFileName(), FILE_READ); //commando to open the file if(handle>0)//when the file exists we read data { FileClose(handle);//close it again check is done if(time >= lastUpdate+update_interval*60)return(true); return(false);//file exists no need to download again } // File does not exist if FileOpen return -1 or if GetLastError = ERR_CANNOT_OPEN_FILE (4103) return(true); //commando true to download CSV file }look to the code of
|
MMB:
The way I have seen this done in the past is that the writing application writes the file with filnename of filex and when the file is complete it renames it to filey, the application reading the file will only look for filey so will only see the file when it is complete. this is only of help to you if you have control of the application that is writing the file.
ok, how aboout deleting the file, & new file instanceis created.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi All,
I am looking for for help to see if this scenerio can be achieved in an ExpertAdvisor :
1. I have a text file(input_to_MT4.CSV) lets say: BUY,EURUSD,1.0,MAGICNUMBER001 //{Action,symbol,lot,orderIdentifier}
2. The ExpertAdvisor should:
Loop
{
A. Read the File
B. If there is contents in the file : Execute the action [BUY,EURUSD,1.0,MAGICNUMBER001]
C. Delete the Line in the file (input_to_MT4.CSV)
}
3. After some time, the file (input_to_MT4.CSV) will have new data Say (CLOSE,EURUSD,1.0,MAGICNUMBER001 )
Can this be done?I would appreciate any inputs and help.
Thanks
Tom