Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1117

 
Top2n:

//--- путь к файлу
   string path=InpDirectoryName+"//"+InpFileName;
//--- откроем файл
   ResetLastError();
   int file_handle=FileOpen(path,FILE_READ|FILE_BIN);
   if(file_handle!=INVALID_HANDLE)
     {
      //--- прочитаем все данные из файла в массив
      FileReadArray(file_handle,arr);
      //--- получим размер массива
      int size=ArraySize(arr);
      //--- распечатаем данные из массива
         Print(" = ",arr[0][0]," = ",arr[1][1]," = ",arr[2][2]);
      Print("Total data = ",size);
      //--- закрываем файл
      FileClose(file_handle);
     }
   else
      Print("File open failed, error ",GetLastError());
2017.01.09 17:20:40.609 TorFid_v02 (EURUSD,H1)  = 0.0  = 0.0  = 0.0
2017.01.09 17:20:40.609 TorFid_v02 (EURUSD,H1)  Total data = 1020100

I understand what's missing, the reverse conversion to a 2D array, but I don't understand how

Unless, of course, I saved it correctly.

for(int z=1; z<=ARRAY_SIZE_Y; z++) // Перебор по барам, колонка Y
        {
         for(int q=1; q<ARRAY_SIZE_X-1; q++) // Перебор по периоду, колонка X
           {
            arr[q][z]=NormalizeDouble(sm.d[q+1].m[nBar-z],5);                // M(I) SMA
           }
        }
      WriteData(1000);
//+------------------------------------------------------------------+
//| Запись n элементов массива в файл                                |
//+------------------------------------------------------------------+
void WriteData(const int n)
  {
//--- откроем файл
   ResetLastError();
   int handle=FileOpen(path,FILE_READ|FILE_WRITE|FILE_BIN);
   if(handle!=INVALID_HANDLE)
     {
      //--- запишем данные массива в конец файла
      FileSeek(handle,0,SEEK_END);
      FileWriteArray(handle,arr,0,n);
      //--- закрываем файл
      FileClose(handle);
     }
   else
      Print("Failed to open the file, error ",GetLastError());
  }

I hope those lines are present, too.

//--- входные параметры
input string InpFileName="data.bin";
input string InpDirectoryName="SomeFolder";

Start with an easy one. Write the whole thing into scripts. One to write the file and one to read and print what you read. For writing, make a simple 2x2 array

int arr[2][2];

void OnStart()
{
int z = 0;
for(int i = 0; i < 2; i++)
  {
   arr[i][z] = i+z+1;
    z++;
  }
WriteData();
}

and remove the number of elements you want to write. This way the whole file will be written from start to finish. Check if the file appears in the given path.

void WriteData() // здесь

FileWriteArray(handle,arr); // и здесь
Then read and print what you see. If you see 1 and 3, there is a problem with the array.
 
Top2n:

Here's what you get.

Write script code.

//+------------------------------------------------------------------+
//|                                                   WriteArray.mq5 |
//|                                                         Viktorov |
//|                                                v4forex@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "Viktorov"
#property link      "v4forex@yandex.ru"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
string InpFileName = "data.bin";
string InpDirectoryName = "SomeFolder";  
string path=InpDirectoryName+"//"+InpFileName;
int arr[3][3];
int handle;
void OnStart()
{
int i = 0, z = 0;
for(i = 0; i < 3; i++)
  {
   for(z = 0; z < 3; z++)
    {
     arr[i][z] = i*z+1;
    }
  }
  WriteData();
}
//+------------------------------------------------------------------+
void WriteData()
  {
//--- откроем файл
   ResetLastError();
   handle=FileOpen(path, FILE_READ|FILE_WRITE|FILE_BIN);
   if(handle!=INVALID_HANDLE)
     {
      //--- запишем данные массива в конец файла
      FileSeek(handle,0,SEEK_END);
      FileWriteArray(handle,arr);
      //--- закрываем файл
      FileClose(handle);
     }
   else
      Print("Failed to open the file, error ",GetLastError());
  }

Read script code.

//+------------------------------------------------------------------+
//|                                                    ReadArray.mq5 |
//|                                                         Viktorov |
//|                                                v4forex@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "Viktorov"
#property link      "v4forex@yandex.ru"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
string InpFileName = "data.bin";
string InpDirectoryName = "SomeFolder";  
string path=InpDirectoryName+"//"+InpFileName;
int handle;
void OnStart()
{
int arr[3][3];
int i = 0, z = 0;
handle = FileOpen(path, FILE_READ|FILE_WRITE|FILE_BIN);
FileReadArray(handle, arr);
for(i = 0; i < 3; i++)
  {
   for(z = 0; z < 3; z++)
    {
     Print("arr[", i, "][", z, "]", arr[i][z]);
    }
  }
}
//+------------------------------------------------------------------+

and this is what's printed.

2017.01.09 12:46:22.979 ReadArray (EURUSD,M1)   arr[0][0]1
2017.01.09 12:46:22.979 ReadArray (EURUSD,M1)   arr[0][1]1
2017.01.09 12:46:22.979 ReadArray (EURUSD,M1)   arr[0][2]1
2017.01.09 12:46:22.979 ReadArray (EURUSD,M1)   arr[1][0]1
2017.01.09 12:46:22.979 ReadArray (EURUSD,M1)   arr[1][1]2
2017.01.09 12:46:22.979 ReadArray (EURUSD,M1)   arr[1][2]3
2017.01.09 12:46:22.979 ReadArray (EURUSD,M1)   arr[2][0]1
2017.01.09 12:46:22.979 ReadArray (EURUSD,M1)   arr[2][1]3
2017.01.09 12:46:22.979 ReadArray (EURUSD,M1)   arr[2][2]5

So you don't need any conversion gimmicks. You only need to set the same arrays from the beginning.

Don't mind that it's mql5, the same way it would work in mql4.

 
Alexey Viktorov:
Then read and print out what you got. If you see 1 and 3 it means the problem is in filling the array.

Honestly don't even know what happened, but it all worked, I just have to add a line every new bar, hopefully there won't be any questions)))

Thank you!

 

Hi all!!! Please advise me, I want to download a clean MT4, but can not find anywhere, from the off site pumps only MT5. Please give me the latest build. Thanks a lot!!!

 
stepan.brend:

Hi all!!! Please advise me, I want to download a clean MT4, but can not find anywhere, from the off site pumps only MT5. Please give me the latest build. Thanks a lot!!!

You can download any favourite brokerage company and get the latest version. The only difference is the logo in the shortcut.
 
Vitaly Muzichenko:
Your only difference is the logo in the shortcut.
The problem is that the market is not working, I can't install any utility on MT4. Please advise what to do) You really need to install the utility
 
stepan.brend:
The problem is that the market is not working, I can't install any utility on MT4. Please advise what to do) Really need to install the utility
Open an account in another brokerage company. Or other type of account. The presence or absence of a marketplace depends entirely on the account.
 
Vitalie Postolache:
Open an account in another brokerage company. Or another type of account. Whether or not a marketplace is available depends entirely on the account
Vitalie Postolache:
Open an account in another brokerage company. Or another type of account. If the market does not work, it depends on the account.

Tried three DCs and different accounts, the market still doesn't work(

 
stepan.brendTried three DCs and different accounts, the market still doesn't work (
There is no miracle. What is the version of the terminal? I've seen accounts with no signals tab, but most have market.
 
  FileReadArray(file_handle,arr);

Please advise on possible developments.

I have array[100], also saved binary file with size [1000], how to return array of binary file last 100 values. Is there anything universal? I've been working on this again for 12 hours and nothing.

Reason: