counting Candles and wait

 

hi guys, Suppose i have several nested conditions which every candle is checking and when all of them is true i want to waiting and counting 5 candle. how to do that?

 
Amin Ahmadi:

hi guys, Suppose i have several nested conditions which every candle is checking and when all of them is true i want to waiting and counting 5 candle. how to do that?

Give it go.  Show your code and then you will get some help.  Too vague a question at the moment could be done so many ways
 
int countingNewCandles(int sPos,int c,bool zero)
  {
   MqlRates priceData[];
   ArraySetAsSeries(priceData,true);
   CopyRates(Symbol(),Period(),sPos,c,priceData);

   static int candleCounter;
   static datetime timeStampLastCheck;

   datetime timeStampCurrentCandle;

   timeStampCurrentCandle=priceData[sPos].time;

   if(zero)
     {
      candleCounter=0;
      Print("counter has 0 value");
     }
   else
     {
      if(timeStampCurrentCandle!=timeStampLastCheck)
        {
         timeStampLastCheck=timeStampCurrentCandle;
         candleCounter++;
        }
     }

   Comment("Counted Candle since Chart : "+(string)candleCounter);
   return candleCounter;
  }

counter = countingNewCandles(0,3,false);

nothing happend! counter not change
 
Does it compile or is this your whole program? Sorry this is just a function.
 

I'm no expert but wouldn't it be easier to count back "x" candles (5 in your case) to see if the conditions are met.

That's how I handle such a task.

But as i said, I'm not an expert and I just do very basic coding for indicators and experts.

Reason: