Navigation:Home > Content >

14_by_Trend_mod.mq4

Time: 2014-07-08 | Download file:14_by_Trend_mod.mq4

#property copyright "Copyright © 2012, [email protected]"
#property link      ""

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Gold
#property indicator_color4 Navy

extern bool withLevels = TRUE;
extern bool withReversBar = FALSE;
double G_ibuf_84[];
double G_ibuf_88[];
double G_ibuf_92[];
double G_ibuf_96[];

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   IndicatorBuffers(4);
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(0, G_ibuf_84);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(1, G_ibuf_88);
   SetIndexStyle(2, DRAW_HISTOGRAM);
   SetIndexBuffer(2, G_ibuf_92);
   SetIndexStyle(3, DRAW_HISTOGRAM);
   SetIndexBuffer(3, G_ibuf_96);
   string Ls_0 = "Тренд и Импульс";
   IndicatorShortName(Ls_0);
   SetIndexLabel(0, Ls_0);
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int Li_4;
   int Li_8;
   int lowest_12;
   int highest_16;
   double open_28;
   double open_36;
   double ihigh_44;
   double ilow_52;
   double ima_60;
   double ima_68;
   double ibands_76;
   double ibands_84;
   double ienvelopes_92;
   double ienvelopes_100;
   double Ld_unused_108;
   double Ld_unused_116;
   double Ld_124;
   double Ld_132;
   double Ld_140;
   double Ld_148;
   double Ld_156;
   double Ld_164;
   double iclose_172;
/*   if (Period() != PERIOD_H1) {
      Comment("ТОЛЬКО ДЛЯ ГРАФИКА 1 ЧАС!!! ПЕРЕКЛЮЧИТЬ НА Н1!!!");
      return (0);
   }*/
   double Ld_20 = 0;
   for (int bars_0 = Bars; bars_0 >= 0; bars_0--) {
      lowest_12 = 0;
      highest_16 = 0;
      G_ibuf_96[bars_0] = 0;
      if (TimeHour(Time[bars_0]) == 0) {
         open_36 = Open[bars_0];
         open_28 = Open[bars_0 + 24];
         Li_4 = iHighest(NULL, 0, MODE_CLOSE, 24, bars_0 + 1);
         ihigh_44 = Close[Li_4];
         Li_4 = iLowest(NULL, 0, MODE_CLOSE, 24, bars_0 + 1);
         ilow_52 = Close[Li_4];
         highest_16 = iHighest(NULL, 0, MODE_HIGH, 24, bars_0 + 24);
         Ld_unused_108 = High[highest_16];
         lowest_12 = iLowest(NULL, 0, MODE_LOW, 24, bars_0 + 24);
         Ld_unused_116 = Low[lowest_12];
      }
      Ld_20 = Volume[bars_0] / 100.0;
      ima_60 = iMA(NULL, 0, 5, 2, MODE_EMA, PRICE_CLOSE, bars_0);
      ima_68 = iMA(NULL, 0, 5, 0, MODE_SMA, PRICE_CLOSE, bars_0);
      if (open_36 > open_28 || Close[bars_0] > open_36) Li_8 = 1;
      if (open_36 < open_28 || Close[bars_0] < open_36) Li_8 = -1;
      if (Li_8 == 1) {
         G_ibuf_84[bars_0] = Ld_20;
         G_ibuf_88[bars_0] = 0;
         G_ibuf_92[bars_0] = 0;
         if (Close[bars_0] < Open[bars_0] && MathAbs(Close[bars_0] - Open[bars_0]) > 5.0 * Point && High[bars_0] > ima_60 && Close[bars_0] < ima_60 && TimeHour(Time[bars_0]) < 19) G_ibuf_92[bars_0] = -1.0 * Ld_20;
         if (Close[bars_0] > Open[bars_0] && MathAbs(Close[bars_0] - Open[bars_0]) > 5.0 * Point && Low[bars_0] < ima_60 && Close[bars_0] > ima_60 && TimeHour(Time[bars_0]) < 19) G_ibuf_92[bars_0] = Ld_20;
      }
      if (Li_8 == -1) {
         G_ibuf_84[bars_0] = 0;
         G_ibuf_88[bars_0] = -1.0 * Ld_20;
         G_ibuf_92[bars_0] = 0;
         if (Close[bars_0] > Open[bars_0] && MathAbs(Close[bars_0] - Open[bars_0]) > 5.0 * Point && Low[bars_0] < ima_60 && Close[bars_0] > ima_60 && TimeHour(Time[bars_0]) < 19) G_ibuf_92[bars_0] = Ld_20;
         if (Close[bars_0] < Open[bars_0] && MathAbs(Close[bars_0] - Open[bars_0]) > 5.0 * Point && High[bars_0] > ima_60 && Close[bars_0] < ima_60 && TimeHour(Time[bars_0]) < 19) G_ibuf_92[bars_0] = -1.0 * Ld_20;
      }
      if (open_36 < open_28 && Close[bars_0] > ilow_52) {
         G_ibuf_84[bars_0] = Ld_20;
         G_ibuf_88[bars_0] = 0;
      }
      if (open_36 > open_28 && Close[bars_0] < ihigh_44) {
         G_ibuf_84[bars_0] = 0;
         G_ibuf_88[bars_0] = -1.0 * Ld_20;
      }
      if (withReversBar) {
         if (G_ibuf_84[bars_0 + 1] > 0.0 && G_ibuf_92[bars_0] < 0.0) G_ibuf_96[bars_0] = Ld_20;
         if (G_ibuf_88[bars_0 + 1] < 0.0 && G_ibuf_92[bars_0] > 0.0) G_ibuf_96[bars_0] = -1.0 * Ld_20;
         if (G_ibuf_96[bars_0] != 0.0) G_ibuf_92[bars_0] = 0;
      } else G_ibuf_96[bars_0] = 0;
      ibands_76 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_UPPER, bars_0);
      ibands_84 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_LOWER, bars_0);
      ienvelopes_92 = iEnvelopes(NULL, 0, 13, MODE_SMA, 0, PRICE_CLOSE, 0.2, MODE_UPPER, bars_0);
      ienvelopes_100 = iEnvelopes(NULL, 0, 13, MODE_SMA, 0, PRICE_CLOSE, 0.2, MODE_LOWER, bars_0);
   }
   if (iClose(NULL, PERIOD_D1, 0) < iOpen(NULL, PERIOD_D1, 0)) {
      if (Hour() > 12) f0_1("txtАмерика", 0, iHigh(NULL, PERIOD_D1, 0), "Америка редко меняет Тренд/Импульс, но часто делает вид", Blue, 8);
   } else
      if (Hour() > 12) f0_1("txtАмерика", 0, iLow(NULL, PERIOD_D1, 0), "Америка редко меняет Тренд/Импульс, но часто делает вид", Blue, 8);
   if (Hour() > 15)
      if (ObjectFind("txtАмерика") > -1) ObjectDelete("txtАмерика");
   if (withLevels) {
      f0_0("Хай", Hour() + 25, ihigh_44, 0, ihigh_44, DarkGreen, 5, STYLE_SOLID, FALSE, TRUE);
      f0_0("Лоу", Hour() + 25, ilow_52, 0, ilow_52, Red, 5, STYLE_SOLID, FALSE, TRUE);
      ilow_52 = iLow(NULL, PERIOD_D1, 1);
      ihigh_44 = iHigh(NULL, PERIOD_D1, 1);
      iclose_172 = iClose(NULL, PERIOD_D1, 1);
      Ld_124 = 0.382;
      if (iClose(NULL, PERIOD_D1, 1) > iOpen(NULL, PERIOD_D1, 1)) Ld_124 = 0.618;
      f0_0("38%", Hour() + 25, ilow_52 + Ld_124 * (ihigh_44 - ilow_52), 0, ilow_52 + Ld_124 * (ihigh_44 - ilow_52), Aqua, 3, STYLE_SOLID, FALSE, TRUE);
      f0_0("50%", Hour() + 25, (ilow_52 + ihigh_44) / 2.0, 0, (ilow_52 + ihigh_44) / 2.0, Aqua, 5, STYLE_SOLID, FALSE, TRUE);
      f0_0("Pivot", Hour() + 25, (ilow_52 + ihigh_44 + iclose_172) / 3.0, 0, (ilow_52 + ihigh_44 + iclose_172) / 3.0, Purple, 5, STYLE_SOLID, FALSE, TRUE);
      Ld_132 = 0.23 * (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1));
      Ld_140 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / 2.0;
      Ld_148 = 0.61 * (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1));
      Ld_156 = iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1) - 3.0 * Point;
      Ld_164 = 1.61 * (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1));
      f0_0("DailyФибо_123_High", 7, iHigh(NULL, PERIOD_D1, 1) + Ld_132, 0, iHigh(NULL, PERIOD_D1, 1) + Ld_132, Blue, 3, STYLE_SOLID, FALSE, TRUE);
      f0_1("txtDailyФибо_123_High", 0, iHigh(NULL, PERIOD_D1, 1) + Ld_132, "                                " + DoubleToStr(iHigh(NULL, PERIOD_D1, 1) + Ld_132, 4) + "(+123%)",
         Blue, 8);
      f0_0("DailyФибо_123_Low", 7, iLow(NULL, PERIOD_D1, 1) - Ld_132, 0, iLow(NULL, PERIOD_D1, 1) - Ld_132, Blue, 3, STYLE_SOLID, FALSE, TRUE);
      f0_1("txtDailyФибо_123_Low", 0, iLow(NULL, PERIOD_D1, 1) - Ld_132, "                                " + DoubleToStr(iLow(NULL, PERIOD_D1, 1) - Ld_132, 4) + "(-123%)",
         Blue, 8);
      f0_0("DailyФибо_138_High", 7, iHigh(NULL, PERIOD_D1, 1) + Ld_140 - 2.0 * Point, 0, iHigh(NULL, PERIOD_D1, 1) + Ld_140 - 2.0 * Point, Blue, 5, STYLE_SOLID, FALSE,
         TRUE);
      f0_1("txtDailyФибо_138_High", 0, iHigh(NULL, PERIOD_D1, 1) + Ld_140 - 2.0 * Point, "                                " + DoubleToStr(iHigh(NULL, PERIOD_D1, 1) + Ld_140 - 2.0 * Point,
         4) + "(+138%)", Blue, 8);
      f0_0("DailyФибо_138_Low", 7, iLow(NULL, PERIOD_D1, 1) - Ld_140 + 2.0 * Point, 0, iLow(NULL, PERIOD_D1, 1) - Ld_140 + 2.0 * Point, Blue, 5, STYLE_SOLID, FALSE, TRUE);
      f0_1("txtDailyФибо_138_Low", 0, iLow(NULL, PERIOD_D1, 1) - Ld_140 + 2.0 * Point, "                                " + DoubleToStr(iLow(NULL, PERIOD_D1, 1) - Ld_140 +
         2.0 * Point, 4) + "(-138%)", Blue, 8);
      f0_0("DailyФибо_161_High", 7, iHigh(NULL, PERIOD_D1, 1) + Ld_148 - 2.0 * Point, 0, iHigh(NULL, PERIOD_D1, 1) + Ld_148 - 2.0 * Point, Blue, 5, STYLE_SOLID, FALSE,
         TRUE);
      f0_1("txtDailyФибо_161_High", 0, iHigh(NULL, PERIOD_D1, 1) + Ld_148 - 2.0 * Point, "                                " + DoubleToStr(iHigh(NULL, PERIOD_D1, 1) + Ld_148 - 2.0 * Point,
         4) + "(+161%)", Blue, 8);
      f0_0("DailyФибо_161_Low", 7, iLow(NULL, PERIOD_D1, 1) - Ld_148 + 2.0 * Point, 0, iLow(NULL, PERIOD_D1, 1) - Ld_148 + 2.0 * Point, Blue, 5, STYLE_SOLID, FALSE, TRUE);
      f0_1("txtDailyФибо_161_Low", 0, iLow(NULL, PERIOD_D1, 1) - Ld_148 + 2.0 * Point, "                                " + DoubleToStr(iLow(NULL, PERIOD_D1, 1) - Ld_148 +
         2.0 * Point, 4) + "(-161%)", Blue, 8);
      f0_0("DailyФибо_200_High", 7, iHigh(NULL, PERIOD_D1, 1) + Ld_156 - 2.0 * Point, 0, iHigh(NULL, PERIOD_D1, 1) + Ld_156 - 2.0 * Point, Blue, 5, STYLE_SOLID, FALSE,
         TRUE);
      f0_1("txtDailyФибо_200_High", 0, iHigh(NULL, PERIOD_D1, 1) + Ld_156 - 2.0 * Point, "                                " + DoubleToStr(iHigh(NULL, PERIOD_D1, 1) + Ld_156 - 2.0 * Point,
         4) + "(+200%)", Blue, 8);
      f0_0("DailyФибо_200_Low", 7, iLow(NULL, PERIOD_D1, 1) - Ld_156 + 2.0 * Point, 0, iLow(NULL, PERIOD_D1, 1) - Ld_156 + 2.0 * Point, Blue, 5, STYLE_SOLID, FALSE, TRUE);
      f0_1("txtDailyФибо_200_Low", 0, iLow(NULL, PERIOD_D1, 1) - Ld_156 + 2.0 * Point, "                                " + DoubleToStr(iLow(NULL, PERIOD_D1, 1) - Ld_156 +
         2.0 * Point, 4) + "(-200%)", Blue, 8);
      f0_0("DailyФибо_261_High", 7, iHigh(NULL, PERIOD_D1, 1) + Ld_164 - 2.0 * Point, 0, iHigh(NULL, PERIOD_D1, 1) + Ld_164 - 2.0 * Point, Blue, 5, STYLE_SOLID, FALSE,
         TRUE);
      f0_1("txtDailyФибо_261_High", 0, iHigh(NULL, PERIOD_D1, 1) + Ld_164 - 2.0 * Point, "                                " + DoubleToStr(iHigh(NULL, PERIOD_D1, 1) + Ld_164 - 2.0 * Point,
         4) + "(+261%)", Blue, 8);
      f0_0("DailyФибо_261_Low", 7, iLow(NULL, PERIOD_D1, 1) - Ld_164 + 2.0 * Point, 0, iLow(NULL, PERIOD_D1, 1) - Ld_164 + 2.0 * Point, Blue, 5, STYLE_SOLID, FALSE, TRUE);
      f0_1("txtDailyФибо_261_Low", 0, iLow(NULL, PERIOD_D1, 1) - Ld_164 + 2.0 * Point, "                                " + DoubleToStr(iLow(NULL, PERIOD_D1, 1) - Ld_164 +
         2.0 * Point, 4) + "(-261%)", Blue, 8);
   } else {
      if (ObjectFind("Хай") > -1) ObjectDelete("Хай");
      if (ObjectFind("Лоу") > -1) ObjectDelete("Лоу");
      if (ObjectFind("38%") > -1) ObjectDelete("38%");
      if (ObjectFind("50%") > -1) ObjectDelete("50%");
      if (ObjectFind("Pivot") > -1) ObjectDelete("Pivot");
      if (ObjectFind("DailyФибо_123_High") > -1) ObjectDelete("DailyФибо_123_High");
      if (ObjectFind("txtDailyФибо_123_High") > -1) ObjectDelete("txtDailyФибо_123_High");
      if (ObjectFind("DailyФибо_123_Low") > -1) ObjectDelete("DailyФибо_123_Low");
      if (ObjectFind("txtDailyФибо_123_Low") > -1) ObjectDelete("txtDailyФибо_123_Low");
      if (ObjectFind("DailyФибо_138_High") > -1) ObjectDelete("DailyФибо_138_High");
      if (ObjectFind("txtDailyФибо_138_High") > -1) ObjectDelete("txtDailyФибо_138_High");
      if (ObjectFind("DailyФибо_138_Low") > -1) ObjectDelete("DailyФибо_138_Low");
      if (ObjectFind("txtDailyФибо_138_Low") > -1) ObjectDelete("txtDailyФибо_138_Low");
      if (ObjectFind("DailyФибо_161_High") > -1) ObjectDelete("DailyФибо_161_High");
      if (ObjectFind("txtDailyФибо_161_High") > -1) ObjectDelete("txtDailyФибо_161_High");
      if (ObjectFind("DailyФибо_161_Low") > -1) ObjectDelete("DailyФибо_161_Low");
      if (ObjectFind("txtDailyФибо_161_Low") > -1) ObjectDelete("txtDailyФибо_161_Low");
      if (ObjectFind("DailyФибо_200_Low") > -1) ObjectDelete("DailyФибо_200_Low");
      if (ObjectFind("txtDailyФибо_200_Low") > -1) ObjectDelete("txtDailyФибо_200_Low");
      if (ObjectFind("DailyФибо_261_Low") > -1) ObjectDelete("DailyФибо_261_Low");
      if (ObjectFind("txtDailyФибо_261_Low") > -1) ObjectDelete("txtDailyФибо_261_Low");
   }
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   if (ObjectFind("Хай") > -1) ObjectDelete("Хай");
   if (ObjectFind("Лоу") > -1) ObjectDelete("Лоу");
   if (ObjectFind("38%") > -1) ObjectDelete("38%");
   if (ObjectFind("50%") > -1) ObjectDelete("50%");
   if (ObjectFind("Pivot") > -1) ObjectDelete("Pivot");
   if (ObjectFind("DailyФибо_123_High") > -1) ObjectDelete("DailyФибо_123_High");
   if (ObjectFind("txtDailyФибо_123_High") > -1) ObjectDelete("txtDailyФибо_123_High");
   if (ObjectFind("DailyФибо_123_Low") > -1) ObjectDelete("DailyФибо_123_Low");
   if (ObjectFind("txtDailyФибо_123_Low") > -1) ObjectDelete("txtDailyФибо_123_Low");
   if (ObjectFind("DailyФибо_138_High") > -1) ObjectDelete("DailyФибо_138_High");
   if (ObjectFind("txtDailyФибо_138_High") > -1) ObjectDelete("txtDailyФибо_138_High");
   if (ObjectFind("DailyФибо_138_Low") > -1) ObjectDelete("DailyФибо_138_Low");
   if (ObjectFind("txtDailyФибо_138_Low") > -1) ObjectDelete("txtDailyФибо_138_Low");
   if (ObjectFind("DailyФибо_161_High") > -1) ObjectDelete("DailyФибо_161_High");
   if (ObjectFind("txtDailyФибо_161_High") > -1) ObjectDelete("txtDailyФибо_161_High");
   if (ObjectFind("DailyФибо_161_Low") > -1) ObjectDelete("DailyФибо_161_Low");
   if (ObjectFind("txtDailyФибо_161_Low") > -1) ObjectDelete("txtDailyФибо_161_Low");
   if (ObjectFind("DailyФибо_200_Low") > -1) ObjectDelete("DailyФибо_200_Low");
   if (ObjectFind("txtDailyФибо_200_Low") > -1) ObjectDelete("txtDailyФибо_200_Low");
   if (ObjectFind("DailyФибо_261_Low") > -1) ObjectDelete("DailyФибо_261_Low");
   if (ObjectFind("txtDailyФибо_261_Low") > -1) ObjectDelete("txtDailyФибо_261_Low");
   return (0);
}

// 91C6133C988942E7CE1AA78CA8069F73
void f0_0(string A_name_0, int Ai_8, double A_price_12, int Ai_20, double A_price_24, color A_color_32, int A_width_36, int A_style_40, int A_bool_44, int A_bool_48) {
   if (ObjectFind(A_name_0) > -1) ObjectDelete(A_name_0);
   ObjectCreate(A_name_0, OBJ_TREND, 0, Time[Ai_8], A_price_12, Time[Ai_20], A_price_24);
   ObjectSet(A_name_0, OBJPROP_COLOR, A_color_32);
   ObjectSet(A_name_0, OBJPROP_WIDTH, A_width_36);
   ObjectSet(A_name_0, OBJPROP_STYLE, A_style_40);
   ObjectSet(A_name_0, OBJPROP_RAY, A_bool_44);
   ObjectSet(A_name_0, OBJPROP_BACK, A_bool_48);
}

// E82909937F22B395E31016304FDC713B
void f0_1(string A_name_0, int Ai_8, double A_price_12, string A_text_20, color A_color_28, int A_fontsize_32) {
   if (ObjectFind(A_name_0) > -1) ObjectDelete(A_name_0);
   ObjectCreate(A_name_0, OBJ_TEXT, 0, Time[Ai_8], A_price_12);
   ObjectSetText(A_name_0, A_text_20, A_fontsize_32, "Tahoma", A_color_28);
}

Recommend