Discussing the article: "Color buffers in multi-symbol multi-period indicators"

 

Check out the new article: Color buffers in multi-symbol multi-period indicators.

In this article, we will review the structure of the indicator buffer in multi-symbol, multi-period indicators and organize the display of colored buffers of these indicators on the chart.

A single-color indicator buffer is a regular double array, which is filled with data when calculating the indicator. We can obtain data from this array and display it on a chart using the CopyBuffer() function provided that the receiving array will be a double array set as an indicator's plotting buffer (SetIndexBuffer()). When copying data from the buffer of the calculated part of the indicator to the buffer of its plotting part, the data is displayed on the chart in one color, which is set for the buffer array of the plotting part. As for multi-colored buffers, the situation is a little different. In addition to the data array, the color buffer also has an array of color indexes.

Based on the above, we understand that

  1. The indicator plot buffer can use one or more arrays for plotting, depending on the drawing style.
  2. For any color array, one more additional array is used, which is an array of color indexes of the plotting buffer, the index of which is 1 greater than the index of the last array assigned to the plotting buffer.

For a better understanding, let's create a new indicator in which we will indicate several plotting buffers, including simple and colored, using multiple arrays for construction:

Author: Artyom Trishkin

 

Artem hi! How to add your own indicator? I can't do it! I must be doing something wrong?! If there was an example... step by step through the code and it would be clear! But he immediately!... error of indicator creation... OnInit return code is -1... Help in general, please!

  MqlParam mql_params[];
   ArrayResize(mql_params, 2);

   mql_params[0].type          = TYPE_STRING;
   mql_params[0].string_value  = "My_Indicators\\INDI_MSMT\\Test";
//---
   mql_params[1].type          = TYPE_INT;
   mql_params[1].integer_value = 10;

   handle_ind2 = indicators.AddNewCustom(NULL, PERIOD_CURRENT, "My_Indicators\\INDI_MSMT\\Test.ex5", "DON_MFI_SIS", 1, mql_params);

//handle_ind1 = IndicatorCreate(NULL, PERIOD_CURRENT, IND_CUSTOM, 1, mql_params);

 
Igor Bakhrushen indicator creation... OnInit return code is -1... Help in general, please!


From the picture it is difficult to understand what you are doing wrong there. Please attach the code that doesn't work together with the custom indicator you are using.
 
Artyom Trishkin #:
From the picture it is difficult to understand what you are doing wrong there. Please attach the code that does not work together with the custom indicator you are using.

Your library was not changed in any way, I just copied it... The test was just made to test on one buffer, I don't quite understand how all this will work when you have 20 of them! Anyway step by step!.... thanks!

Files:
INDI_MSMT_1.mqh  638 kb
Test.mq5  8 kb
DON_MFI_SIS.mq5  10 kb
 
Igor Bakhrushen #:

Your library was not changed in any way, I just copied it... the test was just made to test on one buffer, I don't quite understand how all this will work when you have 20 of them! Anyway, step by step!.... thanks!

Looked at your codes. Where is the working custom indicator? There is just a dummy with one non-coloured buffer. Most likely you need this article: https://www.mql5.com/ru/articles/13578. It has everything for working with one-colour custom indicators.

Готовим мультисимвольные мультипериодные индикаторы
Готовим мультисимвольные мультипериодные индикаторы
  • www.mql5.com
В статье рассмотрим принципы создания мультисимвольных мультипериодных индикаторов и получение от них данных в советниках и индикаторах. Рассмотрим основные нюансы использования мульти-индикаторов в советниках и индикаторах, и их отрисовку через буферы пользовательского индикатора.
 
Artyom Trishkin #:

I looked at your codes. Where is the working custom indicator? There is just a dummy with one non-coloured buffer. Most likely, you need this article: https://www.mql5.com/ru/articles/13578. It has everything for working with one-colour custom indicators.

Artem hi, thanks for looking at it! I got it working with non-coloured buffers, but it's a bit tentative... for some reason it takes a long time to load... maybe Sunday? Do you need history? When you reboot the terminal, does it draw at once? On the photo in the frame three buffers have the same value, it should not be so. Offset by one bar, also in the frame. With coloured ones it's a problem... Nothing loads at all! Can you take a look? Thanks!


 
Sorry, I got the buffers wrong! I accidentally changed the type... and then did not bring it to the right one! So we add 0! We get the same thing! CIndMSTF::Calculate::Test_Indi_MSMT: CopyBuffer(0) failed. Error 4806 data cannot be found! And it happens with different buffers!

 
Igor Bakhrushen CopyBuffer(0) failed. Error 4806 data cannot be found! And it happens with different buffers!

If the data is not received, the indicator simply exits OnCalculate() with the return of zero value, which is equal to the indication that it has not been calculated yet, and on the next tick it will try to receive data again. In this case, the first access to the required but not received data starts the process of paging this data.

 
Artyom Trishkin #:

If the data is not received, the indicator simply exits OnCalculate() with the return of zero value, which is equivalent to an indication that it has not been calculated yet, and on the next tick it will try to receive data again. In this case, the first access to the required but not received data starts the process of paging this data.

Why this problem does not occur when the terminal is restarted? Everything is drawn at once! It occurs when switching to another TF... and sometimes this"array out of range in 'INDI_MSMT_!.mqh' (680,51)" always has enough size, and sometimes not.... it's a mystery to me!


 
Igor Bakhrushen #:
INDI_MSMT_.

I don't have that file. I don't know how to help here...

 
Artyom Trishkin #:

I don't have that file. I don't know how to help here...

Files:

Yesterday I attached 'INDI_MSMT_!.mqh' the very first ...