Arrows - there has to be a better way

 

The indicator displays arrows to show higher/lower high/lows. But using 6 buffers to do this seems clumsy. Is there a better way?

#property indicator_chart_window#property indicator_chart_window 
#property indicator_buffers 6
#property indicator_color1 Lime 
#property indicator_color2 Red
#property indicator_color3 Yellow 
#property indicator_color4 Lime
#property indicator_color5 Red
#property indicator_color6 Yellow
// indicators parameters


//---- buffers
double P1Buffer[];
double P2Buffer[];
double P3Buffer[];
double P4Buffer[];
double P5Buffer[];
double P6Buffer[];

int myStyle  = 2 ;



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- name for indicator window

   string short_name=" ";
   IndicatorShortName(short_name);
   SetIndexBuffer(0, P1Buffer);
   SetIndexBuffer(1, P2Buffer);
   SetIndexBuffer(2, P3Buffer);
   SetIndexBuffer(3, P4Buffer);
   SetIndexBuffer(4, P5Buffer);
   SetIndexBuffer(5, P6Buffer);
 
//----
SetIndexArrow(0, 246); 
SetIndexArrow(1, 248); 
SetIndexArrow(2, 240); 
SetIndexArrow(3, 246); 
SetIndexArrow(4, 248); 
SetIndexArrow(5, 240);
   SetIndexStyle(0, DRAW_ARROW, myStyle, 1);
   SetIndexStyle(1, DRAW_ARROW, myStyle, 1);   
   SetIndexStyle(2, DRAW_ARROW, myStyle, 1);
   SetIndexStyle(3, DRAW_ARROW, myStyle, 1);
   SetIndexStyle(4, DRAW_ARROW, myStyle, 1);
   SetIndexStyle(5, DRAW_ARROW, myStyle, 1);  
   
   // setting the indicator values, which will be invisible on the chart
   SetIndexEmptyValue(0,0); 
   SetIndexEmptyValue(1,0);
   SetIndexEmptyValue(2,0);
   SetIndexEmptyValue(3,0); 
   SetIndexEmptyValue(4,0); 
   SetIndexEmptyValue(5,0);
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  int j,total=OrdersTotal();
   for(j=0;j<total;j++)
   {
    OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
   }
   
 
  
   int i, dayi, counted_bars = IndicatorCounted();
//---- check for possible errors
   if(counted_bars < 0) 
       return(-1);
//---- last counted bar will be recounted
   if(counted_bars > 0) 
       counted_bars--;  
   int limit = Bars - counted_bars;
//----   
   for(i = limit - 1; i >= 0; i--)
     {
        //---- Tricolor indicator code
        double trend=High[i] - High[i+1]; 
    
        if( trend>0 )     
          {
            P1Buffer[i]=High[i]; 
            P2Buffer[i]=0;      
            P3Buffer[i]=0;
          }
        else
          {
            if(trend<0)
              {
                P1Buffer[i]=0;
                P2Buffer[i]=High[i]; 
                P3Buffer[i]=0;
              }
            else 
              {
                P1Buffer[i]=0;
                P2Buffer[i]=0;
                P3Buffer[i]=High[i];
              }
          }    
        //---- 
 
        //---- Tricolor indicator code
        double trendLo=Low[i] - Low[i+1]; 
    
        if( trendLo>0 )     
          {
            P4Buffer[i]=Low[i]; 
            P5Buffer[i]=0;      
            P6Buffer[i]=0;
          }
        else
          {
            if(trendLo<0)
              {
                P4Buffer[i]=0;
                P5Buffer[i]=Low[i]; 
                P6Buffer[i]=0;
              }
            else 
              {
                P4Buffer[i]=0;
                P5Buffer[i]=0;
                P6Buffer[i]=Low[i];
              }
          }    
        //----  
 }  
   return(0);
  }
 

You can draw objects using indicator program. It is not necessary to use any indexes at all.

 
phy:

You can draw objects using indicator program. It is not necessary to use any indexes at all.


How would I do that? I mean, wouldn't I have hundreds of objects on a 1 min chart if I did that? I am new to MT4 but I have 30 years programming experience.
 

Yes, you would have many objects. Hundreds... thousands... no problem.

Reason: