Mt4 End of support. - page 34

 

Getting back to the topic of the thread. The results of the survey "What platform do you use? " were published an hour or two ago http://ru.forexmagnates.com/rezultatyi-oprosa-kakoy-platformoy-vyi-polzuetes/:

"So, according to the voting results, the platform MetaTrader 4 from the trading software provider MetaQuotes wins with a significant advantage, the preference of 63% of the participants. The flagship product of the same provider, MetaTrader 5, received 19% of votes. At the same time, 21% of those who voted use "other" trading platforms, not listed in the list."

Результаты опроса «Какой платформой вы пользуетесь?» | Forex Magnates
Результаты опроса «Какой платформой вы пользуетесь?» | Forex Magnates
  • Vadim Sviderski
  • ru.forexmagnates.com
В конце прошлой недели редакция Forex Magnates провела среди пользователей ресурса опрос на тему «Какой платформой вы пользуетесь?». Сегодня мы опубликуем результаты и выясним, какой торговой платформе отдают предпочтение розничные участники внебиржевого рынка Форекс. Итак, по результатам голосования, с существенным преимуществом побеждает...
 
Dmitry Fedoseev:

Maybe you don't know what 'fast' means?

I think I do know though))
I just don't have time to prove it right now.
I haven't studied Peter's code in detail, but I ran it through profiling. The whole data generation cycle took about 1 microsecond. That's the best result so far with the assumption that no global fixes will be needed in the code to make it fully working.
 
Реter Konow:

Does your solution work well? If it's good, it's great.

How about hundreds of tools - won't there be an overlay?

As I said right away "it's not a masterpiece", it's just a self-taught effort at learning OOP. But it works without any glitches. Before this one, my mql4-program worked well in mql5, but it didn't work properly. I've got a topic somewhere - I've been having a long high-level discussion with a drummer...

Perhaps you will have to add another variant to the function for hundreds of instruments, but the name will remain the same. And this is, in my opinion, the most pleasant plus in OOP. If you master OOP deeper, you might find even more pleasant advantages but... not in my lifetime...

 
Nikolai Semko:
I think I do know though))
I just don't have time to prove it right now.
I haven't studied Peter's code in detail, but I ran it through profiling. The whole data generation cycle took about 1 microsecond. That's the best result so far with the assumption that no global fixes will be needed in the code to make it fully working.

All the same, you've proven that you don't know.

 
Dmitry Fedoseev:

Still, you have proven that you don't know.

All right, as you wish. I don't know. I am defeated and your foot is on my chest. Congratulations!!! Enjoy!
 
Dmitry Fedoseev:

You have no idea what idiocy you have demonstrated, it's just a complete abnormality. But I won't show you exactly where, because you all aren't interested in my opinion)))

Anyone is interested in an opinion only with valid arguments.

The argument, "you have to do it because I do it" does not interest anyone.

In this particular case, the variable names don't correspond to what is accepted is a weak argument. This was not written for CodeBase.

 

It's funny how you all sit on the poker on the cross here. Keep sitting down, it makes the world around you funnier.

 
Dmitry Fedoseev:

It's funny how you all sit on the poker on the cross here. Keep sitting down, it makes the world around you funnier.


Well done, Dimitri!
If Peter is a master at fanning fires, then you are a master at putting them out ))))

 
Alexey Volchanskiy:

So far even MOFT doesn't support MT5, which is frustrating for me as I've been chipping away at the spreads there. And what does support mean? Release of new versions? Well if no critical bugs are found, maybe there won't be any new ones.

I have partially switched to MT5, but as Dmitiry rightly pointed out, conditions are better on MT4 for now.

It's not. The speed and quality oforder execution in MT5 create a nice environment to get used to the better (there are sane, and, in fact, very low spreads during the liquidity periods, the example is the same Robo(MT5)). Which in turn gives advantages to the order limit at certain liquidity levels. /*<= and this can more than compensate for the overhead (spread and commission if the account has a commission).

From examples of this /*the green arrows are the limit levels that I set, and the red to blue arrows are how the actual order worked out*/:

 

This variant of the function has no New_bar() function at all;

This is the most resource-saving option I've provided. In addition, it has another advantage: The new bar event is saved all the time the user code is executed on a timer or tick event.

Previously, you could only get this event once and the flag was cleared with New_bar(). The special function now clears the "event_new_bar[][]" array once a minute and is called only after the execution of custom code.

Custom functions can directly access the array and retrieve new bar event information all the time the code is executed on a timer or tick event.

Resources are saved even more.

//+------------------------------------------------------------------+
//|                                                  Новый бар 3.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()
  {
//--- 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;
   }
 //-----------------------------------------------
 //Здесь наш код...
 //Здесь наш код...
 //Здесь наш код...
 //-----------------------------------------------
 //После завершения всех вызовов на этом событии таймера
 //снимаем флаги событий нового бара.
 if(!Минута)Снять_событие_нового_бара();
 //-----------------------------------------------   
}
//+------------------------------------------------------------------+
//Функция снимает флаги событий нового бара.
//Эта процедура осуществляется после выполнения всего пользовательского
//кода один раз в минуту. Вплоть до момента очищения массива флагов 
//новых баров, все функции могут их видеть обращаясь к массиву напрямую.
//+------------------------------------------------------------------+
void Снять_событие_нового_бара()
{
 for(int a1 = 0; a1 < Всех_символов; a1++)
   {
    for(int a2 = 0; a2 < Всех_таймфреймов; a2++)
      {
       События_нового_бара[a1][a2] = false;
      }
   }
}
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//Пример использования событий нового бара в пользовательском функционал.
//Просто обращаемся к глобальному массиву "События_нового_бара[a1][a2]" напрямую
//и используем событие в наших торговых алгоритмах.
//+------------------------------------------------------------------+
void Моя_стратегия_торговли_на_новых_барах()
{
  for(int a1 = 0; a1 < Всех_символов; a1++)
   {
    string Этот_символ    = Символы[a1];
    //----------------------------------
    for(int a2 = 0; a2 < Всех_таймфреймов; a2++)
      {
       bool   Новый_бар      = События_нового_бара[a1][a2];
       int    Этот_таймфрейм = Таймфреймы[a2];
       //----------------------------------
       if(Новый_бар && Этот_символ == "EURUSD" && Этот_таймфрейм == PERIOD_M15)
         {
          //Купить();
         }
       //---------------------------------- 
       if(Новый_бар && Этот_символ == "AUDUSD" && Этот_таймфрейм == PERIOD_M30)
         {
          //Продать();
         }
       //----------------------------------        
      }
   }
}
//+------------------------------------------------------------------+