[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 14

 
Yulia:

I tried everything, if I put value of 20 bar in green buffer then red is drawn further, if I assign EMPTY_VALUE to red buffer 20, then red to 20 is not drawn. Please show me an example, I would be very grateful to you

Buffers need to be filled by some condition, for example by bar number (from the 20th to the 40th bar we draw in green):
    while (i >= 0)    
    {    
                
         if (i <= 20 && i >= 40) Buf_0[i] = High[i];                      
         if (i >= 20 && i <= 40) Buf_1[i]= High[i];
         i--;                                
      
    }

P.S. And learn to insert code into your posts - through button "SRC" (in the text entry field menu). Here about it more in detail.

 
rigonich:

Variables or arrays of variables are used for this purpose. In fact, MySQL is also an array of variables and a set of rules that allow you to work with this array.

Can you please give an example?
 
TarasBY:
Buffers should be filled by some condition, for example by bar number (from the 20th to the 40th bar we draw in green):

P.S. And learn how to insert code into your posts - via the "SRC" button (in the text entry field menu). Read more about it here.

Yes, my bad, sorry.

Thanks for code. I will look into it.

 
Yulia:

What kind of men you are, you can't help a poor girl, all I ask is such a trifle.

Here's a link to coloured MA, for example.https://www.mql5.com/ru/code/9145

I just need an example, but simpler and clearer with one coloured line on tops or bottoms of bars, without calculation algorithms.

Please respond to my request. Thank you in advance.

On your own or with us, but you can't do it without a textbook! And the poor girl needs a sponsor! ;)
 

Can I ask you a couple more questions?

My indicator has two lines, which I drag with my mouse across the screen, like the Alert function in the terminal, but more convenient. But it goes crazy when switching to a monthly chart. It is of course not that important, but I would like to know the reason.

// Юляшкин индикатор

#property indicator_chart_window
extern bool                     Активность            = 1;
extern int                      Уровень               = 500;
//--------------------------------------------------------------+
int start() {
    if (Активность == 0) {ObjectSet("Line_up",OBJPROP_COLOR,Gray); ObjectSet("Line_down",OBJPROP_COLOR,Gray); return(0);}
    if (Close[0] > ObjectGet ("Line_up",OBJPROP_PRICE1) || Close[0]< ObjectGet("Line_down",OBJPROP_PRICE1)) 
       PlaySound("alert.wav"); 
return(0);
}
//--------------------------------------------------------------+ 
int init() {
ObjectCreate("Line_up",OBJ_HLINE,0,0,Close[0]+Уровень*Point);
ObjectSet("Line_up",OBJPROP_STYLE,2); 
ObjectSet("Line_up",OBJPROP_COLOR,Yellow);
ObjectCreate("Line_down",OBJ_HLINE,0,0,Close[0]-Уровень*Point); 
ObjectSet("Line_down",OBJPROP_STYLE,2); 
ObjectSet("Line_down",OBJPROP_COLOR,Yellow);
return(0);
}  
//--------------------------------------------------------------+
int deinit() {
ObjectDelete("Line_up");
ObjectDelete("Line_down");   
return(0);
} 
//--------------------------------------------------------------+  
The second question. Does mql4 have limitations in creation of objects using the ObjectCreate function?
 
TarasBY:
For the line to be drawn in different colours (it is assembled from separate "pieces" of lines of different colours), you need to activate as many buffers as you want in the colours of the line being drawn.

In your example, on the 20th bar the values must be put in the buffer that draws the green line, and all other buffers on that bar must have an empty value that is not drawn on the chart. The default value is EMPTY_VALUE.


P.S. The coloured MA link you provided is elementary and very clear about what I wrote to you above.


In general, it is elementary and understandable, but it is beyond the scope of standard tools for building indicators, and a person who only develops standard tools is not elementary and understandable. I actually meant that the standard function at one time can draw only one segment from the data from one buffer, and to draw the next one, you should remember the previous one, and then assemble them together.... This is all possible, and in various ways, but for someone asking these kinds of questions they won't all be straightforward.
 
Yulia:

Can I ask you a couple more questions?

My indicator has two lines, which I drag with my mouse across the screen, like the Alert function in the terminal, but more convenient. But it goes crazy when switching to a monthly chart. It is of course not that important, but I would like to know the reason.

The second question. Does mql4 have limitations in creation of objects using the ObjectCreate function?

What does it mean to go crazy?
 
Vinin:

What do you mean, is it going off the rails?
The indicator periodically plays PlaySound("alert.wav"), although it shouldn't.
 
rigonich:

But it is beyond the scope of standard tools for building indicators, and for a person who is just learning the standard tools is elementary and understandable.
When commenting on my posts, you often over... I don't need to (I don't write about things I haven't "touched" or figured out), and putting myself in the shoes of those for whom you are trying to comment, I would give them up too (from that place). There are many more revelations awaiting you on the road to mastering MQL4.
 
Yulia:

Can I ask you a couple more questions?

My indicator has two lines, which I drag with my mouse across the screen, like the Alert function in the terminal, but more convenient. But it goes crazy when switching to a monthly chart. It is of course not that important, but I would like to know the reason.

The second question. Does mql4 have limitations in creation of objects using the function ObjectCreate?
First, write the price in the conditions in a more correct form: Close[0] (bar not closed) equals Bid. Maybe, this will change something in the behaviour of your indicator.
Reason: