Intermediate Fractal Indicator

 

I'm writing an intermediate fractal indicator. Essentially I take a base fractal array of highs and find an intermediate high that has both a lower fractal high on either side. Nothing fancy, just testing mql. On top of the fractal code, I'm running the following logic:


ExtUpFractalsBuffer has all the highs using 3, 5, 7 and 9 bar fractals

ExtUpIntFractalsBuffer just stores intermediate highs per my explanation above. The code works on 90% on the fractal highs but misses when there's some significant trending going on. I wish there was a debugger on MQL4.


//Intermediate Fractals Up

while (i < Bars)
{

if ((NormalizeDouble(ExtUpFractalsBuffer[i],8)) != NormalizeDouble(0,8))
{
int j=i;
int k=0;
j++;

while (j < Bars)
{
if (i == j) {
break;
}

if ((ExtUpFractalsBuffer[i] < ExtUpFractalsBuffer[j]) && (ExtUpFractalsBuffer[i] != 0) && (ExtUpFractalsBuffer[j] != 0))
{
k=j;
k++;
while (k <= Bars)
{
if (ExtUpFractalsBuffer[j] > ExtUpFractalsBuffer[k] && ExtUpFractalsBuffer[k] != 0 && ExtUpFractalsBuffer[j] != 0)
{
ExtUpIntFractalsBuffer[j] = ExtUpFractalsBuffer[j];

i=j;
break;
}
else if ((ExtUpFractalsBuffer[j] < ExtUpFractalsBuffer[k]) && (ExtUpFractalsBuffer[j] != 0) && (ExtUpFractalsBuffer[k] != 0))
{
i=j;
break;
}
k++;
}
}
else if ((ExtUpFractalsBuffer[i] > ExtUpFractalsBuffer[j]) && (ExtUpFractalsBuffer[j] != 0) && (ExtUpFractalsBuffer[i] != 0))
{
i=j;
break;
}
j++;
}
//Print ("V1 ", ExtUpFractalsBuffer[j], " V2 ", ExtUpFractalsBuffer[k]);
}
i++;
}

 

Is there a particular question you have?

The code works on 90% on the fractal highs but misses when there's some significant trending going on. What does it miss?

Have you tried looking at the function ArraySort()?

Reason: