Quang Tran:
Hello everyone!
I'm trying to make my EA to get data from online CSV file and write down to a local file, but it worked wrongly. The destination file is only saved with the word "FALSE" inside as data, even i tried some other function to write data.
So, please! anyone can help me to show my mistakes in the codes below: (result file is attached below)
Thank you all!
Try this code.
void OnStart() { //--- string cookie = NULL, headers; char post[], result[]; int res; int timeout = 5000; string URL = "http://fbgfx.pro/fbgfx.pro/fbgfxcopier/Orders.csv"; ResetLastError(); res = WebRequest("GET", URL, cookie, NULL, 500, post, 0, result, headers); if(res == -1) { Print("Error in WebRequest. Error code =", GetLastError()); MessageBox("Add the address '" + URL + "' in the list of allowed URLs on tab 'Expert Advisors'", "Error", MB_ICONINFORMATION); } else { PrintFormat("The file has been successfully loaded, File size =%d bytes.", ArraySize(result)); string csv = CharArrayToString(result); //--- Save the data to a file int handle = FileOpen("Orders.csv", FILE_READ | FILE_WRITE | FILE_TXT | FILE_ANSI); //--- Checking errors if(handle != INVALID_HANDLE) { FileWriteString(handle, csv); //--- Close the file FileClose(handle); } else Print("Error in FileOpen. Error code=", GetLastError()); } }
Nagisa Unada:
Try this code.
Thank everyone!
It worked
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hello everyone!
I'm trying to make my EA to get data from online CSV file and write down to a local file, but it worked wrongly. The destination file is only saved with the word "FALSE" inside as data, even i tried some other function to write data.
So, please! anyone can help me to show my mistakes in the codes below: (result file is attached below)
Thank you all!