/*
   
*/
#property copyright " Copyright © 2008, Forex Day Monster."
#property link      " http://www.forexprofitmonster.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 White

double g_ibuf_80[];
double g_ibuf_84[];

void SetLoopCount(int ai_unused_0) {
}

void SetIndexValue(int ai_0, double ad_4) {
   g_ibuf_80[ai_0] = ad_4;
}

void SetIndexValue2(int ai_0, double ad_4) {
   g_ibuf_84[ai_0] = ad_4;
}

int MoveObject(string a_name_0, int ai_8, int a_datetime_12, double ad_16, int a_datetime_24 = 0, double ad_28 = 0.0, color a_color_36 = -1, int ai_unused_40 = 0, int ai_unused_44 = 0) {
   int li_48;
   if (ObjectFind(a_name_0) != -1) {
      li_48 = ObjectType(a_name_0);
      if (li_48 == 0 || li_48 == 1 || li_48 == 3 || li_48 == 21 || li_48 == 22 || li_48 == 23) return (ObjectMove(a_name_0, 0, a_datetime_12, ad_16));
      if (li_48 == 7 || li_48 == 8 || li_48 == 9 || li_48 == 10 || li_48 == 11 || li_48 == 12 || li_48 == 13 || li_48 == 16 || li_48 == 18 || li_48 == 20 || li_48 == 2 ||
         li_48 == 6 || li_48 == 4) return (ObjectMove(a_name_0, 0, a_datetime_12, ad_16) && ObjectMove(a_name_0, 1, a_datetime_24, ad_28));
   } else return (ObjectCreate(a_name_0, ai_8, 0, a_datetime_12, ad_16, a_datetime_24, ad_28, 0, 0) && ObjectSet(a_name_0, OBJPROP_COLOR, a_color_36));
   return (0);
}

int init() {
   SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID);
   SetIndexBuffer(0, g_ibuf_80);
   SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID);
   SetIndexBuffer(1, g_ibuf_84);
   return (0);
}

int start() {
   string ls_0 = "2015.11.01";
   int l_str2time_8 = StrToTime(ls_0);
   if (TimeCurrent() >= l_str2time_8) {
      Alert(" Trial version has expired! Email support@forexprofitmonster.com with broker account number for rights to full version!");
      return (0);
   }
   int li_12 = 0;
   double l_high_16 = 0;
   double l_low_24 = 0;
   SetLoopCount(0);
   for (li_12 = Bars - 1; li_12 >= 0; li_12--) {
      if (Close[li_12 + 2] >= iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, li_12 + 2) && Close[li_12 + 1] < iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, li_12 + 1)) l_high_16 = High[iHighest(NULL, 0, MODE_HIGH, li_12 + 20, 20)];
      if (Close[li_12 + 2] <= iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, li_12 + 2) && Close[li_12 + 1] > iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, li_12 + 1)) l_low_24 = Low[iLowest(NULL, 0, MODE_LOW, li_12 + 20, 20)];
      SetIndexValue(li_12, l_high_16);
      SetIndexValue2(li_12, l_low_24);
      if (Close[li_12 + 1] < l_low_24) MoveObject("trade", OBJ_FIBO, Time[li_12 + 1], l_low_24, Time[li_12 + 1], l_high_16, Green, 1, 1);
      else {
         if (Close[li_12 + 1] > l_high_16) MoveObject("trade", OBJ_FIBO, Time[li_12 + 1], l_high_16, Time[li_12 + 1], l_low_24, Green, 1, 1);
         else
            if (Close[li_12 + 1] < l_high_16 && Close[li_12 + 1] > l_low_24) MoveObject("trade", OBJ_FIBO, Time[li_12 + 1], l_high_16, Time[li_12 + 1], l_low_24, Green, 1, 1);
      }
   }
   return (0);
}