I'm having trouble using File Read/Write functions in MT4.
In order to test these functions, i wrote the following code which tries to read an array from file A.csv and then write back the values into file B.csv.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I'm having trouble using File Read/Write functions in MT4.
In order to test these functions, i wrote the following code which tries to read an array from file A.csv and then write back the values into file B.csv.
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
double profit[10];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int handle;
handle = FileOpen("A.csv", FILE_CSV|FILE_READ,",");
if(handle<1)
{
Print("A.csv not found");
return(false);
}
if(handle > 0)
{
FileReadArray(handle, profit, 0, 10);
FileClose(handle);
}
int handle2;
handle2 = FileOpen("B.csv",FILE_CSV|FILE_WRITE,",");
FileWriteArray(handle2, profit, 0, 10);
}
//+------------------------------------------------------------------+
No luck so far ...
Any help would be highly appreciated.
Thanks
Bob
ps: A.csv is created manually in the expert/files folder and contains 10 values