Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 400

 

Where did the libraries go? I lost my MT4 a long time ago, I downloaded a new MT4 and I can't figure out how to write the path to the library. I wrote functions there, not to rewrite them in a new EA, so the code would be shorter. For some reason I don't want to switch to MT5, it's not allowed to lock.

Please advise me, I am not an expert in writing this code.

 
ZZuretc:

Where did the libraries go? I lost my MT4 a long time ago, downloaded a new MT4 and cannot figure out how to write the path to the library. I wrote functions there, not to rewrite them in a new EA, so the code would be shorter. For some reason I do not want to switch to MT5, there is no locking there.

Please tell me, I'm not much of a speller.

I don't know if you are in lethargic sleep or in a coma, God forbid?

Hadge mt5 accounts have allowed locking for so long I can't remember.

Look up libraries over there.


 
Alexey Viktorov:

Were you by any chance in a lethargic sleep? Or, God forbid, in a coma?

Hadge mt5 accounts have allowed locking for so long I can't remember.

Check out the libraries over there.


How to write the path to the library in the Expert Advisor? I created the"Function" library, but I do not understand, give me a literacy, so it works (I was asleep)

 
ZZuretc:

How do I write the path to the library in the Expert Advisor? I created the"Function" library, but I don't understand the rest, can you give me a rundown on how to make it work (I was asleep)?

Type line #include, put the cursor on it and press F1 - help is well written

 

Can anyone advise where to get quotes for testing? The one in the terminal is not enough

 
RomanRott:

Can anyone advise where to get quotes for testing? The one in the terminal is not enough.

Try to adjust it here: Tools - Settings - Charts

In the left window it is necessary to set 450 000 = 60 minutes * 24 hours * 300 working days

 
STARIJ:

Try adjusting here: Service - Settings - Charts

Left box should be set to 450,000 = 60 minutes * 24 hours * 300 working days


Didn't work.

 
RomanRott:

Didn't work.

You didn't do it right. Reload the terminal after setting the number of history bars. And set there, for example, a million bars - you will have the history from the year one thousand nine hundred and seventy.

 

Help, who knows, please.

Is there any way in MQL4 to quickly reduce the size of a binary file?

Well, not to overwrite all data, but just to rearrange the end of the file a few bytes back, thus reducing its size by these few bytes. All information before the new end of the file is preserved, and everything beyond the new end of the file is excluded from it.

 
A.R.Wex:

Help, who knows, please.

Is there any way in MQL4 to quickly reduce the size of a binary file?

Well, not to overwrite all data, but just to rearrange the end of the file a few bytes back, thus reducing its size by these few bytes. All information before the new end of the file is preserved, and everything beyond the new end of the file is excluded from it.

Searched and searched... Seems only to overwrite the required number of bytes into the new file. Then delete the old one and rename the new one. There is also FileSeek function that allows to move pointer in the file to start writing new information from a certain place
//+----------------------------------------------------------+
//| Сокращение бинарного файла                               |
//+----------------------------------------------------------+
#property strict
int    fi, f2;
string st;

void start() 
{
   int n;
   Alert("------------");
   // Создание файла  1  4  9  16  25  36  49
   fi = FileOpen("AAA.bin",FILE_WRITE | FILE_BIN);
   for(n=1; n<=7; n++)   FileWriteInteger(fi,n*n);
   Alert("Размер файла = ", FileSize(fi));
   FileClose(fi);

   // Чтение файла
   Чтение();

   // Перезаписываем 2 последних числа
   fi = FileOpen("AAA.bin",FILE_READ | FILE_WRITE | FILE_BIN);
   FileSeek(fi,20,SEEK_SET);
   FileWriteInteger(fi,-11);
   FileWriteInteger(fi,-33);
   FileWriteInteger(fi,-99);
   FileClose(fi);

   Чтение();

   // Сокращение бинарного файла
   fi = FileOpen("AAA.bin",FILE_READ | FILE_WRITE | FILE_BIN);
   f2 = FileOpen("BBB.bin",FILE_READ | FILE_WRITE | FILE_BIN);
   // Переписываем 5 чисел из AAA.txt  в  BBB.txt
   for(n=0; n<5; n++) FileWriteInteger(f2,FileReadInteger(fi, INT_VALUE));
   FileClose(fi);
   FileClose(f2);
   Sleep(200);
   FileDelete("AAA.bin");
   Sleep(200);
   f2 = FileOpen("AAA.bin",FILE_READ | FILE_WRITE | FILE_BIN);
   fi = FileOpen("BBB.bin",FILE_READ | FILE_WRITE | FILE_BIN);
   // Переписываем 5 чисел из AAA.txt  в  BBB.txt
   for(n=0; n<5; n++) FileWriteInteger(f2,FileReadInteger(fi, INT_VALUE));
   FileClose(fi);
   FileClose(f2);
   Sleep(200);
   FileDelete("BBB.bin");
   Sleep(200);

   Чтение();
}


// Чтение файла
void Чтение()
{
   st="";   
   fi = FileOpen("AAA.bin",FILE_READ | FILE_BIN);
   while(!FileIsEnding(fi)) st+=(string)FileReadInteger(fi, INT_VALUE)+"  ";
   FileClose(fi);
   Alert(st);
}
Reason: