# Quick question on a piece of code..

358

Why would FoundFirst always be equal the Low fractal and never update if a high fractal gets updated on this ZigZag scan...

```      int FoundHigh=0;
int FoundLow=0;
double FoundFirst=0;
int k=0;
while(FoundHigh<=2 && FoundLow<=2) // LAST x ZIGZAG FRACTALS
{
double fractal=iCustom(Symbol(),0,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,k);
if(fractal==High[k]) // High[counter]
{
FU[FoundHigh]=fractal;
if(FoundFirst==0 && FoundHigh==0 && FoundLow==0) FoundFirst=fractal;
FoundHigh++;
}
if(fractal==Low[k]) // Low[counter]
{
FL[FoundLow]=fractal;
if(FoundFirst==0 && FoundLow==0 && FoundHigh==0) FoundFirst=fractal;
FoundLow++;
}

k++;
}```
7578

Did you look at the chart? Which Symbol() and Period()?
358

in this chart you will find FL[0] = FoundFirst... is there any logic to this ?

16349

 investguy: is there any logic to this ? Print variable values before and inside if statements and find out why.
198

investguy:

in this chart you will find FL[0] = FoundFirst... is there any logic to this ?

Interesting chart. It isn't M1, is it?

Moderator
10566

What is the code for the Comment()?

You will have something like

`"FoundFirst="+FoundFirst`

Have you perhaps modified a copy & paste and mistakenly coded

`"FoundFirst="+FL[0]`
358

I have tried adding a few things to the code and still only getting the first Lower Fractal.. any other clues??

```I have tried looking at the results from the Print statements and decided to try and add a few things to the code.. .still not working... is only grabbing the first Lower fractal...

int FoundHigh=0;
int FoundLow=0;
int k=0;
while(FoundHigh<=2 && FoundLow<=2) // LAST x UPPER ZIGZAG FRACTALS
{
double fractal=iCustom(Symbol(),0,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,k);
if(fractal==High[k]) // High[counter]
{
FU[FoundHigh]=fractal;
FoundHigh++;
}
if(fractal==Low[k]) // Low[counter]
{
FL[FoundLow]=fractal;
FoundLow++;
}
//if (fractal !=0 && FoundFirst == 0) FoundFirst=fractal;
//Print( "FoundFirst=",FoundFirst," FL[FoundLow]=",FL[FoundLow]," FL[FoundHigh]=",FL[FoundHigh]);
k++;
}

double FoundFirst=0;
int BarCount=0;
while(BarCount <= Bars)
{
if(High[BarCount] == FU[0]) {FoundFirst=FU[0]; break;}
if(Low[BarCount] == FL[0]) {FoundFirst=FL[0]; break;}
BarCount++;
}

```
358

GumRai:

What is the code for the Comment()?

You will have something like

Have you perhaps modified a copy & paste and mistakenly coded

unfortunately no...
358

DeepThought:

Interesting chart. It isn't M1, is it?

no thats a renko chart.. check it out .. http://bit.ly/1mHQwr0
358

Found my mistake... the logic is right but on the comparison in the if statement i used just "=" and not "=="...

```wrong ---   if(FoundFirst=FL[0])
{

right ---   if(FoundFirst==FL[0])
{```

so the value changed.. thank you guys!!

198

investguy:
no thats a renko chart.. check it out .. http://bit.ly/1mHQwr0
I did not notice it was from the tester. You are probably using some tool to align open price to close price, which distorts the chart.