English

## Number of bars from the last Fractal Up

 246 Alberto_jazz 2009.10.15 18:41   Hi, I need an help in writing this indicator, it doesn't work. I must find the last bar that formed a Fractal Up. The indicator will return the shift from the present bar, to reach the Fractal bar. For instance, if the Fractal Up is formed 3 bars ago, the indicator will return 3. Thank you for your help! int i ; int j ; int limit ; int start() { int counted_bars=IndicatorCounted(); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i=limit; i>0; i--) if (iFractals(NULL,NULL,MODE_UPPER,i)>0) { j=i ; Return(j); } } similar
The EUR came under sharp selling pressure on the back of media reports about the ECB considering a two-tier deposit rate cut. In essence, the ECB will want to distinguish between retail and wholesale banks in the Eurozone. The policy makers are reluctant to penalize the retail banks that fund themselves mainly via domestic deposits too aggressively given that this could increase the risk of deposit flight.
 209 Jacques366 2009.10.15 19:14 #   Alberto_jazz: Hi, I need an help in writing this indicator, it doesn't work. I must find the last bar that formed a Fractal Up. The indicator will return the shift from the present bar, to reach the Fractal bar. For instance, if the Fractal Up is formed 3 bars ago, the indicator will return 3. Thank you for your help! int i ; int j ; int limit ; int start() { int counted_bars=IndicatorCounted(); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i=limit; i>0; i--) if (iFractals(NULL,NULL,MODE_UPPER,i)>0) { j=i ; Return(j); } } The shift parameter of the Fractal() function is the shift from the current bar, you should start your search from 1 and not from counted_bars! similar
 246 Alberto_jazz 2009.10.16 00:15 #   I tried this way but it doesn't work yet... int start() { int i,j ; for (i=1;i==200;i++) if (iFractals(NULL,NULL,MODE_UPPER,i)>0) { j=i ; break ; } Print(j); } similar
 209 Jacques366 2009.10.16 08:39 #   Alberto_jazz: I tried this way but it doesn't work yet... int start() { int i,j ; for (i=1;i==200;i++) if (iFractals(NULL,NULL,MODE_UPPER,i)>0) { j=i ; break ; } Print(j); } I think this code should give you the result you're looking for. What do you mean by 'it doesn't work yet' ? similar
 246 Alberto_jazz 2009.10.16 10:08 #   If I copy this code in an expert file, Print function return 0. similar
 209 Jacques366 2009.10.16 13:33 #   Alberto_jazz: If I copy this code in an expert file, Print function return 0. Certainly because your time frame parameter is wrong: null is not allowed : see http://docs.mql4.com/constants/timeframes You should put 0 if you do not want to specify one. similar
 246 Alberto_jazz 2009.10.16 14:54 #   I'm trying the following code, but the expert print 0. I would expect that the result is the shift to reach the last upper fractal, but it doesn't work... int start() { int i,j ; for (i=1;i==200;i++) if (iFractals(NULL,0,MODE_UPPER,i)>0) { j=i ; break ; } Print(j); } similar
 209 Jacques366 2009.10.16 15:26 #   Alberto_jazz: I'm trying the following code, but the expert print 0. I would expect that the result is the shift to reach the last upper fractal, but it doesn't work... int start() { int i,j ; for (i=1;i==200;i++) if (iFractals(NULL,0,MODE_UPPER,i)>0) { j=i ; break ; } Print(j); } COME ON WAKE UP! int start() { int i,j ; for (i=1;i==200;i++) { if (iFractals(NULL,0,MODE_UPPER,i)>0) { j=i ; break ; } } Print(j); } Write properly and this should not occur! 8-b I mean you can also code that way: ```int start()   {for (int i=1; i<=200; i++)        {if (iFractals(NULL,0,MODE_UPPER,i) > 0)            {break ;            }        }    Print(i);   }``` similar
 11 fdeguzman 2010.02.02 02:04 #   If my chart is set at M15 timeframe and it has been running for 5 days and I issue this for loop for H4 timeframe: ```int start()   {for (int i=1; i<=200; i++)        {if (iFractals(NULL,240,MODE_UPPER,i) > 0)            {break ;            }        }    Print(i);   }``` Is the above statement going to give me the latest information. I am worried that the iFractals do not exist for a timeframe that I haven't brought up on the screen. The data may still be 5 days old. Is MetaTrader continously forming the bars for other timeframes even though I do not have them on the screen? Thank you very much for your response. similar
 5 xman1363 2010.03.18 21:36 #   Alberto_jazz wrote >> Hi, I need an help in writing this indicator, it doesn't work. I must find the last bar that formed a Fractal Up. The indicator will return the shift from the present bar, to reach the Fractal bar. For instance, if the Fractal Up is formed 3 bars ago, the indicator will return 3. Thank you for your help! int i ; int j ; int limit ; int start() { int counted_bars=IndicatorCounted(); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i=limit; i>0; i--) if (iFractals(NULL,NULL,MODE_UPPER,i)>0) { j=i ; Return(j); } } int counted_bars= IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- macd counted in the 1-st buffer for(int i=0; i
 111 pontuso 2012.10.23 09:44 #   ```int start()   {for (int i=1; i<=200; i++)        {if (iFractals(NULL,0,MODE_UPPER,i) > 0)            {break ;            }        }    Print(i);   }   {for (int k=1; k<=200; k++)        {if (iFractals(NULL,0,MODE_UPPER,k) > 1)            {break ;            }        }    Print(k);   }   {for (int L=1; L<=200; L++)        {if (iFractals(NULL,0,MODE_LOWER,L) > 0)            {break ;            }        }    Print(L);   }   {for (int M=1; M<=200; M++)        {if (iFractals(NULL,0,MODE_LOWER,M) > 1)            {break ;            }        }    Print(M);   }``` Is it possible to write like this if i want the: -last and the second last fractal up i,k -last and the second last fractal down L,M ??