Problem in bars counting

 

Hi, I need to obtain the distance from the last fractal, but I seem this code doesn’t work.

Could you help me?

Thank you!

int start()

{

int u, Distance ;

for(u=Bars; u>0; u--)

if (iFractals(NULL,NULL,MODE_LOWER,u)>0)

{

Distance = BARS - u ;

break ;

}

Print(Distance);

}

 

The distance from where?

If you need the distance from the last fractal to the current open bar, the correct code is:

int start()

{


int u, Distance ;


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

if (iFractals(NULL,NULL,MODE_LOWER,u)>0)

{
Distance = u ;
u=Bars;
}


Print(Distance);


}
 

Thank you very much.

Here I have another dubt. I want to check if a previous bar closed over the last upper fractal.

Suppose for instance that previous upper fractal was on bar 6.

int start()

{

int BREAK_UP, u;

BREAK_UP=0 ;

for(u=0; u==6; u++)
if (Close[u]>iFractals(NULL,NULL,MODE_UPPER,6))
{
BREAK_UP=1 ;
u = 6 ;
}

Print(BREAK_UP);

}

It doesn't work but I don't know where is the problem. Thank you!

 
Alberto_jazz:
Here I have another dubt. I want to check if a previous bar closed over the last upper fractal.
Suppose for instance that previous upper fractal was on bar 6.
int lastFract=6;
int highest = Highest(NULL, 0, MODE_HIGH, Bars, 0);
if (highest != lastFract) // Last fractal not highest.

Reason: