problem with a simple custom indicator

 

hello traders

i am a newbie trying to create a indicator that draw a horizontal line in the low of the second bar( bar[2] ) only if there are three succesive high´s .

the problem is that does not work

Any advice will help thanks!

here is the code



//--------------------------------------------------------------------

// help.mq4

//--------------------------------------------------------------------

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Blue


double Buf_0[];

//--------------------------------------------------------------------

int init()

{

SetIndexBuffer(0,Buf_0);

SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);

return;

}

//--------------------------------------------------------------------

int start()

{

int i;

double lasthigh;

int Counted_bars=IndicatorCounted();

int total=Bars-Counted_bars;

for (i=0;i<total;i++)

{ if ( High[1]>High[2]>High[3])

lasthigh=Low[2] ; Buf_0[i]=lasthigh;

return(0);}

//--------------------------------------------------------------------

return(0);

}

//--------------------------------------------------------------------

 

try

for (i=0;i<total;i++){

   if ( High[1]>High[2]  && High[2]>High[3]){

      lasthigh=Low[2] ; 

      Buf_0[i]=lasthigh;

   }

}

return(0);

You had return inside your loop.

a>b>c might not work (not sure)

 
phy:

try

You had return inside your loop.

a>b>c might not work (not sure)

still not working but thank you for your help.

 

Second problem may be with

int Counted_bars=IndicatorCounted();

int total=Bars-Counted_bars;

for (i=0;i<total;i++)

just use

for (i=0;i<Bars;i++)

until you understand the consequences of limiting the number of bars you process

 
phy:

Second problem may be with

just use

until you understand the consequences of limiting the number of bars you process

now the indicator is working !!


thanks a lot !!!!!!!

Reason: