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

 
Alexey Viktorov:

In OnTick() control the button pressing. If it works in the tester - control in OnTick(), but in real life this control block will not be executed and will be controlled in OnChartEvent()

How come? No event parameters are passed to OnTick().

 
Ilya Prozumentov:

How can this be? No event parameters are passed to OnTick().

But the push of the button is monitored

 if(ObjectGetInteger(0, "name", OBJPROP_STATE) == true)
  {
   // Делаем что надо по нажатию кнопки и возвращаем прежнее её состояние
   ObjectSetInteger(0, "name", OBJPROP_STATE, false);
  }


It is exactly the same control in OnChartEvent() with the difference that it is checked only at the moment of pressing, not on each tick.
 
Alexey Viktorov:

But pressing the button is controlled


Exactly the same control in OnChartEvent() with the only difference is that the check takes place exclusively at the moment of click, not on every tick.

Isn't it at the moment of release? Clicking on an object is only counted if you press-release within the object. If you click on an object, move the cursor away from it while holding down the button, and then release it, is the object clicked on?

However, I haven't experimented yet.

 
Artyom Trishkin:

Isn't it at the moment of push-back? Clicking on an object only counts if you press and release within the object. If you click on an object, move the cursor away from it while holding down the button, and then release it, is the object clicked on?

However, I haven't experimented yet.

I have not experimented either, so I can't say anything for sure. But it seems to be by pushing. There was even a thread somewhere discussing this. If memory serves me correctly, it seems that they even asked to separate the event for pressing and releasing the mouse button.

 
Ghabo:

OnChartEvent() does not work in the tester.

Please show the button that can work in the tester. For example, click on which, the flag trade = true will be raised; click again? trade = false;


Ilya Prozumentov:

How can this be done? No event parameters are passed to OnTick().

https://www.mql5.com/ru/forum/171668#comment_10574757

Демо счет работающий в выходные дни (Есть ли сие чудо)
Демо счет работающий в выходные дни (Есть ли сие чудо)
  • 2017.03.04
  • www.mql5.com
Доброго времени, очень увлекся разработкой на mql, но к сожалению позволить себе это могу лишь в выходные дни‌, но в выходные дни проблема с отладк...
 

Taking apart the code of the EquityChartModeller indicator.

It has 2 custom functions:

///////////////////////////////////////////////////////////////////////////
void SetPositions(string name,int number)                                           // 69 SetPositions(Portfolio_Formula_A,1)
  {
   BlocksLastN=BlocksTotal;                                                         //
   SeparateBlocks(name);                                                            // Разбиваем строку на блоки
   for(int i=BlocksLastN;i<BlocksTotal;i++)                                         // Перебираем блоки формулы
     {
      Total++;                                                                      // Увеличиваем кол-во инструментов ++;
      ArrayResize(Lots,Total);                                                      // Устанавливаем размер массива Lots размером Total;
      ArrayResize(Instrument,Total);                                                // Устанавливаем размер массива Instrument размером Total;
      ArrayResize(OpenPrice,Total);                                                 // Устанавливаем размер массива OpenPrice размером Total;
      ArrayResize(ClosePrice,Total);                                                // Устанавливаем размер массива ClosePrice размером Total;
      ArrayResize(Index,Total);                                                     // Устанавливаем размер массива Index размером Total;
      int length=StringLen(Block[i]);                                               // Определяем кол-во символов в блоке;
      int p=length-1;                                                               // Для перебора создаем переменную меньше на единицу;
      while(p>=0)                                                                   // До тех пор пока есть символ
        {
         string X=StringSubstr(Block[i],p,1);                                       // определяем символ;
         if(X=="+"||X=="-") break;                                                  // если дошли до знака то прекращаем;
         if(p==0) break                                                           // Если дошли до первого символа то прекращаем;
         else p--;                                                                  // Иначе переходим к следующему символу 
        }
      Index[Total-1]=number;
      Instrument[Total-1]=StringSubstr(Block[i],0,p);                               // Запоминаем элемент массива Instrument - название инструмента;
      if(p==0) Lots[Total-1]=1;
      else Lots[Total-1]=StrToDouble(StringSubstr(Block[i],p,length-p));            // Запоминаем элемент массива Lots - направление и размер лота;
      if(MarketInfo(Instrument[Total-1],MODE_POINT)==0)                             // Если размера пункта инструмента нет
        {Missing=StringConcatenate(Missing," ",Instrument[Total-1]);Error=true;}    // Запоминаем потерявшийся инструмент "Название инструмента ERROR"
     }
  }
///////////////////////////////////////////////////////////////////////////                     // Функция разбиения строки формулы на блоки
void SeparateBlocks(string text) // 218 SeparateBlocks(name); 
  {
   string fragment="";                                                                          // инструмент с направлением и лотом (до порбела)
   int length=StringLen(text);                                                                  // Возвращает число символов в строке (Portfolio_Formula_A)
   for(int position=0;position<length;position++)                                               // Перебор символов строки
     {
      int sym=StringGetChar(text,position);                                                     // Возвращает значение символа, расположенного в указанной позиции строки
      if(sym!=32&&sym!=9&&sym!=10&&sym!=13) fragment=fragment+StringSubstr(text,position,1);    // Если не пробел, не таб, не перевод строки, не возврат каретки - добавляем символ фрагменту
      if(sym==32||sym==9||sym==10||sym==13||position==length-1)                                 // Если пробел или таб или перевод строки или возврат каретки или последний символ строки формулы
         if(StringLen(fragment)>0)                                                              // Если у фрагмента есть символы 
           {
            BlocksTotal++;ArrayResize(Block,BlocksTotal);                                       // Кол-во блоков++; Изменяем размер массива Block;
            Block[BlocksTotal-1]=fragment;fragment="";
           }                                                                                    // Запоминаем фрагмент в массиве; обнуляем фрагмент для след. итерации цикла
     }
  }

I don't understand where it's highlighted in yellow. If portfolio formula looks like: "USDSEK-4 USDCAD+9 EURJPY-5 AUDNZD-5 EURAUD-1 GBPJPY+6 USDNOK-2", then how can the loop while(p>=0) be overridden to if(p==0) if it only breaks if(X=="+"||X=="-") break; ??

And then below, if(p==0) , why is the lot set to 1 -Lots[Total-1]=1;? ?

Indicator here: https://www.mql5.com/ru/code/10962

Equity Chart Modeller
Equity Chart Modeller
  • www.mql5.com
Данный индикатор создан на базе одной из версий известного индикатора Virtual Equity (автор: Xupypr) и был адаптирован для целей портфельного моделирования и парного трейдинга. Индикатор предназначен для быстрого анализа графиков изменения стоимости портфелей/синтетиков непосредственно перед открытием позиций. Есть два основных сценария...
 
Sergey:

Taking apart the code of the EquityChartModeller indicator.

It has 2 custom functions:

...


Indicator here: https://www.mql5.com/ru/code/10962

Insert code correctly:


 
Artyom Trishkin:

Insert the code correctly:


corrected

 
Good afternoon please help with a technical question on how to translate the script to a chart
 
Sergey:

corrected

How about a styler? Ctrl+, (comma in English)

I'm not picking on you. It's just that you're the one who needs help, so it's up to you to give the information in a usable form, not a dump.