#property copyright "Attila"
#property link      "priceactiontools.com"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Black
#property indicator_color2 Black
#property indicator_color3 Black
#property indicator_color3 Black
#property indicator_color3 Black
#property indicator_color3 Black

extern int barsback = 500;
extern bool arrows = TRUE;
extern int arrowsize = 1;
extern color arrowcolor = Aqua;
extern bool paint = TRUE;
extern int barthickness = 2;
extern color paintcolor = Red;
extern bool alarm = FALSE;
extern string sound = ".wav file here";
extern bool alert = FALSE;
extern int ishX = 20;
extern int ishY = 20;
extern int dist = 50;
extern int Font = 7;
extern int PERIOD = 0;
//extern bool m5 = TRUE;
//extern bool m15 = TRUE;
//extern bool m30 = TRUE;
//extern bool m60 = TRUE;
double g_ibuf_148[];
double g_ibuf_152[];
double g_ibuf_156[];
string gsa_160[7] = {"EURJPY", "USDJPY", "USDCHF", "AUDUSD", "NZDUSD", "GBPUSD", "EURUSD"};

int g_datetime_164 = 0;
int g_datetime_168 = 0;
int g_datetime_172 = 0;
int g_datetime_176 = 0;
int g_datetime_180 = 0;
int g_datetime_184 = 0;
int g_datetime_188 = 0;

int f0_0(int a_timeframe_0) {
   int li_ret_68;
   double ihigh_4 = iHigh(NULL, a_timeframe_0, 1);
   double ilow_12 = iLow(NULL, a_timeframe_0, 1);
   double iclose_20 = iClose(NULL, a_timeframe_0, 1);
   double iopen_28 = iOpen(NULL, a_timeframe_0, 1);
   double ihigh_36 = iHigh(NULL, a_timeframe_0, 2);
   double ilow_44 = iLow(NULL, a_timeframe_0, 2);
   double iclose_52 = iClose(NULL, a_timeframe_0, 2);
   double iopen_60 = iOpen(NULL, a_timeframe_0, 2);
   if (ihigh_4 < ihigh_36 && ilow_12 > ilow_44) li_ret_68 = 65280;
   else li_ret_68 = 5197615;
   return (li_ret_68);
}

int init() {
   if (paint == TRUE) {
      SetIndexBuffer(0, g_ibuf_148);
      SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, barthickness, paintcolor);
      SetIndexEmptyValue(0, 0.0);
      SetIndexBuffer(1, g_ibuf_152);
      SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, barthickness, paintcolor);
      SetIndexEmptyValue(1, 0.0);
   }
   if (arrows == TRUE) {
      SetIndexBuffer(2, g_ibuf_156);
      SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, arrowsize, arrowcolor);
      SetIndexArrow(2, SYMBOL_ARROWDOWN);
      SetIndexEmptyValue(2, 0.0);
   }
   ObjectCreate("_istype1", OBJ_LABEL, 0, 0, 0, 0, 0);
   ObjectSet("_istype1", OBJPROP_CORNER, 0);
   ObjectSet("_istype1", OBJPROP_XDISTANCE, ishX);
   ObjectSet("_istype1", OBJPROP_YDISTANCE, ishY);
   ObjectSetText("_istype1", "Inside Bar", 10, "Verdana", Red);
   for (int li_0 = 6; li_0 >= 0; li_0--) {
      ObjectCreate("_istf1" + li_0, OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSet("_istf1" + li_0, OBJPROP_CORNER, 0);
      ObjectSet("_istf1" + li_0, OBJPROP_XDISTANCE, ishX);
      ObjectSet("_istf1" + li_0, OBJPROP_YDISTANCE, ishY + 20);
      ObjectSetText("_istf1" + li_0, gsa_160[li_0], Font, "Verdana", RoyalBlue);
      ObjectCreate("_issig" + li_0, OBJ_LABEL, 0, 0, 0, 0, 0);
      ObjectSet("_issig" + li_0, OBJPROP_CORNER, 0);
      ObjectSet("_issig" + li_0, OBJPROP_XDISTANCE, ishX);
      ObjectSet("_issig" + li_0, OBJPROP_YDISTANCE, ishY + 30);
      ishX += dist;
   }
   return (0);
}

int deinit() {
   Comment("");
   for (int count_0 = 0; count_0 <= 7; count_0++) {
      ObjectDelete("_istf1" + count_0);
      ObjectDelete("_issig" + count_0);
   }
   ObjectDelete("_istype1");
   return (0);
}

int start() {
   double pips_12;
   color color_24;
   color color_28;
   color color_32;
   color color_36;
   color color_40;
   color color_44;
   color color_48;
   
   int li_0 = IndicatorCounted();
   if (li_0 < 0) return (0);
   if (li_0 > 1) li_0--;
   int li_4 = Bars - li_0 - 2;
   switch (Period()) {
   case PERIOD_M5:
      pips_12 = 50;
      break;
   case PERIOD_M15:
      pips_12 = 70;
      break;
   case PERIOD_M30:
      pips_12 = 80;
      break;
   case PERIOD_H1:
      pips_12 = 90;
      break;
   case PERIOD_H4:
      pips_12 = 150;
      break;
   case PERIOD_D1:
      pips_12 = 500;
      break;
   case PERIOD_W1:
      pips_12 = 1500;
   }
   for (int li_20 = barsback; li_20 >= 1; li_20--) {
      if (High[li_20] < High[li_20 + 1] && Low[li_20] > Low[li_20 + 1]) {
         g_ibuf_148[li_20] = Low[li_20];
         g_ibuf_152[li_20] = High[li_20];
         g_ibuf_156[li_20] = High[li_20] + pips_12 * Point;
      }
   }
      
   color_24 = f0_0("EURUSD");
      if (iTime("EURUSD", PERIOD, 0) != g_datetime_164 && color_24 == Lime) {
         g_datetime_164 = iTime("EURUSD", PERIOD, 0);
         if (alert == TRUE) Alert(Symbol(), " 5M inside bar!!!");
         if (alarm == TRUE) PlaySound(sound);
      }
   
   
   color_28 = f0_0("GBPUSD");
      if (iTime("GBPUSD", PERIOD, 0) != g_datetime_168 && color_28 == Lime) {
         g_datetime_168 = iTime("GBPUSD", PERIOD, 0);
         if (alert == TRUE) Alert(Symbol(), " 15M inside bar!!!");
         if (alarm == TRUE) PlaySound(sound);
      }
   
   color_32 = f0_0("NZDUSD");
      if (iTime("NZDUSD", PERIOD, 0) != g_datetime_172 && color_32 == Lime) {
         g_datetime_172 = iTime("NZDUSD", PERIOD, 0);
         if (alert == TRUE) Alert(Symbol(), " 30M inside bar!!!");
         if (alarm == TRUE) PlaySound(sound);
      }
   
   color_36 = f0_0("AUDUSD");
   if (iTime("AUDUSD", PERIOD, 0) != g_datetime_176 && color_36 == Lime) {
       g_datetime_176 = iTime("AUDUSD", PERIOD, 0);
       if (alert == TRUE) Alert(Symbol(), " 60M inside bar!!!");
       if (alarm == TRUE) PlaySound(sound);     
   }
   
   color_40 = f0_0("USDCHF");
   if (iTime("USDCHF", PERIOD, 0) != g_datetime_180 && color_40 == Lime) {
      g_datetime_180 = iTime("USDCHF", PERIOD, 0);
      if (alert == TRUE) Alert(Symbol(), " 4H inside bar!!!");
      if (alarm == TRUE) PlaySound(sound);
   }
   
  color_44 = f0_0("USDJPY");
   if (iTime("USDJPY", PERIOD, 0) != g_datetime_184 && color_44 == Lime) {
      g_datetime_184 = iTime("USDJPY", PERIOD, 0);
      if (alert == TRUE) Alert(Symbol(), " Daily inside bar!!!");
      if (alarm == TRUE) PlaySound(sound);
   }
 color_48 = f0_0("EURJPY");
   if (iTime("EURJPY", PERIOD, 0) != g_datetime_188 && color_48 == Lime) {
      g_datetime_188 = iTime("EURJPY", PERIOD, 0);
      if (alert == TRUE) Alert(Symbol(), " Weekly inside bar!!!");
      if (alarm == TRUE) PlaySound(sound);
   }
  
   
   
   
   ObjectSetText("_issig6", CharToStr(110), 18, "Wingdings", color_24);
   ObjectSetText("_issig5", CharToStr(110), 18, "Wingdings", color_28);
   ObjectSetText("_issig4", CharToStr(110), 18, "Wingdings", color_32);
   ObjectSetText("_issig3", CharToStr(110), 18, "Wingdings", color_36);
   ObjectSetText("_issig2", CharToStr(110), 18, "Wingdings", color_40);
   ObjectSetText("_issig1", CharToStr(110), 18, "Wingdings", color_44);
   ObjectSetText("_issig0", CharToStr(110), 18, "Wingdings", color_48);
   ObjectsRedraw();
   return (0);
}