Need quick help: Previous 3 bars highest should be less than to its previous 3 bars highest.

Back to topics list To post a new topic, please log in or register
avatar
7
rera7 2016.02.27 14:13
 

Hi i am trying to write a indicator

 if previous 3 bars highest should be less than to its previous 3 bars highest.

i mean if  previous 1,2,3 bars highest  should less than to previous 4,5,6 bars Highest. 

 but iam getting arrows for every bar!

if( High[iHighest(NULL,0,MODE_HIGH,3,4)] > High[iHighest(NULL,0,MODE_HIGH,3,1)])
avatar
7
rera7 2016.02.27 14:36 #
 

anybody correct me please.

 this is Indicator code

//+------------------------------------------------------------------+
//|                                                    Indicator.mq4 |
//|                                                           GGekko |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "GGekko"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Lime
#property indicator_width1 1
#property indicator_width2 1

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,117);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,EMPTY_VALUE);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,218);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,EMPTY_VALUE);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;


   for(int i=0; i<limit; i++)
      {if
      ( High[iHighest(NULL,0,MODE_HIGH,3,4)] > High[iHighest(NULL,0,MODE_HIGH,3,1)])

      ExtMapBuffer1[i]=High[i+1]+.0003;
      else ExtMapBuffer1[i]=EMPTY_VALUE;
      }
      
  
//---- done
   return(0);
  }
//+------------------------------------------------------------------+
   
avatar
Moderator
3418
GumRai 2016.02.27 22:35 #
 
High[iHighest(NULL,0,MODE_HIGH,3,i+4)] > High[iHighest(NULL,0,MODE_HIGH,3,i+1)]
.
avatar
Moderator
3418
GumRai 2016.02.27 22:37 #
 

you should also check limit.

   limit=Bars-counted_bars;
   if(limit>Bars-8)
      limit=Bars-8;
avatar
7
rera7 2016.02.28 17:55 #
 
Thank you GumRai :)
Back to topics list  

To add comments, please log in or register