How to check ..

To add comments, please log in or register
JMohan
6
JMohan  

How to check if the current candle is the 1 pm candle and check the 5 previous candles whether they are buy or sell and maintain a count.
Below is the code but it isnt working

int get3amCandle()
   {
      static datetime currentBar = Time[0];
      double closeCandle, openCandle;
      int i= 0;
      //for(int i = 1; i != 0; i--)
      //{              
         if(TimeHour(Time[i]) == Hour_Digit && TimeMinute(Time[i]) == Minute_Digit)
         {   
            //CandleHigh[i] = candlehigh;
            //CandleLow[i] = candlelow;
             
            closeCandle =(Close[i] < Open[i]);// bearish
            openCandle = (Open[i]< Close[i]);//bullish
            
            //for(int y = Bars -1-IndicatorCounted(); y >= 0; y--)
            if( i - 1 == closeCandle)
            {
               bearCount = bullCount + 1;
            }else
            {
               bullCount = bearCount + 1;
            }
            
            if(i - 2 == closeCandle)
            {
                bearCount = bullCount + 1;
            }
            else{bullCount = bearCount + 1;}
            
            if(i - 3 == closeCandle)
            {
               bearCount = bearCount + 1;
            } 
            else{bullCount = bearCount + 1;}  
            
             if(i - 4 == closeCandle)
            {
               bearCount = bearCount + 1;
            } 
            else{bullCount = bearCount + 1;}  
            
             if(i - 5 == closeCandle)
            {
               bearCount = bearCount + 1;
            } 
            else{bullCount = bearCount + 1;}
           //break;
        }      
      
      //Print(" Number of Bearish Candles"+(string)bearCount);
      //Comment(" Number of BullISh Candles"+(string)bullCount);    
      //Comment(" Number of Bearish Candles "+(string)bearCount); 
         
   //}
   return(0);
   }
To add comments, please log in or register