Please Help on Fractals

 

Please I need your help in coding Fractals. I want the values of four consecutive Fractals: Last but one upper Fractal, Last but one lower Fractal, Last upper Fractal, Last lower Fractal.

Thanks.

 
   ticks++;
if (ticks==1)
for (int shift=0;shift < 5;shift++)
   {
   double Fup_1 = iFractals(NULL, 0, MODE_UPPER, shift);
   double Fdn_1 = iFractals(NULL, 0, MODE_LOWER, shift);   
   }
   
   ticks++;
if (ticks==1)
for (shift=0;shift < 10;shift++)
   {
   double Fup_2 = iFractals(NULL, 0, MODE_UPPER, shift+5);
   double Fdn_2 = iFractals(NULL, 0, MODE_LOWER, shift+5);
   }

Please, help me the above refused to return values, what should I do?

Thanks.

 

Fractal buffers only contain a value when there is a fractal, the rest of the time they are both EMPTY_VALUE. Write a loop to check the indicator buffers on each bar until it it finds one that is not empty value. It is probably worth mentioning, fractals can appear and then disappear if they are less than 3 bars old.

 
SDC:

Fractal buffers only contain a value when there is a fractal, the rest of the time they are both EMPTY_VALUE. Write a loop to check the indicator buffers on each bar until it it finds one that is not empty value. It is probably worth mentioning, fractals can appear and then disappear if they are less than 3 bars old.

Can you pls put me through? Am at crossroad. Thanks.
 
Somebody help me very urgent, I don't understand the looping, am just searching for help right now. Thanks.
 
oladapolaleye:
Somebody help me very urgent, I don't understand the looping, am just searching for help right now. Thanks.
What have you tried so far. . . show your code.
 
RaptorUK:
What have you tried so far. . . show your code.



   ticks++;
if (ticks==1)
for (int shift=0;shift < 5;shift++)
   {
   double Fup_1 = iFractals(NULL, 0, MODE_UPPER, shift);
   double Fdn_1 = iFractals(NULL, 0, MODE_LOWER, shift);   
   }
   
   ticks++;
if (ticks==1)
for (shift=0;shift < 10;shift++)
   {
   double Fup_2 = iFractals(NULL, 0, MODE_UPPER, shift+5);
   double Fdn_2 = iFractals(NULL, 0, MODE_LOWER, shift+5);
   }

But these did not return values.

Thanks.

 
oladapolaleye:


But these did not return values.

Thanks.

Put the Fractals Indicator on a chart and look at it's buffers ( Fractal Up, Fractal Down ) using the Data Window ( Ctrl + D ) you will see that there are only values where there is a Fractal up or Fractal down shown on the chart, not for each and every bar . . .

So . . .

SDC:

Fractal buffers only contain a value when there is a fractal, the rest of the time they are both EMPTY_VALUE. Write a loop to check the indicator buffers on each bar until it it finds one that is not empty value. It is probably worth mentioning, fractals can appear and then disappear if they are less than 3 bars old.

. . . so try writing a loop, while or for, to loop through the bars from 0 upwards and check the fractal values till you find one that is not EMPTY_VALUE. Try it and show you code when you get stuck and need help.
 
RaptorUK:

Put the Fractals Indicator on a chart and look at it's buffers ( Fractal Up, Fractal Down ) using the Data Window ( Ctrl + D ) you will see that there are only values where there is a Fractal up or Fractal down shown on the chart, not for each and every bar . . .

So . . .

. . . so try writing a loop, while or for, to loop through the bars from 0 upwards and check the fractal values till you find one that is not EMPTY_VALUE. Try it and show you code when you get stuck and need help.


Ok, I'll try.

Thanks.

 
oladapolaleye:


But these did not return values.

Thanks.


for (int shift=0;shift < 5;shift++)
   {
   double Fup_1 = iFractals(NULL, 0, MODE_UPPER, shift);
   double Fdn_1 = iFractals(NULL, 0, MODE_LOWER, shift);   
   }

your code see what it is doing.....

shift= 0

   double Fup_1 = iFractals(NULL, 0, MODE_UPPER, 0);
   double Fdn_1 = iFractals(NULL, 0, MODE_LOWER, 0);  

next run loop shift=1

   double Fup_1 = iFractals(NULL, 0, MODE_UPPER, 1);
   double Fdn_1 = iFractals(NULL, 0, MODE_LOWER, 1);  

and you have thrown away the values you calculated with shift = 0

and you will also loose the value shift = 1 when next run loop shift = 2....

at the end you only know

   double Fup_1 = iFractals(NULL, 0, MODE_UPPER, 5);
   double Fdn_1 = iFractals(NULL, 0, MODE_LOWER, 5);  

So learn and see what a loop is doing......

See also Fractal Break Out-Stuck

 
RaptorUK:

Put the Fractals Indicator on a chart and look at it's buffers ( Fractal Up, Fractal Down ) using the Data Window ( Ctrl + D ) you will see that there are only values where there is a Fractal up or Fractal down shown on the chart, not for each and every bar . . .

So . . .

. . . so try writing a loop, while or for, to loop through the bars from 0 upwards and check the fractal values till you find one that is not EMPTY_VALUE. Try it and show you code when you get stuck and need help.


With what I searched and my understanding, I think this is the loop and I don't know what else to do please help.

  ticks++;
if (ticks==1)
for (int shift=0;shift < 5;shift++)
Reason: