An advisor without an indicator. Is this possible? - page 9

 
Nikolai Semko:

Why do you get a new bar onthe SeriesInfoInteger?
As far as I remember - it's a very slow asynchronous function (maybe something has changed - I haven't checked).
As a rule all inconsistencies and slowness is a consequence of using asynchronous functions. Avoid them if possible.
Try to use them in some other way. For example via iTime or iBars.
And don't forget that OnChartEvent itself is asynchronous and cannot be called more than 64 times per second, i.e. at most once per 15.625 milliseconds.

new bar via SERIES_LASTBAR_DATE

And don't forget that OnChartEvent itself is asynchronous and cannot be called more than 64 times per second, i.e. at most once per 15.625 milliseconds.

as they say in china, no matter how purple, as long as it's profitable

 
Dmitry Fedoseev:

how naive...

Dimitri, can I get a reference?

 
Fast235:

new bar via SERIES_LASTBAR_DATE

SERIES_LASTBAR_DATE is only the ID used in the SeriesInfoInteger.

 
Fast235:

Dimitri, can I get a recommendation?

What is it? I already gave one and I'll repeat it - if you don't know how to write indicators, don't claim that they don't work correctly or that the approach with indicators in general is bad, wrong, irrational.

 
Nikolai Semko:

SERIES_LASTBAR_DATE is only the Identifier used in the SeriesInfoInteger.


if(id>=CHARTEVENT_CUSTOM) // Цикл событий по символам
     {
      static CNewBar M1;
      const int number=id-CHARTEVENT_CUSTOM; //приведем в нормальный вид номер символа 0-7
      //--- проверим новый ли бар
      if(M1.NewBar(number,PERIOD_M1))
 
//+------------------------------------------------------------------+
//| Class Новый бар                                                  |
//+------------------------------------------------------------------+
class CNewBar
  {
protected:
   datetime          oldTime[TRADE_SYMBOLS];
public:
   bool              NewBar(int number,ENUM_TIMEFRAMES timeframe)
     {
      //--- создаем переменную newtime(тип время), присваиваем в нее из функции SeriesInfoInteger дату открытия последнего бара
      datetime newTime=datetime(SeriesInfoInteger(Symbols[number],timeframe,SERIES_LASTBAR_DATE));
      if(newTime!=oldTime[number] && newTime) // проверка на появление нового бара (новое время не равно старому и в newtime есть значение(true))
        {
         oldTime[number]=newTime; //обновим время прошлого бара
         return(true); // вернем функции NewBar true, появился новый бар
         //if(MQLInfoInteger(MQL_DEBUG))
         //   Print("Новый бар",newTime,"старый бар",oldTime); // в режиме отладки, будет выводится сообщение о значениях времен баров
        }
      //--- иначе,
      return(false); // нового бара еще нет
     };
   //---- конструктор класса
//                     CNewBar() {oldTime=NULL;}; // вызывается при создании Объекта, проинициализация тут не нужна, что-бы сразу прошел новый бар
  };
 
This is the NewBar - which means no more than one attempt is made.
 
Dmitry Fedoseev:
This NewBar means there is no more than one attempt.

it is not clear what is meant by

As you can see, the character number is correctly passed to the new bar class and is correctly handled there
 
Fast235:


if(id>=CHARTEVENT_CUSTOM) // Цикл событий по символам


What is this? What could it possibly have to do with a normal indicator? You're making things up instead of reading the articles and learning how to do things properly. That's why it's so naive - indicators "don't work properly". So creative as all get.

 
Fast235:

it is not clear what is meant by

And you won't. NewBar is a diagnosis.