Mt4 End of support. - page 32

 
Vitaly Muzichenko:

Put it in, tested it, it doesn't work

It's always showing false.
Did it work for you or not yet?
 
Реter Konow:
You obviously do not know how to read codes. )) Where does she devour them?

in Karaganda.

 
Dmitry Fedoseev:

in karaganda

Is there any confusion? Maybe in Ulan-Ude?
 
George Merts:

I wonder if anyone really has that much?

I've got 16 - and I'm already wondering if it's too much of a load?

I have a minimum timeframe of M15... But still, I wonder when the load on the terminal starts to be critical ?

My client asks me to check and scan all symbols on the server at every tick. And there are not many, not few, but 10 230... That's where the problem lies...

 
Artyom Trishkin:

I have a customer asking me to check and scan on every tick all the characters on the server. And there are not many, not few, but 10,230... That's the problem...

I remember, there was a limit of the maximum number of symbols in the Market Watch window to 1024. Doesn't it exist now? Can I have 10 thousand?
 
Alexey Viktorov:
Is there any confusion? Maybe it's in the Ulan-Ude?

I was thinking that if a person really has 600 instruments in the market overview and on every tick he checks the arrival of a new bar for each instrument and each timeframe, it may be expensive...

I myself don't trade, so I don't know exactly how many times this function should be called in practice.

The double loop on symbols and timeframes in the new bar function may increase the load only if the number of symbols and timeframes is very large and the function is called on each tick of hundreds of symbols. Perhaps Dmitry is right then.

I have shortened one loop in the function.

 
Vladimir:
I remember, there was a limit of the maximum number of symbols in the Market Watch window to 1024. Doesn't it exist now? You can have 10 thousand as well?

Forum on trading, automated trading systems and trading strategy testing

Mt4 End of Support.

Artyom Trishkin, 2017.09.11 14:37

I have a customer asking me to check and scan on every tick all symbols on the server. And there are not many, not few, but 10,230... That's where the problem lies...

Attention... ;)
 

Here's the new version. It's not final.

//+------------------------------------------------------------------+
//|                                                  Новый бар 2.mq4 |
//|                                                      Peter Konow |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Peter Konow"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
datetime Время_последнего_бара;

int Частота_таймера = 25;
int Всех_символов;

string Символы[];
int    Таймфреймы[7] = {PERIOD_M1,PERIOD_M5,PERIOD_M15,PERIOD_M30,PERIOD_H1,PERIOD_H4,PERIOD_D1};
int    Всех_таймфреймов = 7;


int    Количество_баров[][7];
bool   События_нового_бара[][7];

//+------------------------------------------------------------------+
#define  M1    0
#define  M5    1
#define  M15   2
#define  M30   3
#define  H1    4
#define  H4    5
#define  D1    6
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {Alert("!!!");
//--- create timer
   EventSetMillisecondTimer(25);
   //-------------------------------------------------------------
   //Записываем время последнего бара на момент загрузки эксперта.  
   //Для корректного начала работы, робота нужно запустить на М1. 
   //-------------------------------------------------------------
   Время_последнего_бара = Time[0];
   //-------------------------------------------------------------   
   //Узнаем сколько символов есть в обзоре рынка.
   //---------------------------------------------------------
   Всех_символов = SymbolsTotal(true);
   //---------------------------------------------------------   
   //Устанавливаем размер массива Символы. Внутри него будут записаны
   //имена всех символов, которые есть в окне обзоре рынка.
   //---------------------------------------------------------
   ArrayResize(Символы,Всех_символов);
   //---------------------------------------------------------
   //Устанавливаем размеры массивов "Количество_баров[]" и "События_нового_бара[]".
   //В массиве "Количество_баров[]" будет записыватся текущее количество баров каждого символа
   //и каждого таймфрейма. А в массиве "События_нового_бара[]" устанавливаться флаги
   //события нового бара для каждого символа и каждого таймфрейма. 
   //---------------------------------------------------------
   ArrayResize(Количество_баров,Всех_символов);
   ArrayResize(События_нового_бара,Всех_символов);
   //---------------------------------------------------------
   //Записываем наименования символов обзора рынка в массив "Символы[]".
   //---------------------------------------------------------
   for(int a1 = 0; a1 < Всех_символов; a1++)
     {
      Символы[a1] = SymbolName(a1 + 1,true); 
      //Возможно, нумерация символов в обзора рынка идет с нуля.
      //Тогда: Символы[a1] = SymbolName(a1,true);
     }
   //---------------------------------------------------------
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
{
 static bool Начало_отсчета;
 static int  Минута;
 //---------------------------
 //Нам нужен корректный старт отсчета. Это должно быть время начала бара.
 //---------------------------
 if(!Начало_отсчета && Время_последнего_бара != Time[0])Начало_отсчета = true; 
 //--------------------------- 
 if(Начало_отсчета)Минута++;
 //--------------------------- 
 //В следующем цикле, мы будем обращатся к функции iBars для получения количества баров на 
 //каждом из символов и таймфреймов, которые будем проходить в цикле.
 //Далее, будем сравнивать записанное количество баров с текущим и при 
 //наличии разницы установим флаг события нового бара в массив "События_нового_бара[]".
 //---------------------------
 if(Минута*Частота_таймера >= 60000)
   {
    for(int a1 = 0; a1 < Всех_символов; a1++)
      {
       string Этот_символ = Символы[a1];
       //---------------------------------
       for(int a2 = 0; a2 < Всех_таймфреймов; a2++)
         {
          int Этот_таймфрейм = Таймфреймы[a2];
          //------------------------------------------
          int Текущее_количество_баров = iBars(Этот_символ,Этот_таймфрейм);
          //------------------------------------------
          if(Текущее_количество_баров > Количество_баров[a1][a2])
            {
             //------------------------------------------------------------
             //Если это не самая первая запись в массив Количества баров,
             //то фиксируем событие нового бара.
             //------------------------------------------------------------
             if(Количество_баров[a1][a2])
               {
                События_нового_бара[a1][a2]  = true;
               } 
             //------------------------------------------------------------
             //Устанавливаем новое значение текущего количества баров.
             //------------------------------------------------------------
             Количество_баров   [a1][a2]  = Текущее_количество_баров;
            }
          //------------------------------------------
         }
      }
    //---------
    Минута = 0;
   }
 //-----------------------------------------------
    
}
//+------------------------------------------------------------------+






//---------------------------------------------------------------------
//Функция Новый_бар() принимает наименование символа и таймфрейм.
//Она делает цикл по массиву символов, находит совпадение наименований и 
//с запрашиваемым символом, и далее ищет нужный таймфрейм для получения
//индекса ячейки массива в которой он находится. 
//Найдя индекс ячейки имени нужного символа и индекс ячейки нужного
//таймфрейма, функция обращается к массиву "События_нового_бара" и 
//возвращает факт события нового бара или его отсутствие.
//После возврата флага события, функция снимает этот флаг.
//Следовательно, флаг события можно получить только один раз за бар.
//---------------------------------------------------------------------
bool Новый_бар(string Символ, int Таймфрейм)
{
 bool Новый_бар;
 //-----------------------
 for(int a1 = 0; a1 < Всех_символов; a1++)
   {
    if(Символы[a1] == Символ)
      {
       Новый_бар  = События_нового_бара[a1][Таймфрейм];
       if(Новый_бар)События_нового_бара[a1][Таймфрейм] = 0;
       return(Новый_бар);  
      }
   }
 //-----------------------
 return(false);
}
//--------------------------
//+------------------------------------------------------------------+
 
Реter Konow:
Have you succeeded or not yet?

Peter, it's not working for me either. Although the algorithm is quite fast, it's a waste of time. But it's not working yet. No time to figure it out.
Your programming style is strange. You may put all this stuff with all variables and loops from OnInit and OnTimer into one procedure. If someone wants to use it, all this stuff will get in the way. What if there will be 20 or more procedures with the same contents? It is implementedhere .

 
Реter Konow:

I was thinking that if a person really has 600 instruments in the market overview and on every tick he checks the arrival of a new bar for each instrument and each timeframe, it might be expensive...

I myself don't trade, so I don't know exactly how many times this function should be called in practice.

The double loop on symbols and timeframes in the new bar function may increase the load only if the number of symbols and timeframes is very large and the function is called on each tick of hundreds of symbols. Perhaps Dmitry is right then.

I have shortened one cycle in the function.

Take a look at Galina's code and see what you can improve in your code.

Sincerely.
Reason: