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

 
Vitaly Muzichenko:

Use the button to insert code!

Thanks))) Now I will know))) I indicated in which place an error occurs during compilation
double Price;                                                               // Цена выбранного ордера
  double Mas[];                                                                //массив для упорядочивания всех ордеров
  for(int i=0; i<OrdersTotal(); i++)                                           // Цикл перебора ордер
   {
    if(OrderSelect(i,SELECT_BY_POS))                                           // Если есть следующий
     {
      Price=OrderOpenPrice();                                                    //Заполняем массив ценами
      Mas[i] = Price;
     }
   }
  
          ArraySort (Mas,WHOLE_ARRAY,0,MODE_ASCEND);                           // Теперь цены открытия упорядочены по убыванию
          
        int Blizko1=ArrayBsearch(Mas,Bid,WHOLE_ARRAY,0,MODE_ASCEND);           //Определен индекс ближайшего меньшего по значению елемента к текущей цене
        double PriceBlizko1=Mas[Blizko1];
     
     }  
      if (PriceBlizko1-Ask>=30*Point)                          //Если верхний ордер дальше чем 30 пунктов !!!! 'PriceBlizko1' - undeclared identifier!!!!!

       {OrderSend(Symbol(),OP_BUY,LtsB,Ask,2,0,Bid+30*Point);      //Открываем ордер Бай
               Alert (GetLastError());                                    //Сообщение об ошибке
Strange because PriceBlizko1 is described in the line above
 

What, no one uses indicators from ClusterDelta?

 
vikzip:
Thank you))) I will now know))) I have indicated in what place gives an error at compilation
Strange because PriceBlizko1 is described in the line above

It is described exactly in the line above. It needs to be defined globally so that it is available to all units, not just the local(current) one

 
voron_026:

Doesn't anyone use indicators from ClusterDelta?

Read objects and take data from them:ObjectGetDouble

Документация по MQL5: Графические объекты / ObjectGetDouble
Документация по MQL5: Графические объекты / ObjectGetDouble
  • www.mql5.com
2. Возвращает true или false в зависимости от успешности выполнения функции.  В случае успеха значение свойства помещается в приемную переменную, передаваемую по ссылке последним параметром. [in]  Модификатор указанного свойства. Для первого варианта по умолчанию значение модификатора равно 0. Большинство свойств не требуют модификатора...
 
Vitaly Muzichenko:

It is described exactly in the line above. It needs to be defined globally, so that it is available to all units, not just the local(current) one


Thank you)

 

Seems to have finished writing the EA, but an error pops up

')' - not all control paths return a value

What can it be related to. I tried to put return, the error changes

'return' - the function must return a value


possible use of uninitialized variable 'Ticket'
possible use of uninitialized variable 'LtsB'
possible use of uninitialized variable 'LtsS'
'return' - function must return a value
1 error(s), 3 warning(s)

Как самому создать советника или индикатор - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
Как самому создать советника или индикатор - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
  • www.metatrader5.com
Для разработки торговых систем в платформу встроен собственный язык программирования MetaQuotes Language 5 (MQL5), среда разработки MetaEditor и инструменты тестирования стратегий. Любую информацию о разработке торговых стратегий на языке MQL5 можно найти на официальном сайте MQL5.community. На этом же сайте в разделе Code Base могут быть...
 
vikzip:

Seems to have finished writing the EA, but an error pops up

')' - not all control paths return a value

What can it be related to. I tried putting return, the error changes

The 'return' - the function must return a value


Maybe the function mustreturn(0);

 
Vitaly Muzichenko:

Maybe areturn(0) like this is needed;


AAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH !!!! Thanks!!!

 
vikzip:

AAAAAAAA HOORAY!!!! Thank you!!!

Why "thank you"? The function should return a value. And you always return zero. If it is supposed to return nothing, its type should be void.

 
Artyom Trishkin:

In mql4, mql5 an array is always passed to a function by reference only (& == ampersand)

First - in formal parameters of a function, there is an ampersand, and it indicates that it's not the array itself that is passed into the function, but a reference to it. And then - inside the function - you are already working with the reference, which means that you don't have to specify it again.

The tilde (~) precedes the name of the class destructor - the constructor and destructor have the same name as the class itself, but the destructor has ~.

Read this article about when to use references and when to use pointers.

Although, you still need to read the basics.

Thank you!