Navigation:Home > Content >

PZ_SupportResistance-fixed.mq4

Time: 2010-06-14 | Download file:PZ_SupportResistance-fixed.mq4

#property copyright "http://www.pointzero-trading.com"
#property link      "http://www.pointzero-trading.com"

#property indicator_chart_window

int Gia_76[] = {33, 42, 39, 40, 41, 59, 58, 64, 38, 61, 43, 36, 47, 63, 35, 91, 93};
string Gs_80;
extern string Se_Ex = "------- Settings";
extern int MonthlyPeriod = 6;
extern int WeeklyPeriod = 12;
extern int DailyPeriod = 24;
extern int IntradayPeriod = 64;
extern string Sm_Ex = "------- Smoothing";
extern string Sm_Ex2 = ">> Collapses levels by range";
extern double SmoothFactor = 1.5;
extern string CSW_Ex = "------- Line Settings";
extern int MinIntradayWidth = 2;
extern int MinLineWidth = 2;
extern int MaxWidth = 8;
extern color BasicLineColor = Silver;
extern color BasicIntradayColor = LightBlue;
extern color MediumColor = LightSeaGreen;
extern color StrongColor = Teal;
extern color ShortTermColor = Red;
extern string Alerts_ex = "---- Alerts";
extern string AlertCaption = "My Alert Name";
extern bool DisplayAlerts = FALSE;
extern bool EmailAlerts = FALSE;
extern bool PushAlerts = FALSE;
extern bool SoundAlerts = FALSE;
extern string SoundFile = "alert.wav";
bool Gi_216 = FALSE;
double G_price_220 = 0.0;
int Gi_228 = 0;
int Gi_232 = 0;
int Gi_unused_236 = 2;
int Gi_240 = 0;
int Gi_244 = 0;
int Gi_248 = 0;
int Gi_252 = 0;
int Gi_256 = 0;
int Gi_260 = 0;
int Gi_unused_264 = 0;
int Gi_unused_268 = 0;
int Gi_unused_272 = 0;
int G_shift_276 = 0;
int G_shift_280 = 0;
int G_shift_284 = 0;
int G_shift_288 = 0;
int G_shift_292 = 0;
int G_shift_296 = 0;
int Gi_unused_300 = 0;
int Gi_unused_304 = 0;
int Gi_unused_308 = 0;
int Gi_312;
bool Gi_316 = TRUE;
bool Gi_320 = TRUE;

// FD4055E1AC0A7D690C66D37B2C70E529
int f0_11() {
   return (0);
}

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   Gs_80 = f0_3();
   IndicatorShortName("PZ Support Resistance");
   Comment("Copyright © http://www.pointzero-trading.com");
   f0_7();
   f0_8();
   return (0);
}

// C23BD2D05F1A927B2825264A247F4626
void f0_7() {
   string name_0;
   int objs_total_8 = ObjectsTotal();
   for (int Li_12 = objs_total_8 - 1; Li_12 >= 0; Li_12--) {
      name_0 = ObjectName(Li_12);
      if (StringFind(name_0, "PZSR") != -1) ObjectDelete(name_0);
   }
}

// D1DDCE31F1A86B3140880F6B1877CBF8
void f0_8() {
   string name_0;
   int objs_total_8 = ObjectsTotal();
   for (int Li_12 = objs_total_8 - 1; Li_12 >= 0; Li_12--) {
      name_0 = ObjectName(Li_12);
      if (StringFind(name_0, "SPZSR") != -1) ObjectDelete(name_0);
   }
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   f0_7();
   f0_8();
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int Li_0;
   int Li_4;
   int Li_unused_8;
   if (!Gi_216) {
      if ((!IsConnected()) && 1) return (1);
      Li_0 = f0_11();
      if (Li_0 != 0) {
         Sleep(15000);
         return (1);
      }
      Gi_216 = TRUE;
   }
   if (!Gi_216) return (1);
   int Li_12 = 1;
   int ind_counted_16 = IndicatorCounted();
   if (ind_counted_16 < 0) return (-1);
   int Li_20 = Bars - 1 - ind_counted_16;
   int timeframe_24 = Period();
   switch (timeframe_24) {
   case PERIOD_MN1:
      Li_4 = MonthlyPeriod / 2;
      break;
   case PERIOD_W1:
      Li_4 = WeeklyPeriod / 2;
      break;
   case PERIOD_D1:
      Li_4 = DailyPeriod / 2;
      break;
   default:
      Li_4 = IntradayPeriod / 2;
   }
   int Li_unused_32 = MathCeil(Li_4 / 2);
   for (int Li_36 = Li_20; Li_36 >= Li_12; Li_36--) {
      Li_unused_8 = 0;
      if ((Bars % Li_4 == 0 && Li_36 == 1) || Gi_320) {
         Gi_320 = FALSE;
         f0_4(timeframe_24, Li_4);
         f0_8();
         f0_1(Li_4);
      }
   }
   int Li_40 = f0_2(Li_36);
   f0_5();
   if (Gi_312 != Time[0]) {
      if (Li_40 == 1 && Gi_316 == FALSE) {
         if (DisplayAlerts == TRUE) Alert("PZ Support/Resistance" + " (" + AlertCaption + ") [" + Symbol() + "] Bullish Breakout");
         if (PushAlerts == TRUE) SendNotification("PZ Support/Resistance" + " (" + AlertCaption + ") [" + Symbol() + "] Bullish Breakout");
         if (EmailAlerts == TRUE) SendMail("PZ Support/Resistance" + " (" + AlertCaption + ") [" + Symbol() + "]", Symbol() + ": Bullish Breakout");
         if (SoundAlerts == TRUE) PlaySound(SoundFile);
      } else {
         if (Li_40 == 0 && Gi_316 == FALSE) {
            if (DisplayAlerts == TRUE) Alert("PZ Support/Resistance" + " (" + AlertCaption + ") [" + Symbol() + "] Bearish Breakout");
            if (PushAlerts == TRUE) SendNotification("PZ Support/Resistance" + " (" + AlertCaption + ") [" + Symbol() + "] Bearish Breakout");
            if (EmailAlerts == TRUE) SendMail("PZ Support/Resistance" + " (" + AlertCaption + ") [" + Symbol() + "]", Symbol() + ": Bearish Breakout");
            if (SoundAlerts == TRUE) PlaySound(SoundFile);
         }
      }
      Gi_312 = Time[0];
      Gi_316 = FALSE;
   }
   return (0);
}

// D362D41CFF235C066CFB390D52F4EB13
void f0_9(int Ai_0, double A_price_4, color A_color_12, int A_style_16, int A_width_20, string As_unused_24, int Ai_unused_32) {
   int time_36;
   int time_40;
   string name_44;
   if (f0_10(Ai_0, A_price_4) == 0) {
      time_36 = Time[Ai_0];
      time_40 = Time[0];
      name_44 = "PZSR" + "-" + Time[Ai_0];
      if (ObjectFind(name_44) != -1) ObjectDelete(name_44);
      ObjectCreate(name_44, OBJ_TREND, 0, time_36, A_price_4, time_40, A_price_4);
      ObjectSet(name_44, OBJPROP_RAY, TRUE);
      ObjectSet(name_44, OBJPROP_STYLE, A_style_16);
      ObjectSet(name_44, OBJPROP_WIDTH, A_width_20);
      ObjectSet(name_44, OBJPROP_COLOR, A_color_12);
      ObjectSet(name_44, OBJPROP_BACK, TRUE);
      G_price_220 = A_price_4;
   }
}

// F7B1F0AA13347699EFAE0D924298CB02
int f0_10(int Ai_0, double Ad_4) {
   string name_12;
   double Ld_20;
   double Ld_28;
   double Ld_36;
   double Ld_44 = iATR(Symbol(), 0, 100, Ai_0) * SmoothFactor;
   int objs_total_52 = ObjectsTotal();
   for (int Li_56 = objs_total_52 - 1; Li_56 >= 0; Li_56--) {
      name_12 = ObjectName(Li_56);
      if (StringFind(name_12, "PZSR") != -1) {
         Ld_20 = ObjectGet(name_12, OBJPROP_PRICE1);
         Ld_28 = Ld_20 + Ld_44;
         Ld_36 = Ld_20 - Ld_44;
         if (Ad_4 == Ld_20) {
            f0_0(name_12);
            return (1);
         }
         if (Ad_4 <= Ld_28 && Ad_4 >= Ld_36) {
            f0_0(name_12);
            ObjectSet(name_12, OBJPROP_PRICE1, Ad_4);
            ObjectSet(name_12, OBJPROP_PRICE2, Ad_4);
            return (1);
         }
      }
   }
   return (0);
}

// 632A6309D71E99A017FD9D3CE1A19C24
int f0_2(int Ai_0) {
   string name_4;
   double Ld_12;
   int objs_total_20 = ObjectsTotal();
   for (int Li_24 = objs_total_20 - 1; Li_24 >= 0; Li_24--) {
      name_4 = ObjectName(Li_24);
      if (StringFind(name_4, "PZSR") != -1) {
         Ld_12 = ObjectGet(name_4, OBJPROP_PRICE1);
         if (Low[Ai_0] < Ld_12 && Close[Ai_0] > Ld_12) return (1);
         if (High[Ai_0] > Ld_12 && Close[Ai_0] < Ld_12) return (0);
         if (Low[Ai_0] < Ld_12 && Close[Ai_0] > Ld_12 && Open[Ai_0] > Ld_12) return (2);
         if (High[Ai_0] > Ld_12 && Close[Ai_0] < Ld_12 && Open[Ai_0] < Ld_12) return (3);
      }
   }
   return (EMPTY_VALUE);
}

// AA5EA51BFAC7B64E723BF276E0075513
int f0_6(double Ad_0) {
   string name_8;
   double Ld_16;
   int objs_total_24 = ObjectsTotal();
   for (int Li_28 = objs_total_24 - 1; Li_28 >= 0; Li_28--) {
      name_8 = ObjectName(Li_28);
      if (StringFind(name_8, "PZSR") != -1) {
         Ld_16 = ObjectGet(name_8, OBJPROP_PRICE1);
         if (Ad_0 == Ld_16) return (1);
      }
   }
   return (0);
}

// 09CBB5F5CE12C31A043D5C81BF20AA4A
void f0_0(string A_name_0) {
   int Li_8 = ObjectGet(A_name_0, OBJPROP_WIDTH);
   int Li_12 = ObjectGet(A_name_0, OBJPROP_COLOR);
   int width_16 = Li_8 + 1;
   if (width_16 > MaxWidth) {
      width_16 = MathCeil((MinLineWidth + MaxWidth) / 2);
      if (Li_12 == BasicLineColor || Li_12 == BasicIntradayColor) ObjectSet(A_name_0, OBJPROP_COLOR, MediumColor);
      else
         if (Li_12 == MediumColor) ObjectSet(A_name_0, OBJPROP_COLOR, StrongColor);
   }
   ObjectSet(A_name_0, OBJPROP_WIDTH, width_16);
}

// A0F6E6535C856D4495BA899376567E48
void f0_5() {
   string name_0;
   int Li_8;
   int Li_unused_12;
   int objs_total_16 = ObjectsTotal();
   int count_20 = 0;
   for (int Li_24 = objs_total_16 - 1; Li_24 >= 0; Li_24--) {
      name_0 = ObjectName(Li_24);
      if (StringFind(name_0, "PZSR") != -1) {
         count_20++;
         if (count_20 > 40) {
            Li_8 = ObjectGet(name_0, OBJPROP_COLOR);
            Li_unused_12 = ObjectGet(name_0, OBJPROP_WIDTH);
            if (Li_8 == BasicLineColor || Li_8 == BasicIntradayColor) ObjectDelete(name_0);
         }
      }
   }
}

// 2569208C5E61CB15E209FFE323DB48B7
void f0_1(int Ai_0) {
   double icustom_4;
   int datetime_12;
   int datetime_16;
   string name_20;
   int Li_28 = MathCeil(Ai_0 / 2);
   double Ld_unused_32 = 0;
   int count_40 = 0;
   for (int Li_44 = 1; count_40 <= 4; Li_44++) {
      icustom_4 = iCustom(Symbol(), 0, "ZigZag", Li_28, 3, 5, 0, Li_44);
      if (icustom_4 != 0.0 && (!f0_6(icustom_4))) {
         if (count_40 >= 1) {
            datetime_12 = Time[Li_44];
            datetime_16 = Time[0];
            name_20 = "SPZSR" + "-" + Time[Li_44];
            if (ObjectFind(name_20) != -1) ObjectDelete(name_20);
            ObjectCreate(name_20, OBJ_TREND, 0, datetime_12, icustom_4, datetime_16, icustom_4);
            ObjectSet(name_20, OBJPROP_RAY, TRUE);
            ObjectSet(name_20, OBJPROP_STYLE, STYLE_DOT);
            ObjectSet(name_20, OBJPROP_WIDTH, 1);
            ObjectSet(name_20, OBJPROP_COLOR, ShortTermColor);
         }
         count_40++;
      }
   }
}

// 9ED55815FB278759298B6BAF50BEC3C8
void f0_4(int Ai_0, int Ai_4) {
   int shift_8;
   bool Li_12;
   double icustom_16;
   double icustom_24 = 0;
   double icustom_32 = 0;
   double icustom_40 = 0;
   double icustom_48 = 0;
   double icustom_56 = 0;
   double icustom_64 = 0;
   double Ld_unused_72 = 0;
   double Ld_unused_80 = 0;
   double Ld_unused_88 = 0;
   for (int Li_96 = Bars; Li_96 >= Ai_4 + 1; Li_96--) {
      Li_12 = FALSE;
      if (Ai_0 == 43200 || Ai_0 == 10080) {
         shift_8 = iBarShift(Symbol(), PERIOD_MN1, Time[Li_96], TRUE);
         if (shift_8 != -1 && shift_8 != G_shift_276) {
            icustom_16 = iCustom(Symbol(), PERIOD_MN1, "ZigZag", MonthlyPeriod, 3, 5, 0, shift_8);
            if (icustom_16 > 0.0 && icustom_16 != G_price_220 && icustom_16 != icustom_24 && icustom_24 != 0.0 && shift_8 < MonthlyPeriod && icustom_16 != EMPTY_VALUE) {
               f0_9(Li_96, icustom_16, BasicLineColor, Gi_232, MinLineWidth, "MN1", shift_8);
               Gi_240++;
               Li_12 = TRUE;
            }
            if (icustom_16 > 0.0 && icustom_16 != EMPTY_VALUE) icustom_24 = icustom_16;
            G_shift_276 = shift_8;
            if (Li_12) continue;
         }
      }
      if (Ai_0 == 10080 || Ai_0 == 1440) {
         shift_8 = iBarShift(Symbol(), PERIOD_W1, Time[Li_96], TRUE);
         if (shift_8 != -1 && shift_8 != G_shift_280) {
            icustom_16 = iCustom(Symbol(), PERIOD_W1, "ZigZag", WeeklyPeriod, 3, 5, 0, shift_8);
            if (icustom_16 > 0.0 && icustom_16 != G_price_220 && icustom_16 != icustom_32 && icustom_32 != 0.0 && shift_8 < WeeklyPeriod && icustom_16 != EMPTY_VALUE) {
               f0_9(Li_96, icustom_16, BasicLineColor, Gi_232, MinLineWidth, "W1", shift_8);
               Gi_244++;
               Li_12 = TRUE;
            }
            if (icustom_16 > 0.0 && icustom_16 != EMPTY_VALUE) icustom_32 = icustom_16;
            G_shift_280 = shift_8;
            if (Li_12) continue;
         }
      }
      if (Ai_0 == 1440 || Ai_0 == 240) {
         shift_8 = iBarShift(Symbol(), PERIOD_D1, Time[Li_96], TRUE);
         if (shift_8 != -1 && shift_8 != G_shift_284) {
            icustom_16 = iCustom(Symbol(), PERIOD_D1, "ZigZag", DailyPeriod, 3, 5, 0, shift_8);
            if (icustom_16 > 0.0 && icustom_16 != G_price_220 && icustom_16 != icustom_40 && icustom_40 != 0.0 && shift_8 < DailyPeriod && icustom_16 != EMPTY_VALUE) {
               f0_9(Li_96, icustom_16, BasicLineColor, Gi_232, MinLineWidth, "D1", shift_8);
               Gi_248++;
               Li_12 = TRUE;
            }
            if (icustom_16 > 0.0 && icustom_16 != EMPTY_VALUE) icustom_40 = icustom_16;
            G_shift_284 = shift_8;
            if (Li_12) continue;
         }
      }
      if (Ai_0 == 240 || Ai_0 == 60) {
         shift_8 = iBarShift(Symbol(), PERIOD_H4, Time[Li_96], TRUE);
         if (shift_8 != -1 && shift_8 != G_shift_288) {
            icustom_16 = iCustom(Symbol(), PERIOD_H4, "ZigZag", IntradayPeriod, 3, 5, 0, shift_8);
            if (icustom_16 > 0.0 && icustom_16 != G_price_220 && icustom_16 != icustom_48 && icustom_48 != 0.0 && shift_8 < IntradayPeriod && icustom_16 != EMPTY_VALUE) {
               f0_9(Li_96, icustom_16, BasicIntradayColor, Gi_228, MinIntradayWidth, "H4", shift_8);
               Gi_252++;
               Li_12 = TRUE;
            }
            if (icustom_16 > 0.0 && icustom_16 != EMPTY_VALUE) icustom_48 = icustom_16;
            G_shift_288 = shift_8;
            if (Li_12) continue;
         }
      }
      if (Ai_0 == 60 || Ai_0 == 30) {
         shift_8 = iBarShift(Symbol(), PERIOD_H1, Time[Li_96], TRUE);
         if (shift_8 != -1 && shift_8 != G_shift_292) {
            icustom_16 = iCustom(Symbol(), PERIOD_H1, "ZigZag", IntradayPeriod, 3, 5, 0, shift_8);
            if (icustom_16 > 0.0 && icustom_16 != G_price_220 && icustom_16 != icustom_56 && icustom_56 != 0.0 && shift_8 < IntradayPeriod && icustom_16 != EMPTY_VALUE) {
               f0_9(Li_96, icustom_16, BasicIntradayColor, Gi_228, MinIntradayWidth, "H1", shift_8);
               Gi_256++;
               Li_12 = TRUE;
            }
            if (icustom_16 > 0.0 && icustom_16 != EMPTY_VALUE) icustom_56 = icustom_16;
            G_shift_292 = shift_8;
            if (Li_12) continue;
         }
      }
      if (Ai_0 <= 30) {
         shift_8 = iBarShift(Symbol(), PERIOD_M30, Time[Li_96], TRUE);
         if (shift_8 != -1 && shift_8 != G_shift_296) {
            icustom_16 = iCustom(Symbol(), PERIOD_M30, "ZigZag", IntradayPeriod, 3, 5, 0, shift_8);
            if (icustom_16 > 0.0 && icustom_16 != G_price_220 && icustom_16 != icustom_64 && icustom_64 != 0.0 && shift_8 < IntradayPeriod && icustom_16 != EMPTY_VALUE) {
               f0_9(Li_96, icustom_16, BasicIntradayColor, Gi_228, MinIntradayWidth, "M30", shift_8);
               Gi_260++;
               Li_12 = TRUE;
            }
            if (icustom_16 > 0.0 && icustom_16 != EMPTY_VALUE) icustom_64 = icustom_16;
            G_shift_296 = shift_8;
            if (Li_12) {
            }
         }
      }
   }
}

// 9B1AEE847CFB597942D106A4135D4FE6
string f0_3() {
   return (StringSubstr(WindowExpertName(), 21, 10));
}

Recommend