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

 
Can someone please share their thoughts on my topic: https://www.mql5.com/ru/forum/320451?
Код не работает, как ожидалось.
Код не работает, как ожидалось.
  • 2019.08.20
  • www.mql5.com
Я не понимаю, что не так с моим кодом. Посмотрите и дайте мне знать. Клещи не меняются...
 

How do I get the number of Fibonacci levels?

I build them using classes from the standard library:

   CChartObjectFibo *fibo=new CChartObjectFibo();
   if(!fibo.Create(0,name,0,first_time,first_price,second_time,second_price))
     {
      Print(__FUNCTION__+": Fibonacci create failed. Bar #",start_bar,". Error: ",GetLastError());
      return false;
     }
   int levels_count=fibo.LevelsCount();

well, levels_count is always 0

 
leonerd:

How do I get the number of Fibonacci levels?

I build them using classes from the standard library:

well, levels_count is always 0

There are no levels when creating fibo. Once created, the number of levels is set and values, descriptions and other object properties are assigned.

 

Can you tell me, is it possible to use static fields in classes in MQL? I want a weird one, like this:

// ...

int OnInit()
  {
//---
  A::test();
//---
   return(INIT_SUCCEEDED);
  }

//...

class A{
   public:
      static int t;
 
      A(){};
      ~A(){};
      static void test(){
         if(Is_Works){
            Print (t); // unresolved static variable 'AA::t'
         }
      }
};

It's clear that I can create an instance of a class inside a method, but I want it without instances... Is it possible?
 
Oleh Fedorov:

Can you tell me, is it possible to use static fields in classes in MQL? I want a weird one, like this:

It's clear that I can create an instance of a class inside a method, but I want it without instances... Is it possible?
Документация по MQL5: Основы языка / Объектно-ориентированное программирование / Статические члены класса
Документация по MQL5: Основы языка / Объектно-ориентированное программирование / Статические члены класса
  • www.mql5.com
Члены класса могут быть объявлены с использованием модификатора класса памяти static. Такие члены данных разделяются всеми экземплярами данного класса и хранятся в одном месте. Нестатические члены данных создаются для каждой переменной-объекта класса. Отсутствие возможности объявлять статически члены класса привело бы к необходимости объявлять...
 
Artyom, thank you, that helped... Although it's... Not intuitive :-) To be not just initialised, but also declared... I've reread the section a couple of times before, then some more - now, and thought for a long time about the difference between my code and the reference one :-)
 
Is there any way for the EA to know the end date of testing?

For example, I set in the tester that the EA should be tested from 20.07.2019 to 20.08.2019.

Can I somehow write in the EA code to make it know this date20.08.2019 ? The end date of testing.

So that it finds this out at the beginning of the test, in the OnInit function, or at the beginning of the OnTick function.
 
Good evening .Maybe someone already has or has tried to make or has a link to a ready made Fibo extension tool with vertical lines.
 
Hello. Can you advise me on this point... Push notifications come normally to the phone only when the screen is on and when it's charging. But should turn off the screen, and after some time (not immediately!) messages are not delivered. I mean, I turn on the screen and only then see a bunch of notifications from the EA.

Phone: Samsung SM-G955F Galaxy S8 Plus,Android 9 Pie.
Terminal: MT4, Build 1170, Windows 10.

p.s. The problem has nothing to do with saving power on the phone or disabling wifi in sleep mode or anything like that. Checked all settings and modes with advice on profile forums. For example, messages from messengers are coming normally.

What can be done?

Скачайте мобильное приложение MetaTrader 5 для Android
Скачайте мобильное приложение MetaTrader 5 для Android
  • www.metatrader5.com
Мобильный трейдинг с MetaTrader 5 для Android — это возможность торговать валютой, акциями и фьючерсами при помощи смартфонов и планшетов. Где бы вы ни были, вы можете подключаться к серверам брокерских компаний, анализировать котировки акций и валют и совершать торговые сделки. Все это — бесплатно и круглосуточно! MetaTrader 5 для Android...
 
Darirunu:
Good evening .Maybe someone already has or has tried to make or has a link to a ready made Fibo extension tool with vertical lines.

Show a screenshot - it's not clear what you wish for.

Reason: