Arrow signal error

To add comments, please log in or register
RodrigoMariani
86
RodrigoMariani  

Hi, Im trying to make an arrow indicator , but its not showing in the chart. Can anyone help ?

//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
//----
double CrossUp[];
double CrossDown[];
double prevtime;
double Range,AvgRange;

extern int SoundAlert=    1; // 0 = disabled
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW,EMPTY);
   SetIndexArrow(0,233);
   SetIndexBuffer(0,CrossUp);
   SetIndexStyle(1,DRAW_ARROW,EMPTY);
   SetIndexArrow(1,234);
   SetIndexBuffer(1,CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,counter;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   if(counted_bars==0) limit-=1+9;
//----   
   for(i=0; i<=limit; i++)
     {
      counter=i;
      Range=0;
      AvgRange=0;
      for(counter=i;counter<=i+9;counter++)
        {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
        }
      Range=AvgRange/10;
      //----       

      //----      
      if((Close[1]<iMA(NULL,0,5,0,MODE_EMA,PRICE_OPEN,1))&&(iMA(NULL,0,5,0,MODE_EMA,PRICE_OPEN,1)<iMA(NULL,0,14,0,MODE_LWMA,PRICE_OPEN,1))&&(iMA(NULL,0,14,0,MODE_LWMA,PRICE_OPEN,1)<iMA(NULL,0,20,0,MODE_SMA,PRICE_OPEN,1))&&(Close[1]<Open[2] )&&(Open[1]>Close[1]) &&(Close[2]>Open[2]))
        {
         CrossUp[i]=Low[i]-Range*0.5;
        }
      if((Close[1]>iMA(NULL,0,5,0,MODE_EMA,PRICE_OPEN,1))&&(iMA(NULL,0,5,0,MODE_EMA,PRICE_OPEN,1)>iMA(NULL,0,14,0,MODE_LWMA,PRICE_OPEN,1))&&(iMA(NULL,0,14,0,MODE_LWMA,PRICE_OPEN,1)>iMA(NULL,0,20,0,MODE_SMA,PRICE_OPEN,1))&&(Close[1]>Open[2] )&&(Open[1]<Close[1]) &&(Close[2]<Open[2]))
        {
         CrossDown[i]=High[i]+Range*0.5;
        }
     }
   if((CrossUp[0]>2000) && (CrossDown[0]>2000)) { prevtime=0; }
   if((CrossUp[0]==Low[0]-Range*0.5) && (prevtime!=Time[0]) && (SoundAlert!=0))
     {
      prevtime=Time[0];
      Alert(Symbol()," Up @  Hour ",Hour(),"  Minute ",Minute());
     }
   if((CrossDown[0]==High[0]+Range*0.5) && (prevtime!=Time[0]) && (SoundAlert!=0))
     {
      prevtime=Time[0];
      Alert(Symbol(),"  Down @  Hour ",Hour(),"  Minute ",Minute());
     }
//Comment("  CrossUp[0]  ",CrossUp[0]," ,  CrossDown[0]  ",CrossDown[0]," ,  prevtime  ",prevtime);
//Comment("");   
   return(0);
  }
//-------------------------------------------------------+
William Roeder
20207
William Roeder  
RodrigoMariani: but its not showing in the chart.
     if((Close[1]<iMA(NULL,0,5,0,MODE_EMA,PRICE_OPEN,1))&&(iMA(NULL,0,5,0,MODE_EMA,PRICE_OPEN,1)<iMA(NULL,0,14,0,MODE_LWMA,PRICE_OPEN,1))&&(iMA(NULL,0,14,0,MODE_LWMA,PRICE_OPEN,1)<iMA(NULL,0,20,0,MODE_SMA,PRICE_OPEN,1))&&(Close[1]<Open[2] )&&(Open[1]>Close[1]) &&(Close[2]>Open[2]))
        {
         CrossUp[i]=Low[i]-Range*0.5;

You are processing bar i. So why is your test only using bars one and two?

RodrigoMariani
86
RodrigoMariani  
whroeder1:

You are processing bar i. So why is your test only using bars one and two?

Thanks, now Im using i+1, i+2... and works!

To add comments, please log in or register