Mt4 End of support. - page 42

 
Реter Konow:
No.

Unfortunately I only have half a gig of traffic left until 2pm on 14.09 so I won't look. I'll look after that time. That's something...

 
Реter Konow:

Thank you, Nikolai - thanks to you I learned how much I gained from not having a clue about the debugger.

If I had relied on it, I would have nothing now. Maybe I would have, but half as much.

Simply because I wouldn't have been able to use a colossal advantage to use my own language in programming.

Strange, because you know English much better than I do, although I live in Canada. Why not write long names in English? Except they won't be highlighted in red.
 
Nikolai Semko:
It's strange, because you know English much better than I do, even though I live in Canada. Why not write long names in English? Except they won't be highlighted in red.

On every word in your mind (albeit unconsciously) translate?

The mother tongue is biologically ingrained in the brain. Understanding is the fastest possible. Alien language is always processed before it is understood.

Pure biology.

I understand my own code much faster using Russian than I would if I used English. I memorize it much better.

 
Реter Konow:

On every word in your mind (albeit unconsciously) translate?

The mother tongue is biologically ingrained in the brain. Understanding is the fastest possible. Alien language is always processed before it is understood.

Pure biology.

I understand my own code much faster using Russian than I would if I used English. I am much better at remembering it.

And try to do something with #define. I'm just not at my computer right now. Maybe you can somehow work with Russian variable names in the debugger, if you can't do without them.
 
Реter Konow:

On every word in your mind (albeit unconsciously) translate?

The mother tongue is biologically ingrained in the brain. Understanding is the fastest possible. Alien language is always processed before it is understood.

Pure biology.

I understand my own code much faster using Russian than I would if I used English. I remember it much better.


It just so happens that I have never had English - not in school, not in a single institute, not in a second one. I still don't understand it by ear at all. I'm learning it myself, but my first attempts were long before I started programming. Annygdot " - How did you learn English so fast? - What's there to learn - they got all words from C++" - that's me.

And you know what? I've never had an anglophone in my life for some reason. So speak for yourself - don't generalize to everyone.

 
Nikolai Semko:
Try to do something with #define. I'm just not at my computer right now. Maybe you can somehow work with Russian variable names in the debugger, if you cannot do without them.

I have translated my solution code into English for the public's convenience.

//+------------------------------------------------------------------+
//|                                                  Новый бар 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 Last_Bar_Time;

int    Periodicity = 25;
int    All_symbols;

string Symbols[];
int    Timeframes[7] = {PERIOD_M1,PERIOD_M5,PERIOD_M15,PERIOD_M30,PERIOD_H1,PERIOD_H4,PERIOD_D1};
int    All_Timeframes = 7;


int    All_bars_table[][7];
bool   New_Bar_Events[][7];

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetMillisecondTimer(25);
   //-------------------------------------------------------------
   //Записываем время последнего бара на момент загрузки эксперта.  
   //Для корректного начала работы, робота нужно запустить на М1. 
   //-------------------------------------------------------------
   Last_Bar_Time = Time[0];
   //-------------------------------------------------------------   
   //Узнаем сколько символов есть в обзоре рынка.
   //---------------------------------------------------------
   All_symbols = SymbolsTotal(true);
   //---------------------------------------------------------   
   //Устанавливаем размер массива Symbols. Внутри него будут записаны
   //имена всех символов, которые есть в окне обзоре рынка.
   //---------------------------------------------------------
   ArrayResize(Symbols,All_symbols);
   //---------------------------------------------------------
   //Устанавливаем размеры массивов "All_bars_table[]" и "New_Bar_Events[]".
   //В массиве "All_bars_table[]" будет записыватся текущее количество баров каждого символа
   //и каждого таймфрейма. А в массиве "New_Bar_Events[]" устанавливаться флаги
   //события нового бара для каждого символа и каждого таймфрейма. 
   //---------------------------------------------------------
   ArrayResize(All_bars_table,All_symbols);
   ArrayResize(New_Bar_Events,All_symbols);
   //---------------------------------------------------------
   //Записываем наименования символов обзора рынка в массив "Symbols[]".
   //---------------------------------------------------------
   for(int a1 = 0; a1 < All_symbols; a1++)
     {
      Symbols[a1] = SymbolName(a1 + 1,true); 
      //Возможно, нумерация символов в обзора рынка идет с нуля.
      //Тогда: Symbols[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 Start_count;
 static int  Current_period;
 //---------------------------
 //Нам нужен корректный старт отсчета. Это должно быть время начала бара.
 //---------------------------
 if(!Start_count && Last_Bar_Time != Time[0])Start_count = true; 
 //--------------------------- 
 if(Start_count)Current_period++;
 //--------------------------- 
 //В следующем цикле, мы будем обращатся к функции iBars для получения количества баров на 
 //каждом из символов и таймфреймов, которые будем проходить в цикле.
 //Далее, будем сравнивать записанное количество баров с текущим и при 
 //наличии разницы установим флаг события нового бара в массив "New_Bar_Events[]".
 //---------------------------
 if(Current_period*Periodicity >= 1000)
   {
    for(int a1 = 0; a1 < All_symbols; a1++)
      {
       string This_symbol = Symbols[a1];
       //---------------------------------
       for(int a2 = 0; a2 < All_Timeframes; a2++)
         {
          int This_timeframe = Timeframes[a2];
          //------------------------------------------
          int All_current_bars = iBars(This_symbol,This_timeframe);
          //------------------------------------------
          if(All_current_bars > All_bars_table[a1][a2])
            {
             //------------------------------------------------------------
             //Если это не самая первая запись в массив All_bars_table,
             //то фиксируем событие нового бара.
             //------------------------------------------------------------
             if(All_bars_table[a1][a2])
               {
                New_Bar_Events[a1][a2]  = true;
               } 
             //------------------------------------------------------------
             //Устанавливаем новое значение текущего количества баров.
             //------------------------------------------------------------
             All_bars_table   [a1][a2]  = All_current_bars;
            }
          //------------------------------------------
         }
      }
    //---------
    Current_period = 0;
   }
 //-----------------------------------------------
 //Здесь наш код...
 //Здесь наш код...
 //Здесь наш код...
 //-----------------------------------------------
 //После завершения всех вызовов на этом событии таймера
 //снимаем флаги событий нового бара.
 if(!Current_period)Refresh_new_bar_events_table();
 //-----------------------------------------------  
}
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//Функция снимает флаги событий нового бара.
//Эта процедура осуществляется после выполнения всего пользовательского
//кода один раз в минуту. Вплоть до момента очищения массива флагов 
//новых баров, все функции могут их видеть обращаясь к массиву напрямую.
//+------------------------------------------------------------------+
void Refresh_new_bar_events_table()
{
 for(int a1 = 0; a1 < All_symbols; a1++)
   {
    for(int a2 = 0; a2 < All_Timeframes; a2++)
      {
       New_Bar_Events[a1][a2] = false;
      }
   }
}
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//Пример использования событий нового бара в пользовательском функционал.
//Просто обращаемся к глобальному массиву "New_Bar_Events[a1][a2]" напрямую
//и используем событие в наших торговых алгоритмах.
//+------------------------------------------------------------------+
void Trading_on_new_bars_strategy()
{
  for(int a1 = 0; a1 < All_symbols; a1++)
   {
    string This_symbol    = Symbols[a1];
    //----------------------------------
    for(int a2 = 0; a2 < All_Timeframes; a2++)
      {
       bool   New_bar      = New_Bar_Events[a1][a2];
       int    This_timeframe = Timeframes[a2];
       //----------------------------------
       if(New_bar && This_symbol == "EURUSD" && This_timeframe == PERIOD_M15)
         {
          //Buy();
         }
       //---------------------------------- 
       if(New_bar && This_symbol == "AUDUSD" && This_timeframe == PERIOD_M30)
         {
          //Sell();
         }
       //----------------------------------        
      }
   }
}
//+------------------------------------------------------------------+

I hope I didn't mix up anything.

 
Реter Konow:

Thank you, Nikolai - thanks to you I have learned how much I have gained from not having a clue about the debugger.

If I had relied on it, I would have nothing now. Maybe I would have, but half as much.

Simply because I wouldn't have been able to use a colossal advantage to use my own language in programming.

I'm pretty sure if I used such tools as OOP and debugger in my work, I would do everything much faster and of higher quality!
Too bad you don't realize that...

 
Реter Konow:

For the convenience of the public, I have translated my solution code into English.

I hope I didn't make a mistake.

Try it and see the result.

void Trading_on_new_bars_strategy()
{
  for(int a1 = 0; a1 < All_symbols; a1++)
   {
    string This_symbol    = Symbols[a1];
    //----------------------------------
    for(int a2 = 0; a2 < All_Timeframes; a2++)
      {
       bool   New_bar      = New_Bar_Events[a1][a2];
       int    This_timeframe = Timeframes[a2];
       //----------------------------------
       if(New_bar && This_symbol == "EURUSD" && This_timeframe == PERIOD_M5)
         {
          //Buy();
          Print("M5");
         }
       //---------------------------------- 
       if(New_bar && This_symbol == "AUDUSD" && This_timeframe == PERIOD_M1)
         {
          //Sell();
          Print("M1");
         }
       //----------------------------------        
      }
   }
}
 
Nikolai Semko:
I'm pretty sure if I used tools like OOP and debugger in my work, I would do everything much faster and better!


I won't argue. Time and practice will show whether I have chosen the right way, approach and tools.

 
Vitaly Muzichenko:

Try a print and see the results

What are your results?

Where are you calling the function from?

Reason: