Download MetaTrader 5

2 Color arrow , is there a bug here?

To add comments, please log in or register
Have you made a screenshot in MetaTrader? Share it with friends!
lello1231
430
lello1231 2014.01.16 23:27 
#property version   "1.00"
#property indicator_chart_window

#property indicator_buffers 4
#property indicator_plots 2

#property indicator_type1   DRAW_COLOR_ARROW
#property indicator_width1 1
#property indicator_color1 clrRed,clrGray


#property indicator_type2   DRAW_COLOR_ARROW
#property indicator_width2 1
#property indicator_color2 clrGreen,clrYellow

int arrowDistance=10;
double b1[];
double b1c[];
double b2[];
double b2c[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
  SetIndexBuffer(0,b1,INDICATOR_DATA);
  SetIndexBuffer(1,b1c,INDICATOR_COLOR_INDEX);
  // PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_ARROW);
  PlotIndexSetInteger(0,PLOT_ARROW,234);
  PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-arrowDistance);
  PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); 
    
  SetIndexBuffer(2,b2,INDICATOR_DATA);
  SetIndexBuffer(3,b2c,INDICATOR_COLOR_INDEX);
  
 //PlotIndexSetInteger(2,PLOT_DRAW_TYPE,DRAW_COLOR_ARROW);
 PlotIndexSetInteger(2,PLOT_ARROW,233);
 PlotIndexSetInteger(2,PLOT_ARROW_SHIFT,arrowDistance);

//---
   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 first;
    if(prev_calculated>rates_total || prev_calculated<=0) // checking for the first start of the indicator calculation
     {
      first=0;                   // starting index for calculation of all bars
     }
        else first=prev_calculated-1;
  
  for(int i=first;i<rates_total&&!IsStopped();i++)
    {
      b1[i]=high[i];
     if(open[i]>close[i])  b1c[i]=0.0; 
        else b1c[i]=1.0;
        
     b2[i]=low[i];
     if (open[i]>open[i+1]) b2c[i]=0;
        else b2c[i]=1.0; 
        
    }  
        
 
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Hello,

I am trying to create a simple indicator , which assign 2 different type of graphical arrows (each graphical arrow can be assigned one of 2 colors  based on certain conditions in the  code) on each candle on chart . However the second graphical arrow should be looking as an " arrow up", however a "small circle" is drawn instead, and i don't know the reason why the arrow code =  233 is not taken in use. The colors of the second graphical arrow is fine.

Can someone help please? 

Alain Verleyen
Moderator
30723
Alain Verleyen 2014.01.17 10:52  

These lines :

 PlotIndexSetInteger(2,PLOT_ARROW,233);
 PlotIndexSetInteger(2,PLOT_ARROW_SHIFT,arrowDistance);

must be :

 PlotIndexSetInteger(1,PLOT_ARROW,233);
 PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,arrowDistance);
lello1231
430
lello1231 2014.01.17 11:12  
Thank you ! it worked:)
To add comments, please log in or register