
#property copyright "free"
#property link      "no_link"

#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 1.0
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

extern int FiltPer = 25;
double g_ibuf_80[];
double g_ibuf_84[];

int init() {
   IndicatorDigits(5);
   SetIndexBuffer(0, g_ibuf_80);
   SetIndexBuffer(1, g_ibuf_84);
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexEmptyValue(0, -1);
   SetIndexEmptyValue(1, -1);
   return (0);
}

int start() {
   double icustom_4;
   double icustom_12;
   double icustom_20;
   for (int li_0 = Bars - IndicatorCounted() - 1; li_0 >= 0; li_0--) {
      icustom_4 = iCustom(NULL, 0, "HP", 500, FiltPer, 0, li_0);
      icustom_12 = iCustom(NULL, 0, "HP", 500, FiltPer, 0, li_0 + 1);
      icustom_20 = iCustom(NULL, 0, "HP", 500, FiltPer, 0, li_0 + 2);
      if ((icustom_4 >= icustom_12 && icustom_12 > icustom_20) || (icustom_4 > icustom_12 && icustom_12 <= icustom_20) || (g_ibuf_80[li_0] == 1.0 && icustom_4 == icustom_12 &&
         icustom_12 == icustom_20)) {
         g_ibuf_80[li_0] = 1;
         g_ibuf_84[li_0] = -1;
      } else {
         if ((icustom_4 <= icustom_12 && icustom_12 < icustom_20) || (icustom_4 < icustom_12 && icustom_12 >= icustom_20) || (g_ibuf_84[li_0] == 1.0 && icustom_4 == icustom_12 &&
            icustom_12 == icustom_20)) {
            g_ibuf_80[li_0] = -1;
            g_ibuf_84[li_0] = 1;
         }
      }
   }
   return (0);
}