![*think*](http://opentraders.ru/templates/skin/g6h/images/smilies/think.gif)
#property copyright "Copyright 2020, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int days=22;
input int hour0=0;
input int hour1=1;
input int hour2=2;
input int hour3=3;
input int hour4=4;
input int hour5=5;
input int hour6=6;
input int hour7=7;
input int hour8=8;
input int hour9=9;
input int hour10=10;
input int hour11=11;
input int hour12=12;
input int hour13=13;
input int hour14=14;
input int hour15=15;
input int hour16=16;
input int hour17=17;
input int hour18=18;
input int hour19=19;
input int hour20=20;
input int hour21=21;
input int hour22=22;
input int hour23=23;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
string symbol = Symbol();
string text_comment = "";
text_comment += "Bulls 00: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour0,time,open,close)) + "\n";
text_comment += "Bears 00: " + StringConcatenate(CountBarsType(symbol,"Bears",hour0,time,open,close)) + "\n";
text_comment += "Bulls 01: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour1,time,open,close)) + "\n";
text_comment += "Bears 01: " + StringConcatenate(CountBarsType(symbol,"Bears",hour1,time,open,close)) + "\n";
text_comment += "Bulls 02: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour2,time,open,close)) + "\n";
text_comment += "Bears 02: " + StringConcatenate(CountBarsType(symbol,"Bears",hour2,time,open,close)) + "\n";
text_comment += "Bulls 03: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour3,time,open,close)) + "\n";
text_comment += "Bears 03: " + StringConcatenate(CountBarsType(symbol,"Bears",hour3,time,open,close)) + "\n";
text_comment += "Bulls 04: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour4,time,open,close)) + "\n";
text_comment += "Bears 04: " + StringConcatenate(CountBarsType(symbol,"Bears",hour4,time,open,close)) + "\n";
text_comment += "Bulls 05: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour5,time,open,close)) + "\n";
text_comment += "Bears 05: " + StringConcatenate(CountBarsType(symbol,"Bears",hour5,time,open,close)) + "\n";
text_comment += "Bulls 06: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour6,time,open,close)) + "\n";
text_comment += "Bears 06: " + StringConcatenate(CountBarsType(symbol,"Bears",hour6,time,open,close)) + "\n";
text_comment += "Bulls 07: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour7,time,open,close)) + "\n";
text_comment += "Bears 07: " + StringConcatenate(CountBarsType(symbol,"Bears",hour7,time,open,close)) + "\n";
text_comment += "Bulls 08: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour8,time,open,close)) + "\n";
text_comment += "Bears 08: " + StringConcatenate(CountBarsType(symbol,"Bears",hour8,time,open,close)) + "\n";
text_comment += "Bulls 09: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour9,time,open,close)) + "\n";
text_comment += "Bears 09: " + StringConcatenate(CountBarsType(symbol,"Bears",hour9,time,open,close)) + "\n";
text_comment += "Bulls 10: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour10,time,open,close)) + "\n";
text_comment += "Bears 10: " + StringConcatenate(CountBarsType(symbol,"Bears",hour10,time,open,close)) + "\n";
text_comment += "Bulls 11: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour11,time,open,close)) + "\n";
text_comment += "Bears 11: " + StringConcatenate(CountBarsType(symbol,"Bears",hour11,time,open,close)) + "\n";
text_comment += "Bulls 12: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour12,time,open,close)) + "\n";
text_comment += "Bears 12: " + StringConcatenate(CountBarsType(symbol,"Bears",hour12,time,open,close)) + "\n";
text_comment += "Bulls 13: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour13,time,open,close)) + "\n";
text_comment += "Bears 13: " + StringConcatenate(CountBarsType(symbol,"Bears",hour13,time,open,close)) + "\n";
text_comment += "Bulls 14: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour14,time,open,close)) + "\n";
text_comment += "Bears 14: " + StringConcatenate(CountBarsType(symbol,"Bears",hour14,time,open,close)) + "\n";
text_comment += "Bulls 15: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour15,time,open,close)) + "\n";
text_comment += "Bears 15: " + StringConcatenate(CountBarsType(symbol,"Bears",hour15,time,open,close)) + "\n";
text_comment += "Bulls 16: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour16,time,open,close)) + "\n";
text_comment += "Bears 16: " + StringConcatenate(CountBarsType(symbol,"Bears",hour16,time,open,close)) + "\n";
text_comment += "Bulls 17: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour17,time,open,close)) + "\n";
text_comment += "Bears 17: " + StringConcatenate(CountBarsType(symbol,"Bears",hour17,time,open,close)) + "\n";
text_comment += "Bulls 18: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour18,time,open,close)) + "\n";
text_comment += "Bears 18: " + StringConcatenate(CountBarsType(symbol,"Bears",hour18,time,open,close)) + "\n";
text_comment += "Bulls 19: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour19,time,open,close)) + "\n";
text_comment += "Bears 19: " + StringConcatenate(CountBarsType(symbol,"Bears",hour19,time,open,close)) + "\n";
text_comment += "Bulls 20: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour20,time,open,close)) + "\n";
text_comment += "Bears 20: " + StringConcatenate(CountBarsType(symbol,"Bears",hour20,time,open,close)) + "\n";
text_comment += "Bulls 21: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour21,time,open,close)) + "\n";
text_comment += "Bears 21: " + StringConcatenate(CountBarsType(symbol,"Bears",hour21,time,open,close)) + "\n";
text_comment += "Bulls 22: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour22,time,open,close)) + "\n";
text_comment += "Bears 22: " + StringConcatenate(CountBarsType(symbol,"Bears",hour22,time,open,close)) + "\n";
text_comment += "Bulls 23: " + StringConcatenate(CountBarsType(symbol,"Bulls",hour23,time,open,close)) + "\n";
text_comment += "Bears 23: " + StringConcatenate(CountBarsType(symbol,"Bears",hour23,time,open,close)) + "\n";
Comment(text_comment);
return(rates_total);
}
//+------------------------------------------------------------------+
int CountBarsType(string symbol,string bar_type,datetime hour,const datetime &time[],const double &open[],const double &close[])
{
int bulls=0, bears=0;
int bars=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,days));
int result = 0;
for(int index = 0; index < bars; index++)
{
if(TimeHour(time[index]) == hour)
{
if(close[index]-open[index]>0)
{
bulls++;
}
if(close[index]-open[index]<0)
{
bears++;
}
}
}
if (bar_type == "Bulls") return(bulls);
if (bar_type == "Bears") return(bears);
return(EMPTY);
}
Kudryashov