Indicators: Fractal Channel

 

Fractal Channel:

Fractal Channel Indicator.

Author: Collector

 

The official fractal is a 5-bar pattern, and the fractal is not valid until the close of bar 5.

The Fractal Channel Indicator by Collector begins writing the most recent channel at the open of bar 5, before the fractal is valid. How do I adjust the code to have the most recent channel written only when the pattern is valid, at the close of bar 5?

Thank you.

 
ctrader6:

The official fractal is a 5-bar pattern, and the fractal is not valid until the close of bar 5.

The Fractal Channel Indicator by Collector begins writing the most recent channel at the open of bar 5, before the fractal is valid. How do I adjust the code to have the most recent channel written only when the pattern is valid, at the close of bar 5?

Thank you.

Try this in the section while (i>= 0) change 0 for 1.
 
Damian Mateusz Dziadosz:
Try this in the section while (i>= 0) change 0 for 1.

Hi Damian.

Thank you for the suggestion.

Your suggestion did not work quite the way I wanted, but you made me think! :)

I added the code "&& Close[i-3]", which appears to have solved the problem:


   while(i >= 0)

     {  

       val1 = iFractals(NULL, 0, MODE_UPPER, i);

       //----

       if(val1 > 0 && Close[i-3]) 

           v1[i] = High[i];

       else

           v1[i] = v1[i+1];

 

       val2 = iFractals(NULL, 0, MODE_LOWER, i);

       //----

       if(val2 > 0 && Close[i-3])

           v2[i] = Low[i];

       else

           v2[i] = v2[i+1];


Thanks again for making me think!

 
ctrader6:

Hi Damian.

Thank you for the suggestion.

Your suggestion did not work quite the way I wanted, but you made me think! :)

I added the code "&& Close[i-3]", which appears to have solved the problem:


   while(i >= 0)

     {  

       val1 = iFractals(NULL, 0, MODE_UPPER, i);

       //----

       if(val1 > 0 && Close[i-3]) 

           v1[i] = High[i];

       else

           v1[i] = v1[i+1];

 

       val2 = iFractals(NULL, 0, MODE_LOWER, i);

       //----

       if(val2 > 0 && Close[i-3])

           v2[i] = Low[i];

       else

           v2[i] = v2[i+1];


Thanks again for making me think!

Im glad it helped you at least indirectly:)
Reason: