I tried to write my own indicator using the published code using the drawing property DRAW_FILLING.
But I have problems with sticking of neighbouring drawn sections separated by empty values.
If two drawn sections appear in one window, then despite the fact that they are separated by an indicator section with EMPTY_VALUE value, this empty section is still drawn with values of neighbouring sections.
I took up this case because the published codes for the sessions indicator don't work for me, so I decided to rewrite everything.
Here is a draft.
I can only offer this option
Thank you, but a little bit not go, I'll stop perhaps on graph objects.
Thank you, but a little bit will not go, I will stop on graph objects.

- www.mql5.com
Since DRAW_FILLING style drawing is done with polygons, you can't get nice rectangles, unfortunately.
I have encountered the same problem (sticking on areas of empty values). Although it seems to be said above that you can't get rectangles, but since there is an example that draws these rectangles(trading sessions indicator), I decided to dig into the topic.
Frankly speaking, I couldn't understand how to get rectangles in the above indicator. Therefore, I will be grateful for any explanations (from platform developers, author, third-party developers).
On the other hand, in the course of experiments it turned out that it is not so difficult to get rectangles - you just need to swap filing buffers after a section of empty values. In other words, this code
... //--- for ( int bar = startBar; bar < rates_total && !IsStopped(); bar++ ) { if ( prev_calculated != rates_total && bar == rates_total - 1 ) { _up = up; } if ( bar % 4 == 0 ) { if ( up ) { draw(bar, high[bar], low[bar]); up = false; } else { draw(bar, low[bar], high[bar]); up = true; } } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ void draw(int bar, double price1, double price2) { //--- int start = bar-2; for ( int i = start; i <= bar; i++ ) { FillingBuffer1[i] = price1; FillingBuffer2[i] = price2; } //--- }
gives this result:
It would seem that the problem is solved. I wrote an indicator that allocates time intervals specified by the user on a daily basis, and I got a new surprise:
No matter how I twist it, I can't remove the "side effects". Note that in the first case (code and picture above) nothing like this was observed.
Hence, the questions:
- why the trading sessions indicator (link at the beginning of the post) does not have the problem of sticking on the areas of empty values?
- Why in some cases rectangles are drawn normally, and in other cases we get side effects? The codes are attached at the end of the post. (Yes, if such phenomena always occur, I would agree with the statement about polygons).
I repeat: I will be grateful for all explanations.
P.S.1 As it seems to me, the solution to the problem of rectangles, is a good alternative to objects (which somehow do not really want to use). After all, it is the same selection of time intervals, and linear reversal, and Darvas areas, and the selection of various patterns, etc., etc.
P.S.2 I thought of putting the TimeZone indicator into the code base, but is it worth it (with these "left" bars)?
use PlotIndexSetDouble (1,PLOT_EMPTY_VALUE,EMPTY_VALUE); for not filling range.
Why sometime effect but sometime no effect ?


- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
DRAW_FILLING:
The DRAW_FILLING drawing style plots the filled area between the values of two indicator buffers. In fact, it plots two lines and fills the area between them with the specified color. The indicator plots a channel based on two moving averages with different periods in the separate window.
The change of the channel color shows the change of the trend. The colors of the channel changed after N ticks. The N variable is defined as input parameter, it can be changed using the "Properties" window.
See also: The Drawing Styles in MQL5.
Author: MetaQuotes