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

 
lil_lil:

Thank you, the values there are from a file and one time, but my task is spread out over time.

Record the current price and time at the beginning of each day for 30 minutes, every 120 seconds.

Do not overwrite previous entries.


Start writing your code and what doesn't work, we'll take it apart.

So what's there to write? Take any day and read the opening price of even or odd minutes PERIOD_M1...
 
lil_lil:

Thank you, the values there are from a file and one time and I have a task that stretches over time.

Record the current price and time at the start of each day for 30 minutes, every 120 seconds

Do not overwrite previous entries.

This is what I wrote once. Use OnTimer instead of OnTick.

#property strict
enum Локаль   // Десятичный разделитель для отображения в Excel
{
  Точка,
  Запятая
};
extern Локаль   RUS = Запятая; // Для русской локализации запятую

string ИмяФайла;          // Имя файла на диске


void OnInit()
{
  ИмяФайла=Symbol()+".txt";
}


void OnTick()
{
   string Текст, Строка;

   // Открытие или создание файла и перемещение указателя в конец
   int Файл = FileOpen(ИмяФайла, FILE_CSV | FILE_READ | FILE_WRITE, " ");
   if(Файл == -1)
   {
      Alert("Ошибка при открытии файла ", ИмяФайла);
      return;
   }
   FileSeek(Файл, 0, SEEK_END);

   // Если новый файл записать строку заголовков колонок
   if(FileSize(Файл)==0)FileWrite(Файл, "           Время   ASK     BID");

   // Сбор информации и запись в файл
   FileWrite(Файл,
             TimeToStr(Time[0]),
             dstr(Ask),
             dstr(Bid) );
   FileClose(Файл);
   Файл = 0;                 // Заметая следы обнулим указатель
}


// Преобразование числа double в строку с запятой или точкой в соответствии с локализацией
string dstr(double Цена)
{
  if(!RUS) return DoubleToStr(Цена, Digits);
  return StringSetChar(DoubleToStr(Цена, Digits), StringFind(DoubleToStr(Цена, Digits), "."), ',');
}
 
Alexey Viktorov:

Start writing your code and what doesn't work, we'll take it apart.

Writes Janv 51

/********************Script program start function*******************/
void OnStart()
{
if(iVolume(0,PERIOD_D1,0)>=1)
  {
  int file_1;
   file_1=FileOpen("prise.csv",FILE_CSV|FILE_WRITE);
   if(file_1!=-1) 
     {
      FileWriteString(file_1,Bid,StringLen(Bid));
      FileClose(file_1);
     }
    }
   }
}/*******************************************************************/
 
STARIJ:

Here's something I used to write. Use OnTimer instead of OnTick.

Thanks

 
Hello. Can you please tell me ifafter activatingthe virtual server it is possible to close the mt4 site? Will the virtual server work or how does it work?
 
lil_lil:

Writes Jan 51

This is a problem with Excell. Put a dot instead of a comma as the separator between integer part and fractional part in the settings and it will show correctly.
 
Alexey Viktorov:
This is a problem with Excell. Put a dot instead of a comma in the settings to separate the integer part from the fractional part and it will show correctly.

Writes and how to make it write every 120 seconds within 30 minutes of the bar opening?

 
Good day! Please help me to improve copier code. The problem is the following: EA (Slave) prints the message about no access to the file, no matter what I do... What's wrong?

Decompiled by Artyom Trishkin

Note to you.

 
lil_lil:

Writes and how do I make it write every 120 seconds within 30 minutes of the bar opening?

EventSetTimer

 
Konstantin Nikitin:

EventSetTimer

Does it not work in the scripts?