Download MetaTrader 5
To add comments, please log in or register
Do you want to learn MQL5? 300 articles will help you!
oladapolaleye
182
oladapolaleye 2013.08.19 01:36 

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.

oladapolaleye
182
oladapolaleye 2013.08.19 03:55  
   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.

Ian Venner
2583
Ian Venner 2013.08.19 05:01  

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.

oladapolaleye
182
oladapolaleye 2013.08.19 08:57  
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.
oladapolaleye
182
oladapolaleye 2013.08.19 09:18  
Somebody help me very urgent, I don't understand the looping, am just searching for help right now. Thanks.
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2013.08.19 09:26  
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.
oladapolaleye
182
oladapolaleye 2013.08.19 10:17  
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.

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2013.08.19 10:23  
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.
oladapolaleye
182
oladapolaleye 2013.08.19 10:57  
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.

Tjipke de Vries
6283
Tjipke de Vries 2013.08.19 11:20  
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

oladapolaleye
182
oladapolaleye 2013.08.19 12:01  
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++)
/ /123
To add comments, please log in or register