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

 
How do I replace the Sleep(500) function in the indicator?
 
HeAic:
How to replace Sleep(500) function in the indicator?

by nothing, unfortunately... You cannot stop the flow of the indicator.

Revise the logic of the indicator...

 
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
  {
  }
void OnTick()
  {
    int fileHandle=FileOpen("logg.txt",FILE_WRITE|FILE_TXT|FILE_SHARE_READ|FILE_UNICODE); 
    FileWrite(fileHandle,"иии");
    FileClose(fileHandle);
  }
It only records one "eeee" while I need it to be completed with every tick. Where did I go wrong?
Основы тестирования в MetaTrader 5
Основы тестирования в MetaTrader 5
  • www.mql5.com
Идея автоматической торговли привлекательна тем, что торговый робот может без устали работать 24 часа в сутки и семь дней в неделю. Робот не знает усталости, сомнений и страха,  ему не ведомы психологические проблемы. Достаточно четко формализовать торговые правила и реализовать их в виде алгоритмов, и робот готов неустанно трудиться. Но прежде...
 
Folks, how do I add currency pairs to MT5? Only ruble pairs are available, others are not on the general list.
 
ascerdfg:
It only writes one "iii" while I need it to add a "iii" to each tick. Where did I go wrong?

Open the file in oninit, close it in deinit. That's how it works for me)))

 
ascerdfg:
It only records one "eeee" while I want it to be completed with every tick. Where did I go wrong?

Because the FILE_WRITE flag creates a NEW file each time it is opened. To be able to append something to existing file, it is necessary to open file for reading and writing.

 
Alexey Viktorov:

Because the FILE_WRITE flag creates a NEW file each time you open it. To be able to add something to an existing file, you must open the file for reading and writing.

Didn't notice, sorry....

 
I have a question. Somewhere the yuan to the dollar is traded, but it is either not present in MT5 or is only held by a broker for introductions and not for real trades.
 
Alexey Viktorov:

Because the FILE_WRITE flag creates a NEW file each time it is opened. To be able to add something to an existing file, you must open the file for reading and writing.

So it is FILE_SHARE_READ
 
ascerdfg:
So, it should be FILE_SHARE_READ

FILE_SHARE_READ

128

Shared read access by multiple programs. This flag is used when opening files (FileOpen()), but does not replace the need to specify FILE_WRITE and/or FILE_READ when opening a file

It does not. And in general, it's better not to open and close the file on every tick

It allows shared reads, not shared reads
Документация по MQL5: Файловые операции / FileOpen
Документация по MQL5: Файловые операции / FileOpen
  • www.mql5.com
[in]  Имя открываемого файла, может содержать подпапки. Если файл открывается для записи, то указанные подпапки будут созданы в случае их отсутствия. [in]  значение, используемое в качестве разделителя в txt или csv-файле. Если для csv-файла разделитель не указан, то по умолчанию используется символ табуляции. Если для txt-файла разделитель не...
Reason: