Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1248

 
Sergey:

Good afternoon !

I'm trying to figure out the code of the indicator. Stuck on one line.

What does the last line mean and how can it be rewritten in a simpler (clearer) way ?

It's described normally in the documentation.

Документация по MQL5: Основы языка / Операторы / Условный оператор ?:
Документация по MQL5: Основы языка / Операторы / Условный оператор ?:
  • www.mql5.com
В качестве первого операнда – "выражение1" – может быть использовано любое выражение, результатом которого является значение типа bool. Если результат равен , то выполняется третий операнд – "выражениеЗ". Второй и третий операнды, то есть "выражение2" и "выражениеЗ", должны возвращать значения одного типа и не должны иметь тип void. Результатом...
 
Vitaly Muzichenko:

It is written much more simply than any other construction. It's called: the ternary operator

I've shown you the code conditionally, I hope you'll get the hang of it

Thank you for the clarification.

 

Hello all!

I am continuing to study MQL5 programming language. My idea of functions, commands, variables, arrays and all the like described above has gradually turned from Chinese hieroglyphs into Chinese characters, and I have some idea what they are for, but I have not mastered their use yet.

At this stage I have made a detailed requirements for writing a simple Expert Advisor. Using the MQL5 Wizard I created an EA template and started to fill it gradually with code. I commented on each line of the code so that it was gradually saved in my memory.

Today I have faced one problem: I have created a csv file in the local folder of the client terminal \Terminal\Common\Files. In cell A1 of this file I manually wrote down the word "buy". Then, according to the technical requirements, the Expert Advisor needs to somehow indicate that it should read this word, convert it to something digestible and understandable in the form of programming code, understand what it needs and only then open theBUY position.

I cannot find and write such keywords in search engine of MQL5 site to get links to necessary articles or examples.

Please, help me, not with some ready-made code, because I'll never understand the MQL5 language, but with keywords for search! What to write, how to formulate a request for a search engine?

Regards, Vladimir.

Знакомство с MQL5: написание простого советника и индикатора
Знакомство с MQL5: написание простого советника и индикатора
  • www.mql5.com
Язык программирования MetaQuotes Language 5 (MQL5), входящий в торговый терминал MetaTrader 5, обладает новыми возможностями и более высоким быстродействием, по сравнению с языком MetaQuotes Language 4 (MQL4). Эта статья поможет познакомиться с новым языком программирования. В ней приведен пример написания простого советника и индикатора, также...
 
MrBrooklin:

Hello all!

I am continuing to study MQL5 programming language. My idea of functions, commands, variables, arrays and all the like described above has gradually turned from Chinese hieroglyphs into Chinese characters, and I have some idea what they are for, but I have not mastered their use yet.

At this stage I have made a detailed requirements for writing a simple Expert Advisor. Using the MQL5 Wizard I created an EA template and started to fill it gradually with code. I commented on each line of the code so that it was gradually saved in my memory.

Today I have faced one problem: I have created a csv file in the local folder of the client terminal \Terminal\Common\Files. In cell A1 of this file I manually wrote down the word "buy". Then, according to the technical requirements, the Expert Advisor needs to somehow indicate that it should read this word, convert it to something digestible and understandable in the form of programming code, understand what it needs and only then open theBUY position.

I cannot find and write such keywords in search engine of MQL5 site to get links to necessary articles or examples.

Please, help me, not with some ready-made code, because I'll never understand the MQL5 language, but with keywords for search! What to write, how to formulate a request for a search engine?

Sincerely, Vladimir.

You have to read the orders from the trading file) it's not a simple one from the very beginning. Search work with files first article. And the third, but it's more complicated.

Working with files

Поиск - MQL5.community
Поиск - MQL5.community
  • www.mql5.com
Поиск выполняется с учетом морфологии и без учета регистра. Все буквы, независимо от того, как они введены, будут рассматриваться как строчные. По умолчанию наш поиск показывает страницы...
 
Valeriy Yastremskiy:

Straight from the trading orders file) it's not a simple one already initially. Search work with files is the first article. And the third, but it's more complicated.

Working with files

Thanks, Valery, for the tip, but it turned out for some reason in a truncated form: search for "Working with files" is the first article, then "bang!" and immediately the third. And what should be the second article and the third - what is it actually about? Could you elaborate?

I'm already studying the "Working with files" article.

Regards, Vladimir.

 
MrBrooklin:

Thank you, Valery, for the advice, but for some reason it came out in a truncated form: searching for "Working with files" is the first article, then "bang!" and immediately the third. And what should be the second article and the third - what is it actually about? Could you elaborate?

I'm already studying the "Working with files" article.

Sincerely, Vladimir.

You may search not only by article but also by forum, kodobase and blogs. I do not know how to rank them. Both articles and forum threads with a search query appear in the search results. Now apparently work on the site and it often behaves inadequately. I have

https://www.mql5.com/ru/articles/2720 the first article of 2016 by Dmitry Fedoseyev. It should be read.

https://www.mql5.com/ru/articles/1382 The third article is from 2006 on MT4, about working with files and graphical objects, and it's not superfluous to read the logic.

The second one is about optimization management, it's frankly still early days.

Основы программирования на MQL5: Файлы
Основы программирования на MQL5: Файлы
  • www.mql5.com
Функции для работы с файлами есть почти во всех языках программирования, и MQL5 в этом смысле — не исключение. Хотя при программировании советников и индикаторов на MQL5 работать с использованием файлов приходится не всегда, (а скорее даже — очень редко), но тем не менее, каждый экспертописатель рано или поздно с этим сталкивается. Диапазон...
 
Valeriy Yastremskiy:

Not only articles are searched, but also forums, kodobase and blogs. The ranking does not know how. Both articles and forum threads with a search query appear in the search results. Now apparently work on the site and it often behaves inadequately. I have

https://www.mql5.com/ru/articles/2720 the first article of 2016 by Dmitry Fedoseyev. It should be read.

https://www.mql5.com/ru/articles/1382 The third article is from 2006 on MT4, about working with files and graphical objects, and it's not superfluous to read the logic.

The second one is about optimization management, it's frankly still early.

Thanks, Valery! I am already studying the first article of 2016 by Dmitry Fedoseyev. The third article is for MT4, while I have MT5, but I'll read it anyway. Everything is clear with the second article.

Regards, Vladimir.

 

Good day everyone!

I'm continuing my study of MQL5. I tried to build an EA that would read from cell A1 in EUR_USD.csv the word"buy" and open BUY position. The compiler shows no errors, which is good for me. When being launched, the Expert Advisor refers to the file, that's for sure. But it does not open a position. I understand that the problem lies exactly in this part of the code. I have blocked one line because I do not know whether it is necessary or not. However, the Expert Advisor opens no BUY position both with or without it.

Please give my advice on what I am doing wrong, not through code but by pointing in the direction of what I should add or correct. Maybe, I have mistranslated something in the comments, causing me confusion?

Sincerely, Vladimir.

void OnTimer() // функция, вызываемая при наступлении события Timer (генерируется системным таймером, в скриптах не применяется!)
  {

   filehandle=FileOpen("EUR_USD.csv",FILE_READ|FILE_SHARE_READ|FILE_CSV|FILE_COMMON); // открываем файл для чтения
   if(filehandle!=INVALID_HANDLE) // если указатель файла не равен константе "некорректный указатель"
     {
      FileSeek(filehandle,0,SEEK_SET); // перемещаем файловый указатель в начало файла
     }
   FileClose(filehandle); // закрываем файл
     {
      string open = FileReadString(filehandle);  // читаем из файла строку с текущего положения файлового указателя
      if(open == "покупать") // если значение строки равно "покупать"

         //         if(PositionSelect(_Symbol)) // выбираем позицию на текущем графике (символе)
        {
         Type_Pos=EnumToString((ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE)); // определяем тип позиции, BUY или SELL
         PositionGetDouble(POSITION_VOLUME,Volume); // определяем объём
        }
        {
         if(Type=="POSITION_TYPE_BUY") // если тип позиции "BUY"
           {
            OpenBuy(Volume*Lots); // открываем позицию "BUY", с объемом расчитанным по формуле
            return;
           }
         else // в противном случае
           {
            OpenSell(Volume*Lots); // открываем позицию "SELL", с объемом расчитанным по формуле
            return; // оператор, который прекращает выполнение текущей функции и возвращает управление вызвавшей программе
           }
        }
     }
 
How can I programmatically determine which version of windows is installed?
 
mrgabdullin:
How can the software determine which version of windows is installed?

Why and why Windows and not another system?