Help with an indicator

 

I am new to Forex and MQL4 and currently trying out several systems. I'm trying to build an indicator that would draw an arrow when the conditions are met. I did some research and took a stab at writing the indicator, unfortunately it is not working. I would really appreciate any help in making this work. Thanks

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red


extern int Period_MA = 5; 
extern int Type_MA = MODE_EMA;                              
extern int Period_RSI = 2;
extern int UpperRSI = 91;
extern int LowerRSI = 9;

double MA_H;
double MA_L;
double RSI_;
double CrossUp[];
double CrossDown[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
  //---- indicators
  SetIndexStyle(0, DRAW_ARROW, EMPTY);
  SetIndexArrow(0, 225);
  SetIndexBuffer(0, CrossUp);
  SetIndexStyle(1, DRAW_ARROW, EMPTY);
  SetIndexArrow(1, 226);
  SetIndexBuffer(1, CrossDown);

  return(0);
}

int start()
  {
   int limit;
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0) return(-1);
   if(counted_bars > 0) counted_bars--;
   limit=Bars-counted_bars;
for(int i=0; i<=limit; i++)
 {
  MA_H=iMA(Symbol(),0,Period_MA,0,Type_MA,PRICE_HIGH,0);
  MA_L=iMA(Symbol(),0,Period_MA,0,Type_MA,PRICE_LOW,0); 
  RSI_=iRSI(Symbol(),0,Period_RSI,PRICE_CLOSE,0);
//----
  if (Open > MA_H && RSI_ < UpperRSI)//Check if Open is above Upper MA and if RSI is overbought
    {
      CrossDown[i]=High[i]+0.0010;
    }
  if (Open < MA_L && RSI_ > LowerRSI)//Check if Open is below lower MA and if RSI is Oversold
    {
     CrossUp[i]=Low[i]-0.0010;
    }                        
   }                                             
   return(0);
  }
 

In these lines:

  MA_H=iMA(Symbol(),0,Period_MA,0,Type_MA,PRICE_HIGH,0);
  MA_L=iMA(Symbol(),0,Period_MA,0,Type_MA,PRICE_LOW,0); 
  RSI_=iRSI(Symbol(),0,Period_RSI,PRICE_CLOSE,0);


the last (shift) parameter is 0, you should use i .

 
szgy74:

In these lines:

the last (shift) parameter is 0, you should use i .

Thanks szgy74, that helped draw the arrows, there were still some other errors to it as well, but I was able to figure it out. Thanks a lot for the help

Reason: