//+------------------------------------------------------------------+
//|                                  __________ABHAFXS STARS V20.mq4 |
//|                    Copyright © 2008, MetaQuotes SoAYftware Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes SoAYftware Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 DarkOrange
#property indicator_color2 Aqua
#property indicator_color3 Aqua
#property indicator_color4 Aqua
#property indicator_color5 Aqua
#property indicator_color6 DarkOrange
#property indicator_color7 DarkOrange
#property indicator_color8 DarkOrange


double g_ibuf_76[];
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
double g_ibuf_104[];
extern bool Commentt = TRUE;
extern int a = 1;
int GMTshift=0;
int g_timeframe_116 = PERIOD_D1;
double gd_120;
double gd_128;
double gd_136;
double gd_144;
double gd_152;
double gd_160;
double gd_168;
double gd_176;
double gd_184;
double gd_200;

int init() {
   SetIndexBuffer(0, g_ibuf_76);
   SetIndexBuffer(1, g_ibuf_80);
   
   SetIndexBuffer(2, g_ibuf_84);
   SetIndexBuffer(3, g_ibuf_88);
   SetIndexBuffer(4, g_ibuf_92);
   SetIndexBuffer(5, g_ibuf_96);
   SetIndexBuffer(6, g_ibuf_100);
   SetIndexBuffer(7, g_ibuf_104);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 0);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(7, DRAW_LINE, STYLE_SOLID, 0);
   SetIndexStyle(8, DRAW_LINE, STYLE_SOLID, 0);
   SetIndexStyle(9, DRAW_LINE, STYLE_SOLID, 0);
   SetIndexStyle(11, DRAW_LINE, STYLE_SOLID, 0);
   return (0);
}

int deinit() {
   ObjectDelete("txtWeekS4");
   ObjectDelete("txtWeekR4");
   ObjectDelete("WeekR4");
   ObjectDelete("WeekP");
   ObjectDelete("WeekR1");
   ObjectDelete("WeekR11");
   ObjectDelete("WeekR2");
   ObjectDelete("WeekR3");
   ObjectDelete("WeekS1");
   ObjectDelete("WeekS4");
   ObjectDelete("WeekS2");
   ObjectDelete("WeekS3");
   ObjectDelete("txtWeekP");
   ObjectDelete("txtWeekR1");
   ObjectDelete("txtWeekR11");
   ObjectDelete("txtWeekR2");
   ObjectDelete("txtWeekR3");
   ObjectDelete("txtWeekS1");
   ObjectDelete("txtWeekS2");
   ObjectDelete("txtWeekS3");
   
   Comment("");
   return (0);
}

int start() {
   int l_shift_4;
   int li_8 = IndicatorCounted();
   if (li_8 < 0) return (-1);
   if (li_8 > 0) li_8--;
   int li_12 = Bars - li_8;
   for (int li_0 = li_12 - 1; li_0 >= 0; li_0--) {
      l_shift_4 = iBarShift(Symbol(), g_timeframe_116, Time[li_0], FALSE);
      gd_176 = iHigh(Symbol(), g_timeframe_116, l_shift_4) + iLow(Symbol(), g_timeframe_116, l_shift_4 + a);
      gd_120 = (iHigh(Symbol(), g_timeframe_116, l_shift_4 + a) + iLow(Symbol(), g_timeframe_116, l_shift_4 + a) + iClose(Symbol(), g_timeframe_116, l_shift_4 + a)) / 3.0;
      gd_200 = iHigh(Symbol(), g_timeframe_116, l_shift_4 + a) - iLow(Symbol(), g_timeframe_116, l_shift_4 + a);
      gd_128 = gd_176 / 2.0;
      if (iClose(Symbol(), g_timeframe_116, l_shift_4 + a) > gd_120) gd_152 = gd_128 + gd_200;
      if (iClose(Symbol(), g_timeframe_116, l_shift_4 + a) < gd_120) gd_152 = gd_128 - gd_200;
      if (Commentt) {
         if (iClose(Symbol(), g_timeframe_116, l_shift_4 + a) > gd_120) Comment("ABHA TREND <<<<< UP  >>>>> ENTRY <<<<<<<< [[BUY  LEVEL AT]] >>>>   ", gd_120,   " <<<< [[TARGET]] >>>> ", gd_152,", <<<<    ");
         if (iClose(Symbol(), g_timeframe_116, l_shift_4 + a) < gd_120) Comment("ABHA TREND <<<<< DOWN >>>>> ENTRY <<<<<<<< [[SELL LEVEL AT]] >>>>  ", gd_120,   "  <<<< [[TARGET]] >>>> ", gd_152,", <<<<   ");
         
      }
      g_ibuf_80[li_0] = gd_128;
      SetPrice("WeekR1", Time[li_0], gd_128, Aqua);
      SetText("txtWeekR1", "TREND ", Time[li_0], gd_128, Aqua);
      g_ibuf_84[li_0] = gd_136;
      SetPrice("WeekS1", Time[li_0], gd_136, Aqua);
      SetText("txtWeekS1", "ENTRY ", Time[li_0], gd_136, Aqua);
      g_ibuf_88[li_0] = gd_144;
      SetPrice("WeekR2", Time[li_0], gd_144, Aqua);
      SetText("txtWeekR2", "W-R100%", Time[li_0], gd_144, Aqua);
      g_ibuf_92[li_0] = gd_152;
      SetPrice("WeekS2", Time[li_0], gd_152, Aqua);
      SetText("txtWeekS2", "TREND", Time[li_0], gd_152, Aqua);
      g_ibuf_96[li_0] = gd_160;
      SetPrice("WeekR3", Time[li_0], gd_160, DarkOrange);
      SetText("txtWeekR3", "W-R123%", Time[li_0], gd_160, DarkOrange);
      g_ibuf_100[li_0] = gd_168;
      SetPrice("WeekS3", Time[li_0], gd_168, DarkOrange);
      SetText("txtWeekS3", "W-S123%", Time[li_0], gd_168, DarkOrange);
      g_ibuf_104[li_0] = gd_184;
      SetPrice("WeekR4", Time[li_0], gd_184, DarkOrange);
      SetText("txtWeekR4", "W-R23%", Time[li_0], gd_184, DarkOrange);
      g_ibuf_76[li_0] = gd_120;
      SetPrice("WeekS4", Time[li_0], gd_120, DarkOrange);
      SetText("txtWeekS4", "ENTRY", Time[li_0], gd_120, DarkOrange);
      
      
   }
   return (0);
}

void SetPrice(string a_name_0, int a_datetime_8, double a_price_12, color a_color_20) {
   if (ObjectFind(a_name_0) == -1) {
      ObjectCreate(a_name_0, OBJ_ARROW, 0, a_datetime_8, a_price_12);
      ObjectSet(a_name_0, OBJPROP_COLOR, a_color_20);
      ObjectSet(a_name_0, OBJPROP_WIDTH, 2);
      ObjectSet(a_name_0, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
      return;
   }
   ObjectSet(a_name_0, OBJPROP_TIME1, a_datetime_8);
   ObjectSet(a_name_0, OBJPROP_PRICE1, a_price_12);
   ObjectSet(a_name_0, OBJPROP_COLOR, a_color_20);
   ObjectSet(a_name_0, OBJPROP_WIDTH, 2);
   ObjectSet(a_name_0, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
}

void SetText(string a_name_0, string a_text_8, int a_datetime_16, double a_price_20, color a_color_28) {
   if (ObjectFind(a_name_0) == -1) {
      ObjectCreate(a_name_0, OBJ_TEXT, 0, a_datetime_16, a_price_20);
      ObjectSetText(a_name_0, a_text_8, 9, "Arial", a_color_28);
      ObjectSet(a_name_0, OBJPROP_CORNER, 2);
      return;
   }
   ObjectSet(a_name_0, OBJPROP_TIME1, a_datetime_16);
   ObjectSet(a_name_0, OBJPROP_PRICE1, a_price_20);
   ObjectSetText(a_name_0, a_text_8, 9, "Arial", a_color_28);
   ObjectSet(a_name_0, OBJPROP_CORNER, 2);
}