#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 clrSteelBlue
#property indicator_color2 clrDodgerBlue
#property indicator_color3 clrNONE
#property indicator_color4 clrRed
input int period_MA = 20;
input int Normalize = 3;
double bufer_MA[];
double arrow_up[];
double count_up[];
double arr_verh[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0, bufer_MA); SetIndexStyle(0, DRAW_LINE); // Синяя линия
SetIndexBuffer(1, arrow_up); SetIndexStyle(1, DRAW_ARROW, 0, 2); SetIndexArrow(1, 159); // Синяя стрелка
SetIndexBuffer(2, count_up); SetIndexStyle(2, DRAW_NONE); // Счётчик ступеней
SetIndexBuffer(3, arr_verh); SetIndexStyle(3, DRAW_ARROW, 0, 1); SetIndexArrow(3, 161); // Для красной стрелки
return (INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| 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[])
{
int limit = rates_total - prev_calculated;
if (limit > 1)limit -= 1;
// Ступеньки из линии МА
for (int i = 0; i < limit; i++) bufer_MA[i] = NormalizeDouble(iMA(Symbol(), 0, period_MA, 0, 0, 0, i), Normalize);
// Счётчик количества непрерывных ступеней
int continuous_steps_up = 0;
// Определить сколько раз, у первой линии, было непрерывно ступеней вверх.
for (int i = limit - 1; i >= 0; i--){
//+----------------------------------------------------------------------------------------------------+
if (i < rates_total - 1 && bufer_MA[i] > bufer_MA[i + 1] && bufer_MA[i] != bufer_MA[i + 1]){
continuous_steps_up++;
arrow_up[i] = bufer_MA[i];
}
//+----------------------------------------------------------------------------------------------------+
//| счётчик ступеней
//+----------------------------------------------------------------------------------------------------+
if( bufer_MA[i] < bufer_MA[i + 1]){ continuous_steps_up = 0; }
count_up[i] = continuous_steps_up;
//+----------------------------------------------------------------------------------------------------+
}
return (rates_total);
}
/////////////////////////////////////////////////