Vertical line. - page 2

 
Alexey Viktorov:

You have to decide what you want...

If you want mixed, only sometimes to remove connections between two vertical sections of the zigzag, it's better to take a coloured zigzag and place, by condition, no colour.

In fact, you may want to read the entire documentation section about graphic plotting. It will give you some idea what can be done...

"I have started to make an indicator which will draw lines between two points by time and price...

Everything is good, but sometimes the time of points can be in one candle..."

My fault for using the word line instead of line segments. I should have inserted a picture right away.

Thanks, I'll try the coloured zigzag, I think it will be easier than making an extra buffer for the slanted segment.
 
Alexey Viktorov:

If you need to mix and match, only occasionally remove the connections between the two vertical sections of the zigzag, it is better to take a coloured zigzag and assign no colour in places, by convention.

Well not how do I get the lack of colour in a colored zigzag. If it is not difficult (I think for you it will not take more than 5 minutes), can you assign the lack of colour in this example? I have attached a picture of what lines should be missing.


#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   1
//--- plot ZigZag
#property indicator_label1  "ZigZag"
#property indicator_type1   DRAW_COLOR_ZIGZAG
#property indicator_color1  clrRed,clrYellow
#property indicator_style1  STYLE_SOLID
#property indicator_width1  10
//--- input параметры
//--- indicator buffers
double         ZigZagBuffer1[];
double         ZigZagBuffer2[];

int            color_sections;
double         Color_ZigzagColors[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- связывание массивов и индикаторных буферов
   SetIndexBuffer(0,ZigZagBuffer1,INDICATOR_DATA);
   SetIndexBuffer(1,ZigZagBuffer2,INDICATOR_DATA);
   SetIndexBuffer(2,Color_ZigzagColors,INDICATOR_COLOR_INDEX);
   color_sections=0; 

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int limit=prev_calculated;
   if(prev_calculated==0)limit=rates_total-1;

   for(int i2=limit;i2<rates_total;i2++) // recalculate on new bar
     {
      for(int i=0;i<rates_total;i++)
        {
         if(i==rates_total-3 || i==rates_total-12 ||  i==rates_total-18) // Test VLines and TLines! 
           {
            ZigZagBuffer1[i]=high[i];
            Color_ZigzagColors[i]=color_sections;
           }
         else
           {
            ZigZagBuffer1[i]=EMPTY_VALUE;
           }

         if(i==rates_total-7 || i==rates_total-12 || i==rates_total-20) // Test VLines and TLines!   
           {
            ZigZagBuffer2[i]=low[i];
            Color_ZigzagColors[i]=color_sections;
           }
         else
           {
            ZigZagBuffer2[i]=EMPTY_VALUE;
           }

        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Nauris Zukas:

I can't get the lack of colour into the coloured zigzag. If it is not difficult (I think for you it will not take more than 5 minutes), can you assign the lack of colour in this example? Attached a picture of what lines should be missing.


1.

#property indicator_color1  clrRed,clrNone

2.

Color_ZigzagColors[i]=0;

Colour will be red

Color_ZigzagColors[i]=1;

There will be no colour.

And the variable

int            color_sections;
is completely superfluous.
 
Alexey Viktorov:

1.

2.

Colour will be red

There will be no colour.

And the variable

is completely unnecessary.

Thank you, but I can't get this to work in the function level, what should I add or remove in the functions to make these lines disappear? How do I implement clrNone here?

         if(i==rates_total-3 || i==rates_total-12 ||  i==rates_total-18) // Test VLines and TLines! 
           {
            ZigZagBuffer1[i]=high[i];
            Color_ZigzagColors[i]=0;
           }
         else
           {
            ZigZagBuffer1[i]=EMPTY_VALUE;
           }

         if(i==rates_total-7 || i==rates_total-12 || i==rates_total-20) // Test VLines and TLines!   
           {
            ZigZagBuffer2[i]=low[i];
            Color_ZigzagColors[i]=0;
           }
         else
           {
            ZigZagBuffer2[i]=EMPTY_VALUE;
           }
           
 
Nauris Zukas:

Thanks, but I can't get this to apply at function level, what should I add or remove in functions there to make these lines disappear? How to implement clrNone here?

In one place 0 in another 1

Forum on trading, automated trading systems and strategy testing

Vertical Line.

Alexey Viktorov, 2018.10.12 17:29

Color_ZigzagColors[i]=0;

Colour will be red

Color_ZigzagColors[i]=1;

There will be no colour.

And in your code it is the same in two cases

Color_ZigzagColors[i]=0;


 
Alexey Viktorov:

In one place 0 in the other 1

In your code it is the same in both cases


Here is what will happen (I put clrYellow instead of clrNone to make it clearer). Instead of connecting lines (marked with blue crosses) disappear and middle vertical line (circled in red). I therefore assume that something is already wrong in the function level.


 
Nauris Zukas:

This is what happens (I replaced clrNone with clrYellow to make it clearer). The middle vertical line (circled in red) also disappears instead of the connecting lines (circled in blue). I therefore assume that something is already wrong in the function level.


Provide the code and drawing not by hand but lines drawn by the indicator. The ability to draw vertical sections of a zigzag appeared quite recently. Rashid Umarov took part in that discussion and this change was made at his suggestion. If this option is confirmed, we will invite Rashid.

 
Alexey Viktorov:

Provide the code and drawing not by hand but lines drawn by the indicator. The ability to draw vertical sections of the zigzag appeared quite recently. Rashid Umarov took part in that discussion and this change was made at his suggestion. If this option is confirmed, we will invite Rashid.


Files:
 
Nauris Zukas:


Interesting, with such thick lines it looks like hand-drawn lines...

@Rashid Umarov

In one of the threads you participated in discussion of the impossibility of drawing a vertical line by DRAW_ZIGZAG. An example is in the previous post. After that discussion, changes were made and the feature was added. Now there is another problem with DRAW_COLOR_ZIGZAG, it's just impossible to set the colour consistently for each segment. Maybe there is a way to fix this drawback in the graphical display as well?

 
Alexey Viktorov:

Interesting, with such thick lines it looks like hand-drawn lines...

@Rashid Umarov

In one of the threads you participated in discussion of the impossibility of drawing a vertical line by DRAW_ZIGZAG. An example is in the previous post. After that discussion, changes were made and the feature was added. Now there is another problem with DRAW_COLOR_ZIGZAG, it's just impossible to set the colour consistently for each segment. Maybe there is a way to fix this drawback in the graphical display as well?

If there is, it won't be soon. It will be somewhere on the hundredth place as a far away non-priority task.

Reason: