BULLISH/BEARISH Bar counter code

To add comments, please log in or register
Nguyen5
14
Nguyen5  
BULLISH/BEARISH Bar counter code


Hi guys i`m having problem creating a bar counter code.Basically this indicator would be a statistical tool for me and it would help me very much with my market research.
It would count how many  BEARISH bars appear and BULLISH bars at the next candle of certain time "EST" 
for example in the photo the indicator will add only the blue lines at time "EST" and i want to add the counter of how many up/ down candles for only the next candle after the blue lines and it will show the result same in the rectangle that i have added in the photo.
i added the arrows just for explaining but i don't need the arrow.


counter


thanks a lot guys



Files:
Nguyen5
14
Nguyen5  

here is coding of the original indicator 


#property indicator_chart_window

extern int EST=7;
extern int CountBars=500;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   int shift=0;
   for  (shift=Bars-1;shift>=0;shift--) {
   ObjectDelete("EST"+shift);
   ObjectDelete("Broker"+shift);
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int shift, NumBars=500;
   double CloseTime,OpenTime;
   
   if (Bars<CountBars)  { NumBars=Bars-1; } else { NumBars=CountBars; }

   for  (shift=Bars-1;shift>=0;shift--) {
 
//      OpenTime=StrToTime(TimeDay(Time[shift])+" "+EST+":"+OpenTimeMin);
//      CloseTime=StrToTime(TimeDay(Time[shift])+" "+MST+":"+CloseTimeMin);      
          
          
          if (TimeHour(Time[shift])== EST && TimeMinute(Time[shift])==0) {
             if(ObjectFind("EST"+shift) != 0)
         {            
            ObjectCreate("EST"+shift, OBJ_VLINE, 0, Time[shift], 0);
            ObjectSet("EST"+shift, OBJPROP_STYLE, STYLE_DASHDOTDOT);
            ObjectSet("EST"+shift, OBJPROP_COLOR, Blue);
         }           
      }
      
      
      if (TimeHour(Time[shift])== 0 && TimeMinute(Time[shift])==0) {
             if(ObjectFind("Broker"+shift) != 0)
         {            
            ObjectCreate("Broker"+shift, OBJ_VLINE, 0, Time[shift], 0);
            ObjectSet("Broker"+shift, OBJPROP_STYLE, STYLE_DASHDOTDOT);
            ObjectSet("Broker"+shift, OBJPROP_COLOR, White);
         }           
      }  

   }


   return(0);
  }
//+------------------------------------------------------------------+
Jonathan Mcbrine
1227
Jonathan Mcbrine  
I'm seeking something a bit simper, I just need the code to count each bar, each day.  From bar one to the last bar that day. 
nicholish en
2696
nicholish en  
   MqlRates rates[];
   int bars = CopyRates(_Symbol, PERIOD_CURRENT, iTime(_Symbol, PERIOD_D1, 0), TimeCurrent(), rates);
   int bull = 0;
   for (int i=0; i<bars; i++)
      if (rates[i].close > rates[i].open)
         bull++;
   printf("Bulls(%d) vs. Bears(%d)", bull, bars - bull);
Jannie
256
Jannie  

Hello

Did you manage to get the counter working in the end?

Regards

To add comments, please log in or register