Errors, bugs, questions - page 2282

 
TaywinLannister:

Guys, please advise how to get indicator value for previous bars in mql5.

In mql 4 there was a SAVING variable, but mql 5 doesn't have it. HELP

int  CopyBuffer(
   int       indicator_handle,     // handle индикатора
   int       buffer_num,           // номер буфера индикатора
   int       start_pos,            // откуда начнем 
   int       count,                // сколько копируем
   double    buffer[]              // массив, куда будут скопированы данные
   );

And there are other implementations. Like with felt-tip pens, the colour is different but the taste is the same.

Документация по MQL5: Доступ к таймсериям и индикаторам / CopyBuffer
Документация по MQL5: Доступ к таймсериям и индикаторам / CopyBuffer
  • www.mql5.com
Отсчет элементов копируемых данных (индикаторный буфер с индексом buffer_num) от стартовой позиции ведется от настоящего к прошлому, то есть стартовая позиция, равная 0, означает текущий бар (значение индикатора для текущего бара). При копировании заранее неизвестного количества данных в качестве массива-приемника buffer[] желательно...
 
How do I get the colour from an indicator colour buffer?
 
Vladimir Pastushak:
How do I get the colour from an indicator colour buffer?
Each buffer has its own number. And in the CopyBuffer function, the second parameter is the buffer number. But it will be not colour, but an index in colour array. But with it, I hope, you will manage by yourself.
 
Alexey Viktorov:
Each buffer has its own number. And in the function CopyBuffer, the second parameter is the buffer number. But it will be not colour, and an index in colour array. But with it, hopefully, you can handle by yourself.

I don't understand, could you be more specific?

#property indicator_color2  clrBlue, clrRed
SetIndexBuffer(1,upper_line_color,INDICATOR_COLOR_INDEX);   

How toget colour from bufferupper_line_color ????

 
Vladimir Pastushak:

I don't understand, can you be more specific?

The code is taken from the indicator

#property indicator_buffers   5
#property indicator_plots     1
#property indicator_type1     DRAW_COLOR_BARS
#property indicator_color1    clrDarkViolet, clrCrimson, clrYellow

The system generates an array with three colours. (If I may say so, it is a hidden array, inaccessible to the programmer).

   SetIndexBuffer(4, colorBufer, INDICATOR_COLOR_INDEX);

Indicator buffer 4 contains indexes of colours from colour array

     colorBufer[j] = open[j] < close[j] ? 0.0 : open[j] > close[j] ? 1.0 : 2.0;

Here, the colour index is written to the indicator buffer and the system uses the index to select a colour from those listed in the array.

Accordingly, having used function

CopyBuffer(indicator_handle, 4, 0, 1, buffer);

we will receive the colour index on the last bar in the declared array buffer[]


ps; While I was writing, a question was added. I hope this clarification is enough. I don't want to correct it.

 
Error during execution
void OnStart()
{
    string text1 = "\0ABCDEF",
           text2 = "\0ABC";
    Print(                text1 == text2,        ":",
           StringCompare( text1,   text2 ) == 0, ":", StringLen(text1), ":", StringLen(text2));
}

Result: true:false:7:4

How is it that strings of different lengths are suddenly equal? While comparison using StringCompare produces the opposite == result

 
Alexey Viktorov:

The code is taken from the indicator

The system generates an array with three colours. (if I may say so, a hidden array, inaccessible to the programmer).

Indicator buffer 4 contains colour indices from an array of colours

Here the colour index is entered into the indicator buffer, and the system uses the index to select a colour from those listed and entered into the array.

Accordingly, having used function

we receive the colour index on the last bar in the array buffer[] declared beforehand


ps; As I was writing, the question was added. I hope this clarification is enough. I don't want to correct it.

And in the buffer buffer is copied not a colour but 0,0 1,0 2,0

tested does not work


My question says colour and not index, we get the index ascolorBufer[0] on the last bar without all these manipulations... How do I get the colour name or the colour itself as a color ?

 
Vladimir Pastushak:

And the colour is copied to the buffer not the 0.0 1.0 2.0

tested does not work

Tested, it works.

Vladimir Pastushak:

In my question it is written about colour and not about index, we get the indexcolorBufer[0] on the last bar without all these machinations... How to pull exactly the colour name or the colour itself by color type ?

This is called "Don't tailgate". I told you right away that you'd only get the index.

 
Alexey Viktorov:

Checked, it works.

And this is called "Don't bend your tail." I told you right away that you would only get the index.

I wrote the colour right away ... Thank you for responding ... Read the questions more carefully !!!

 
Vladimir Pastushak:

And I wrote the colour right away ... Thank you for responding ... Read the questions carefully !!!

Whatever the question, that's the answer. There are two ways to set the colour of the indicator display. Use the second one.