/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Devil2000"
#property link      "http:\www.indofx-trader.net"

#property indicator_separate_window
#property indicator_minimum -40.0
#property indicator_maximum 40.0
#property indicator_buffers 2
#property indicator_color1 DarkBlue
#property indicator_color2 DarkBlue

extern bool   AlertOnPrice = TRUE;
extern double Price_ceil = 0.0;
extern double Price_floor = 0.0;
extern string   Son = "alerte_1";
extern int RangeFilter = 100;
double g_ibuf_100[];
double g_ibuf_104[];
string gs_108;

int init() {
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 5);
   SetIndexBuffer(0, g_ibuf_100);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 5);
   SetIndexBuffer(1, g_ibuf_104);
   if (AlertOnPrice == TRUE) gs_108 = "true";
   else gs_108 = "false";
   IndicatorShortName("Alert on Price " + gs_108 + " ");
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int l_ind_counted_0 = IndicatorCounted();
   int li_4 = Bars - l_ind_counted_0;
   for (int l_index_8 = 0; l_index_8 <= li_4; l_index_8++) {
      g_ibuf_100[l_index_8] = 40;
      g_ibuf_104[l_index_8] = -40;
   }
   if (Price_ceil != 0.0 && Price_floor != 0.0) {
      if (Price_ceil < Price_floor) {
         Alert("Price_ceil should higher than Price_floor");
         return (0);
      }
   }
   double ld_12 = NormalizeDouble(Bid, 4);
   int l_window_20 = WindowFind("Alert on Price " + gs_108 + " ");
   ObjectCreate("priceon", OBJ_LABEL, l_window_20, 0, 0);
   ObjectSet("priceon", OBJPROP_CORNER, 0);
   ObjectSet("priceon", OBJPROP_XDISTANCE, 360);
   ObjectSet("priceon", OBJPROP_YDISTANCE, 8);
   ObjectSetText("priceon", "Status alert ", 10, "Arial", White);
   if (AlertOnPrice == TRUE) {
      ObjectCreate("status", OBJ_LABEL, l_window_20, 0, 0);
      ObjectSet("status", OBJPROP_CORNER, 0);
      ObjectSet("status", OBJPROP_XDISTANCE, 430);
      ObjectSet("status", OBJPROP_YDISTANCE, 1);
      ObjectSetText("status", "ON", 20, "Arial", Lime);
   } else {
      ObjectCreate("status", OBJ_LABEL, l_window_20, 0, 0);
      ObjectSet("status", OBJPROP_CORNER, 0);
      ObjectSet("status", OBJPROP_XDISTANCE, 430);
      ObjectSet("status", OBJPROP_YDISTANCE, 1);
      ObjectSetText("status", "OFF", 20, "Arial", Red);
   }
   if (Price_ceil > 0.0 && ld_12 >= Price_ceil && AlertOnPrice == TRUE) {
      PlaySound(Son);
      ObjectCreate("price_c", OBJ_LABEL, l_window_20, 0, 0);
      ObjectSet("price_c", OBJPROP_CORNER, 0);
      ObjectSet("price_c", OBJPROP_XDISTANCE, 200);
      ObjectSet("price_c", OBJPROP_YDISTANCE, 1);
      ObjectSetText("price_c", "Price Ceil    " + DoubleToStr(Price_ceil, 4) + "", 9, "Chaney Extended", Red);
   } else {
      ObjectCreate("price_c", OBJ_LABEL, l_window_20, 0, 0);
      ObjectSet("price_c", OBJPROP_CORNER, 0);
      ObjectSet("price_c", OBJPROP_XDISTANCE, 200);
      ObjectSet("price_c", OBJPROP_YDISTANCE, 1);
      ObjectSetText("price_c", "Price Ceil    " + DoubleToStr(Price_ceil, 4) + "", 9, "Chaney Extended", White);
   }
   if (Price_floor > 0.0 && ld_12 <= Price_floor && AlertOnPrice == TRUE) {
      PlaySound(Son);
      ObjectCreate("price_f", OBJ_LABEL, l_window_20, 0, 0);
      ObjectSet("price_f", OBJPROP_CORNER, 0);
      ObjectSet("price_f", OBJPROP_XDISTANCE, 200);
      ObjectSet("price_f", OBJPROP_YDISTANCE, 12);
      ObjectSetText("price_f", "Price Floor " + DoubleToStr(Price_floor, 4) + "", 9, "Chaney Extended", Red);
   } else {
      ObjectCreate("price_f", OBJ_LABEL, l_window_20, 0, 0);
      ObjectSet("price_f", OBJPROP_CORNER, 0);
      ObjectSet("price_f", OBJPROP_XDISTANCE, 200);
      ObjectSet("price_f", OBJPROP_YDISTANCE, 12);
      ObjectSetText("price_f", "Price Floor " + DoubleToStr(Price_floor, 4) + "", 9, "Chaney Extended", White);
   }
   double ld_24 = (iHigh(Symbol(), PERIOD_D1, 0) - iLow(Symbol(), PERIOD_D1, 0)) / Point;
   if (ld_24 >= RangeFilter) {
      ObjectCreate("Drange", OBJ_LABEL, l_window_20, 0, 0);
      ObjectSet("Drange", OBJPROP_CORNER, 0);
      ObjectSet("Drange", OBJPROP_XDISTANCE, 500);
      ObjectSet("Drange", OBJPROP_YDISTANCE, 1);
      ObjectSetText("Drange", "Todays Range : " + DoubleToStr(ld_24, 0) + " pips", 18, "Impact", Yellow);
   } else {
      ObjectCreate("Drange", OBJ_LABEL, l_window_20, 0, 0);
      ObjectSet("Drange", OBJPROP_CORNER, 0);
      ObjectSet("Drange", OBJPROP_XDISTANCE, 500);
      ObjectSet("Drange", OBJPROP_YDISTANCE, 1);
      ObjectSetText("Drange", "Todays Range : " + DoubleToStr(ld_24, 0) + " pips", 18, "Impact", White);
   }
   return (0);
}