remember many variables after log off of computer, pls help!

 

Dear all

If I have 90 variables in an array[3,10,3] (each variable has 6 digits) that I want EA to remember after I log off my computer, apart from adding globalvariable one by one, is there any other method that is more efficient to do it?

Would anyone like to help? (I'm not asking for code, but method only)

Thank you.

 
wing:

Dear all

If I have 90 variables in an array[3,10,3] (each variable has 6 digits) that I want EA to remember after I log off my computer, apart from adding globalvariable one by one, is there any other method that is more efficient to do it?

Would anyone like to help? (I'm not asking for code, but method only)

Thank you.

Hi wing,

I never try FileReadArray() and FileWriteArray(), I think it's only for 1 dimension array, but you can try now. Please reply back if it fails to your expectation.

 

Dear onewithzachy

I've checked from web and find multi dimension array works with these two functions (my code is shown below).

But it seems something in my code is not correct, during backtesting, it kept showing me the following two lines after each new data was added:

"1 parameter for ArrayRange function must be array"

"range of array (spd_array,0) is -1"


Also, at the start of report, it shows:

"2 parameter for FileReadArray function must be array"

and, at the end of report, it shows:

"2 parameter for FileWriteArray function must be array"

What's that means?

On the other hand, does arrayrange show total number of elements inside an array? why does MT4 return "-1" from my checking line?

"Print("range of array (spd_array) is "+ArrayRange(spd_array,0));"

int count1[3,11,3];
string spd_array;
int handle;

int init()

   handle = FileOpen("spd_array", FILE_BIN|FILE_READ|FILE_WRITE);

   if( handle < 0 )
   {
      Print(Symbol()+", No data stored in the array, start from beginning!");
   }
   else
   {
      FileReadArray(handle, spd_array, 0, 3*11*3);
      Print("range of array (spd_array) is "+ArrayRange(spd_array,0));
      FileClose(handle);
   }

int deinit()

   handle = FileOpen("spd_array", FILE_BIN|FILE_READ|FILE_WRITE);

   if( handle < 0 )
   { Print("File (spd_array) not found, the last error is ", GetLastError()); }
   else
   {
      FileWriteArray(handle, spd_array, 0, 3*11*3);
      FileClose(handle);
   }

int start()

   << calculation and store data into spd_array >>

   Print("range of array (spd_array,0) is "+ArrayRange(spd_array,0);
 
wing:

Dear onewithzachy

I've checked from web and find multi dimension array works with these two functions (my code is shown below).

But it seems something in my code is not correct, during backtesting, it kept showing me the following two lines after each new data was added:

"1 parameter for ArrayRange function must be array"

"range of array (spd_array,0) is -1"

Your array is count1 . . .

int count1[3,11,3];

spd_array is a string and not an array . . .

string spd_array;
 

finally done!

thank you all!

Reason: