Problems with a colored line chart - page 2

 
I can't manage it... I don't know how to work with DRAW_ARROW. Which arrow code do I have to use for drawing a line? I never thought that this could be so hard...
 
mar:
I can't manage it... I don't know how to work with DRAW_ARROW. Which arrow code do I have to use for drawing a line? I never thought that this could be so hard...

Use a Wingding, but you will only get a series of dots or something like that.
 

I had a look at the Wingding-Table and I didn't find anything close to a line. I did it with dots and it works. But I still have no idea how to draw a line between the closes.


EDIT: correct, with dots it works. But why is it so complicated with a normal line? I really want to know what I don't consider in my code..

 
mar:

I had a look at the Wingding-Table and I didn't find anything close to a line. I did it with dots and it works. But I still have no idea how to draw a line between the closes.


EDIT: correct, with dots it works. But why is it so complicated with a normal line? I really want to know what I don't consider in my code..

I don't think that DRAW_COLORLINE has been implemented yet (at least in build 625)
Seems to me that the only way to do it at the moment is with 4 buffers

This will only draw to closed candles, trying to sort it out with the varying values of the current candle would be too much headache for me right now :)

#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   4
//--- plot Bull_Line_1
#property indicator_label1  "Bull_Line_1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDodgerBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- plot Bull_Line_2
#property indicator_label2  "Bull_Line_2"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrDodgerBlue
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2
//--- plot Bear_Line_1
#property indicator_label3  "Bear_Line_1"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrRed
#property indicator_style3  STYLE_SOLID
#property indicator_width3  2
//--- plot Bear_Line_2
#property indicator_label4  "Bear_Line_2"
#property indicator_type4   DRAW_LINE
#property indicator_color4  clrRed
#property indicator_style4  STYLE_SOLID
#property indicator_width4  2
//--- input parameters

//--- indicator buffers
double         Bull_Line_1Buffer[];
double         Bull_Line_2Buffer[];
double         Bear_Line_1Buffer[];
double         Bear_Line_2Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Bull_Line_1Buffer);
   SetIndexBuffer(1,Bull_Line_2Buffer);
   SetIndexBuffer(2,Bear_Line_1Buffer);
   SetIndexBuffer(3,Bear_Line_2Buffer);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);
   SetIndexEmptyValue(3,0.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[])
  {
//---
  ArraySetAsSeries(close,true);
  int index,limit;
  if(prev_calculated==0)
     limit=rates_total-3;
  else
     limit=rates_total-prev_calculated;
     
  for(index=limit;index>0;index--)
     {
     if(close[index]>=close[index+1])
        if(Bull_Line_1Buffer[index+2]==0.0)
           {
           Bull_Line_1Buffer[index]=close[index];
           Bull_Line_1Buffer[index+1]=close[index+1];
           }
        else
           {
           Bull_Line_2Buffer[index]=close[index];
           Bull_Line_2Buffer[index+1]=close[index+1];
           }
     if(close[index]<close[index+1])
        if(Bear_Line_1Buffer[index+2]==0.0)
           {
           Bear_Line_1Buffer[index]=close[index];
           Bear_Line_1Buffer[index+1]=close[index+1];
           }
        else
           {
           Bear_Line_2Buffer[index]=close[index];
           Bear_Line_2Buffer[index+1]=close[index+1];
           }
     }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
GumRai:

I don't think that DRAW_COLORLINE has been implemented yet (at least in build 625)
Seems to me that the only way to do it at the moment is with 4 buffers

This will only draw to closed candles, trying to sort it out with the varying values of the current candle would be too much headache for me right now :)

Yes I would have used 2 alternating buffers for each color too, I didnt know DRAW_COLOR_LINE was not implemented. Strange that editor does recognise DRAW_COLORLINE as a keyword even though it is supposed to be DRAW_COLOR_LINE according to the docs.
 
mar:

I had a look at the Wingding-Table and I didn't find anything close to a line. I did it with dots and it works. But I still have no idea how to draw a line between the closes.

EDIT: correct, with dots it works. But why is it so complicated with a normal line? I really want to know what I don't consider in my code..

What you didnt consider is, when a line is supposed to end on one bar, and then begin again on the next bar, the line will fill in the gap. This is why GumRai is talking about using 4 buffers.
Reason: