Navigation:Home > Content >

autofibophenomenon~.mq4

Time: 2017-01-16 | Download file:autofibophenomenon~.mq4


#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 LightBlue
#property indicator_color2 MediumBlue
#property indicator_color3 Olive
#property indicator_color4 White
#property indicator_color5 Red
#property indicator_color6 Blue

extern string FontName = "Arial";
extern int FontSize = 8;
extern int FontSizeLabel = 10;
extern bool UseOpenAlert = TRUE;
extern bool UseCloseAlert = TRUE;
extern bool UseEmail = TRUE;
double g_ibuf_104[];
double g_ibuf_108[];
double g_ibuf_112[];
double g_ibuf_116[];
double g_ibuf_120[];
double g_ibuf_124[];
double g_high_128;
double g_low_136;
double gd_144;
double gd_152;
double gd_160;
double gd_168;
double gd_176;
double gd_184;
double gd_192;
double gd_200;
double g_high_208;
double g_low_216;
double g_open_224;
double gd_232;
double gd_240;
double gd_248;
double gd_256;
double gd_264;
double gd_272;
double gd_280;
double gd_288;
string gs_296;
string g_str_concat_304;
double gd_unused_312;
double gd_320;
bool gi_328 = TRUE;
bool gi_332 = TRUE;
bool gi_unused_336 = TRUE;
bool gi_unused_340 = TRUE;
bool gi_unused_344 = TRUE;
bool gi_unused_348 = TRUE;
bool gi_unused_352 = TRUE;
bool gi_unused_356 = TRUE;
int g_bars_360 = -1;
int g_bars_364 = -1;
int g_bars_368 = -1;
int g_bars_372 = -1;

int deinit() {
   string name_8;
   Comment("");
   ObjectDelete("PrevDayHi");
   ObjectDelete("PrevDayLo");
   ObjectDelete("PrevDayOpen");
   ObjectDelete("PrevDayClose");
   ObjectDelete("fb");
   ObjectDelete("fs");
   ObjectDelete("fe");
   ObjectDelete("tp1");
   ObjectDelete("tp2");
   ObjectDelete("tp3");
   ObjectDelete("fb Line");
   ObjectDelete("fs Line");
   ObjectDelete("fe Line");
   ObjectDelete("tp1 Line");
   ObjectDelete("tp2 Line");
   ObjectDelete("tp3 Line");
   int objs_total_0 = ObjectsTotal();
   for (int li_4 = objs_total_0 - 1; li_4 >= 0; li_4--) {
      name_8 = ObjectName(li_4);
      if (StringFind(name_8, "myArrow_", 0) >= 0) ObjectDelete(name_8);
   }
   return (0);
}

int init() {
   SetIndexBuffer(0, g_ibuf_104);
   SetIndexBuffer(1, g_ibuf_108);
   SetIndexBuffer(2, g_ibuf_112);
   SetIndexBuffer(3, g_ibuf_116);
   SetIndexBuffer(4, g_ibuf_120);
   SetIndexBuffer(5, g_ibuf_124);
   SetIndexStyle(0, DRAW_NONE);
   SetIndexStyle(1, DRAW_NONE);
   SetIndexStyle(2, DRAW_NONE);
   SetIndexStyle(3, DRAW_NONE);
   SetIndexStyle(4, DRAW_ARROW, STYLE_SOLID, 4);
   SetIndexStyle(5, DRAW_ARROW, STYLE_SOLID, 4);
   SetIndexArrow(4, 233);
   SetIndexArrow(5, 234);
   SetIndexLabel(0, "Prev.Day High");
   SetIndexLabel(1, "Prev.Day Low");
   SetIndexLabel(2, "Prev.Day Open");
   SetIndexLabel(3, "Prev.Day Close");
   SetIndexLabel(4, "Arrow Sell");
   SetIndexLabel(5, "Arrow Buy");
   gs_296 = "Prev Hi-Lo levels";
   IndicatorShortName(gs_296);
   return (0);
}

int start() {
   int ind_counted_0 = IndicatorCounted();
   if (Period() > PERIOD_H4) {
      Comment("\nИндикатор ", gs_296, " работает на периодах больше H4");
      return (0);
   }
   if (ind_counted_0 < 0) return (0);
   int li_4 = Bars - ind_counted_0 - 1;
   for (int li_8 = li_4; li_8 >= 0; li_8--) {
      g_high_208 = High[iHighest(NULL, 0, MODE_HIGH, li_8 + 1)];
      g_low_216 = Low[iLowest(NULL, 0, MODE_LOW, li_8 + 1)];
      if (Open[li_8 + 1] > g_open_224) g_open_224 = Open[li_8 + 1];
      if (TimeDay(Time[li_8]) != TimeDay(Time[li_8 + 1])) {
         g_high_128 = g_high_208;
         g_low_136 = g_low_216;
         gd_144 = gd_232;
         gd_152 = Open[li_8];
         g_low_216 = Open[li_8];
         g_high_208 = Open[li_8];
         g_open_224 = Open[li_8];
         gd_232 = Open[li_8];
      }
      g_ibuf_104[li_8] = g_high_128;
      g_ibuf_108[li_8] = g_low_136;
      g_ibuf_112[li_8] = gd_144;
      g_ibuf_116[li_8] = gd_152;
   }
   gd_320 = NormalizeDouble(Close[0], Digits);
   if (Close[0] > gd_232) {
      gd_160 = g_high_128 - (g_high_128 - g_low_136) / 2.0;
      gd_176 = g_high_128 - 0.618 * (g_high_128 - g_low_136);
      gd_184 = 0.618 * (g_high_128 - g_low_136) + gd_160;
      gd_192 = g_high_128 - g_low_136 + gd_160;
      gd_200 = 1.618 * (g_high_128 - g_low_136) + gd_160;
      gd_240 = MathRound(10000.0 * (gd_160 - gd_176)) / 10000.0;
      gd_248 = MathRound(10000.0 * (gd_184 - gd_160)) / 10000.0;
      gd_256 = MathRound(10000.0 * (gd_192 - gd_160)) / 10000.0;
      gd_264 = MathRound(10000.0 * (gd_200 - gd_160)) / 10000.0;
      gd_272 = MathRound(10.0 * (gd_248 / gd_240)) / 10.0;
      gd_280 = MathRound(10.0 * (gd_256 / gd_240)) / 10.0;
      gd_288 = MathRound(10.0 * (gd_264 / gd_240)) / 10.0;
      ObjectDelete("fs Line");
      ObjectDelete("fs");
      f0_0("fb", " Buy Entry", Time[0], gd_160, FontSizeLabel, FontName, CLR_NONE);
      f0_2("fb Line", gd_160, White);
      f0_0("fe", " Stop Loss", Time[0], gd_176, FontSizeLabel, FontName, CLR_NONE);
      f0_2("fe Line", gd_176, OrangeRed);
      f0_0("tp1", " Take Profit 1", Time[0], gd_184, FontSizeLabel, FontName, CLR_NONE);
      f0_2("tp1 Line", gd_184, SpringGreen);
      f0_0("tp2", " Take Profit 2", Time[0], gd_192, FontSizeLabel, FontName, CLR_NONE);
      f0_2("tp2 Line", gd_192, SpringGreen);
      f0_0("tp3", " Take Profit 3", Time[0], gd_200, FontSizeLabel, FontName, CLR_NONE);
      f0_2("tp3 Line", gd_200, SpringGreen);
      if (gd_272 > 2.0 && gd_280 > 2.0 && gd_288 > 2.0) {
         Comment("\nNOW Trend   UP ", 
            "\nBUY - ", gd_160, 
            "\nStopLoss ", gd_176, 
            "\nTakeProfit 1 ", gd_184, " R/R : ", gd_272, "  Trade SIGNAL", 
            "\nTakeProfit 2 ", gd_192, " R/R Ratio : ", gd_280, " Trade ", 
         "\nTakeProtit 3 ", gd_200, " R/R : ", gd_288, " Trade SIGNAL ");
      } else {
         Comment("\nNOW Trend   UP ", 
            "\nBUY - ", gd_160, 
            "\nStopLoss ", gd_176, 
            "\nTakeProfit 1 ", gd_184, " R/R : ", gd_272, " NO TRADE SIGNAL", 
            "\nTakeProfit 2 ", gd_192, " R/R Ratio : ", gd_280, " NO TRADE ", 
         "\nTakeProfit 3 ", gd_200, " R/R : ", gd_288, " NO TRADE SIGNAL");
      }
      if (Low[2] <= gd_160 && High[1] > gd_160 && gi_328 == TRUE) {
         gi_328 = FALSE;
         gi_332 = TRUE;
         gi_unused_336 = TRUE;
         gi_unused_340 = TRUE;
         gi_unused_344 = TRUE;
         gi_unused_348 = TRUE;
         gi_unused_352 = TRUE;
         gi_unused_356 = TRUE;
      }
   } else {
      gd_168 = (g_high_128 - g_low_136) / 2.0 + g_low_136;
      gd_176 = 0.618 * (g_high_128 - g_low_136) + g_low_136;
      gd_184 = 0.618 * (g_low_136 - g_high_128) + gd_168;
      gd_192 = g_low_136 - g_high_128 + gd_168;
      gd_200 = 1.618 * (g_low_136 - g_high_128) + gd_168;
      gd_240 = MathRound(10000.0 * (gd_168 - gd_176)) / 10000.0;
      gd_248 = MathRound(10000.0 * (gd_184 - gd_168)) / 10000.0;
      gd_256 = MathRound(10000.0 * (gd_192 - gd_168)) / 10000.0;
      gd_264 = MathRound(10000.0 * (gd_200 - gd_168)) / 10000.0;
      gd_272 = MathRound(10.0 * (gd_248 / gd_240)) / 10.0;
      gd_280 = MathRound(10.0 * (gd_256 / gd_240)) / 10.0;
      gd_288 = 10.0 * (gd_264 / gd_240) / 10.0;
      ObjectDelete("fb Line");
      ObjectDelete("fb");
      f0_0("fs", " Sell Entry", Time[0], gd_168, FontSizeLabel, FontName, CLR_NONE);
      f0_2("fs Line", gd_168, Red);
      f0_0("fe", " Stop Loss", Time[0], gd_176, FontSizeLabel, FontName, CLR_NONE);
      f0_2("fe Line", gd_176, OrangeRed);
      f0_0("tp1", " Take Profit 1", Time[0], gd_184, FontSizeLabel, FontName, CLR_NONE);
      f0_2("tp1 Line", gd_184, SpringGreen);
      f0_0("tp2", " Take Profit 2", Time[0], gd_192, FontSizeLabel, FontName, CLR_NONE);
      f0_2("tp2 Line", gd_192, SpringGreen);
      f0_0("tp3", " Take Profit 3", Time[0], gd_200, FontSizeLabel, FontName, CLR_NONE);
      f0_2("tp3 Line", gd_200, SpringGreen);
      if (gd_272 > 2.0 && gd_280 > 2.0 && gd_288 > 2.0) {
         Comment("\nNOW Trend  Down ", 
            "\nSELL - ", gd_168, 
            "\nStopLoss ", gd_176, 
            "\nTakeProfit 1 ", gd_184, " R/R Ratio : ", gd_272, "  Trade SIGNAL", 
            "\nTakeProfit 2 ", gd_192, " R/R Ratio : ", gd_280, " Trade ", 
         "\nTakeProfit 3 ", gd_200, " R/R : ", gd_288, " Trade SIGNAL");
      } else {
         Comment("\nNOW Trend  Down ", 
            "\nSELL - ", gd_168, 
            "\nStopLoss ", gd_176, 
            "\nTakeProfit 1 ", gd_184, " R/R Ratio : ", gd_272, " NO TRADE SIGNAL", 
            "\nTakeProfit 2 ", gd_192, " R/R Ratio : ", gd_280, " NO TRADE ", 
         "\nTakeProfit 3 ", gd_200, " R/R : ", gd_288, " NO TRADE SIGNAL");
      }
      if (High[2] >= gd_168 && Low[1] < gd_168 && gi_332 == TRUE) {
         gi_332 = FALSE;
         gi_328 = TRUE;
         gi_unused_336 = TRUE;
         gi_unused_340 = TRUE;
         gi_unused_344 = TRUE;
         gi_unused_348 = TRUE;
         gi_unused_352 = TRUE;
         gi_unused_356 = TRUE;
      }
   }
   gd_unused_312 = gd_320;
   if (UseOpenAlert && Bars != g_bars_360) {
      if (Open[1] < gd_160 && Close[1] > gd_160 && gd_160 < gd_184) {
         g_str_concat_304 = StringConcatenate("AUTOFIBO: ", " BUY ", Symbol());
         Alert(g_str_concat_304);
         if (UseEmail) SendMail("Alert signal " + TimeToStr(TimeCurrent()), g_str_concat_304);
         f0_1("myArrow_", 0, Time[0], gd_160, Green);
      }
      if (Open[1] > gd_160 && Close[1] < gd_160 && gd_160 > gd_184) {
         g_str_concat_304 = StringConcatenate("AUTOFIBO: ", " SELL ", Symbol());
         Alert(g_str_concat_304);
         if (UseEmail) SendMail("Alert signal " + TimeToStr(TimeCurrent()), g_str_concat_304);
         f0_1("myArrow_", 1, Time[0], gd_160, Red);
      }
      g_bars_360 = Bars;
   }
   if (UseCloseAlert && Bars != g_bars_364) {
      if (Low[0] < gd_184 && High[0] > gd_184) {
         g_str_concat_304 = StringConcatenate("AUTOFIBO: ", " Close for tp1 ", Symbol());
         Alert(g_str_concat_304);
         if (UseEmail) SendMail("Alert signal " + TimeToStr(TimeCurrent()), g_str_concat_304);
         g_bars_364 = Bars;
      }
   }
   if (UseCloseAlert && Bars != g_bars_368) {
      if (Low[0] < gd_192 && High[0] > gd_192) {
         g_str_concat_304 = StringConcatenate("AUTOFIBO: ", " Close for tp2 ", Symbol());
         Alert(g_str_concat_304);
         if (UseEmail) SendMail("Alert signal " + TimeToStr(TimeCurrent()), g_str_concat_304);
         g_bars_368 = Bars;
      }
   }
   if (UseCloseAlert && Bars != g_bars_372) {
      if (Low[0] < gd_200 && High[0] > gd_200) {
         g_str_concat_304 = StringConcatenate("AUTOFIBO: ", " Close for tp3 ", Symbol());
         Alert(g_str_concat_304);
         if (UseEmail) SendMail("Alert signal " + TimeToStr(TimeCurrent()), g_str_concat_304);
         g_bars_372 = Bars;
      }
   }
   return (0);
}

void f0_0(string a_name_0, string a_text_8, int a_datetime_16, double ad_20, int a_fontsize_28, string a_fontname_32, color a_color_40) {
   if (ObjectFind(a_name_0) == 0 || ObjectCreate(a_name_0, OBJ_TEXT, 0, 0, 0)) {
      ObjectSet(a_name_0, OBJPROP_PRICE1, ad_20);
      ObjectSet(a_name_0, OBJPROP_TIME1, a_datetime_16);
      ObjectSetText(a_name_0, a_text_8, a_fontsize_28, a_fontname_32, a_color_40);
   }
}

void f0_2(string a_name_0, double ad_8, color a_color_16) {
   if (ObjectFind(a_name_0) == 0 || ObjectCreate(a_name_0, OBJ_HLINE, 0, 0, 0)) {
      ObjectSet(a_name_0, OBJPROP_PRICE1, ad_8);
      ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet(a_name_0, OBJPROP_COLOR, a_color_16);
      ObjectSet(a_name_0, OBJPROP_WIDTH, 2);
   }
}

void f0_1(string as_0, int ai_8, int a_datetime_12, double ad_16, color a_color_24) {
   string name_28 = as_0 + DoubleToStr(a_datetime_12, 0);
   if (ObjectFind(name_28) == 0 || ObjectCreate(name_28, OBJ_ARROW, 0, 0, 0)) {
      ObjectSet(name_28, OBJPROP_PRICE1, ad_16);
      ObjectSet(name_28, OBJPROP_TIME1, a_datetime_12);
      ObjectSet(name_28, OBJPROP_COLOR, a_color_24);
      ObjectSet(name_28, OBJPROP_WIDTH, 4);
      if (ai_8 == 0) ObjectSet(name_28, OBJPROP_ARROWCODE, 233);
      if (ai_8 == 1) ObjectSet(name_28, OBJPROP_ARROWCODE, 234);
   }
}

Recommend