Navigation:Home > Content >

YADIX_Pivot_Points~.mq4

Time: 2014-03-05 | Download file:YADIX_Pivot_Points~.mq4

#property copyright "Copyright © 2012, Yadix."
#property link      "http://www.yadix.com/"

#property indicator_chart_window

extern bool display_daily = TRUE;
extern bool alert_daily = TRUE;
extern int daily_threshold = 10;
extern bool display_weekly = TRUE;
extern bool alert_weekly = TRUE;
extern int weekly_threshold = 30;
double G_datetime_100;
double G_datetime_108;
double G_datetime_116;
double G_datetime_124;
double G_datetime_132;
double G_datetime_140;
double G_datetime_148;
double G_datetime_156;
double G_datetime_164;
double G_datetime_172;
double G_datetime_180;
double G_datetime_188;
double G_datetime_196;
double G_datetime_204;
bool Gi_212;
double G_datetime_216;
double G_datetime_224;
double G_point_232;
int G_day_of_week_240;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   Gi_212 = TRUE;
   if (f0_0() == 11) {
      Alert("Invalid broker, please only run on Yadix");
      Gi_212 = FALSE;
   }
   f0_2();
   G_day_of_week_240 = DayOfWeek();
   start();
   return (0);
}

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

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   if (Gi_212) {
      if (DayOfWeek() != G_day_of_week_240) f0_3();
      f0_6();
      f0_5();
      if (G_datetime_148 != 0.0 && G_datetime_204 != 0.0) f0_1();
      f0_4();
   }
   return (0);
}

// D1DDCE31F1A86B3140880F6B1877CBF8
void f0_6() {
   G_datetime_100 = NormalizeDouble((iHigh(Symbol(), PERIOD_D1, 1) + iClose(Symbol(), PERIOD_D1, 1) + iLow(Symbol(), PERIOD_D1, 1)) / 3.0, Digits);
   G_datetime_108 = 2.0 * G_datetime_100 - iLow(Symbol(), PERIOD_D1, 1);
   G_datetime_132 = 2.0 * G_datetime_100 - iHigh(Symbol(), PERIOD_D1, 1);
   G_datetime_116 = G_datetime_100 + (G_datetime_108 - G_datetime_132);
   G_datetime_140 = G_datetime_100 - (G_datetime_108 - G_datetime_132);
   G_datetime_124 = iHigh(Symbol(), PERIOD_D1, 1) + 2.0 * (G_datetime_100 - iLow(Symbol(), PERIOD_D1, 1));
   G_datetime_148 = iLow(Symbol(), PERIOD_D1, 1) - 2.0 * (iHigh(Symbol(), PERIOD_D1, 1) - G_datetime_100);
   G_datetime_156 = NormalizeDouble((iHigh(Symbol(), PERIOD_W1, 1) + iClose(Symbol(), PERIOD_W1, 1) + iLow(Symbol(), PERIOD_W1, 1)) / 3.0, Digits);
   G_datetime_164 = 2.0 * G_datetime_156 - iLow(Symbol(), PERIOD_W1, 1);
   G_datetime_188 = 2.0 * G_datetime_156 - iHigh(Symbol(), PERIOD_W1, 1);
   G_datetime_172 = G_datetime_156 + (G_datetime_164 - G_datetime_188);
   G_datetime_196 = G_datetime_156 - (G_datetime_164 - G_datetime_188);
   G_datetime_180 = iHigh(Symbol(), PERIOD_W1, 1) + 2.0 * (G_datetime_156 - iLow(Symbol(), PERIOD_W1, 1));
   G_datetime_204 = iLow(Symbol(), PERIOD_W1, 1) - 2.0 * (iHigh(Symbol(), PERIOD_W1, 1) - G_datetime_156);
}

// A9B24A824F70CC1232D1C2BA27039E8D
void f0_5() {
   Comment("---------------------------", 
      "\n", "Account       : ", AccountNumber(), 
      "\n", "Name         : ", AccountName(), 
      "\n", "FreeMargin  : ", AccountFreeMargin(), 
      "\n", "Currency     : ", AccountCurrency(), 
      "\n", "---------------------------", 
      "\n", "-----------Daily-----------", 
      "\n", "R3     : ", G_datetime_124, 
      "\n", "R2     : ", G_datetime_116, 
      "\n", "R1     : ", G_datetime_108, 
      "\n\n", "  Pivot  : ", G_datetime_100, 
      "\n\n", "S1     : ", G_datetime_132, 
      "\n", "S2     : ", G_datetime_140, 
      "\n", "S3     : ", G_datetime_148, 
      "\n\n", "----------Weekly-----------", 
      "\n", "R3     : ", G_datetime_180, 
      "\n", "R2     : ", G_datetime_172, 
      "\n", "R1     : ", G_datetime_164, 
      "\n\n", "  Pivot  : ", G_datetime_156, 
      "\n\n", "S1     : ", G_datetime_188, 
      "\n", "S2     : ", G_datetime_196, 
      "\n", "S3     : ", G_datetime_204, 
      "\n", "---------------------------", 
   "\n");
}

// 945D754CB0DC06D04243FCBA25FC0802
void f0_3() {
   ObjectDelete("DR3");
   ObjectDelete("DR2");
   ObjectDelete("DR1");
   ObjectDelete("DPP");
   ObjectDelete("DS1");
   ObjectDelete("DS2");
   ObjectDelete("DS3");
   ObjectDelete("WR3");
   ObjectDelete("WR2");
   ObjectDelete("WR1");
   ObjectDelete("WPP");
   ObjectDelete("WS1");
   ObjectDelete("WS2");
   ObjectDelete("WS3");
   Comment("");
}

// 09CBB5F5CE12C31A043D5C81BF20AA4A
int f0_0() {
   return (1);
}

// 2569208C5E61CB15E209FFE323DB48B7
void f0_1() {
   if (display_daily) {
      ObjectCreate("DR3", OBJ_HLINE, 0, G_datetime_124, G_datetime_124);
      ObjectSet("DR3", OBJPROP_COLOR, Orange);
      ObjectSet("DR3", OBJPROP_STYLE, STYLE_DASHDOT);
      ObjectCreate("DR2", OBJ_HLINE, 0, G_datetime_116, G_datetime_116);
      ObjectSet("DR2", OBJPROP_COLOR, Orange);
      ObjectSet("DR2", OBJPROP_STYLE, STYLE_DASHDOT);
      ObjectCreate("DR1", OBJ_HLINE, 0, G_datetime_108, G_datetime_108);
      ObjectSet("DR1", OBJPROP_COLOR, Orange);
      ObjectSet("DR1", OBJPROP_STYLE, STYLE_DASHDOT);
      ObjectCreate("DPP", OBJ_HLINE, 0, G_datetime_100, G_datetime_100);
      ObjectSet("DPP", OBJPROP_COLOR, Yellow);
      ObjectCreate("DS1", OBJ_HLINE, 0, G_datetime_132, G_datetime_132);
      ObjectSet("DS1", OBJPROP_COLOR, LawnGreen);
      ObjectSet("DS1", OBJPROP_STYLE, STYLE_DASHDOT);
      ObjectCreate("DS2", OBJ_HLINE, 0, G_datetime_140, G_datetime_140);
      ObjectSet("DS2", OBJPROP_COLOR, LawnGreen);
      ObjectSet("DS2", OBJPROP_STYLE, STYLE_DASHDOT);
      ObjectCreate("DS3", OBJ_HLINE, 0, G_datetime_148, G_datetime_148);
      ObjectSet("DS3", OBJPROP_COLOR, LawnGreen);
      ObjectSet("DS3", OBJPROP_STYLE, STYLE_DASHDOT);
   }
   if (display_weekly) {
      ObjectCreate("WR3", OBJ_HLINE, 0, G_datetime_180, G_datetime_180);
      ObjectSet("WR3", OBJPROP_COLOR, Crimson);
      ObjectSet("WR3", OBJPROP_STYLE, STYLE_DOT);
      ObjectCreate("WR2", OBJ_HLINE, 0, G_datetime_172, G_datetime_172);
      ObjectSet("WR2", OBJPROP_COLOR, Crimson);
      ObjectSet("WR2", OBJPROP_STYLE, STYLE_DOT);
      ObjectCreate("WR1", OBJ_HLINE, 0, G_datetime_164, G_datetime_164);
      ObjectSet("WR1", OBJPROP_COLOR, Crimson);
      ObjectSet("WR1", OBJPROP_STYLE, STYLE_DOT);
      ObjectCreate("WPP", OBJ_HLINE, 0, G_datetime_156, G_datetime_156);
      ObjectSet("WPP", OBJPROP_COLOR, OrangeRed);
      ObjectCreate("WS1", OBJ_HLINE, 0, G_datetime_188, G_datetime_188);
      ObjectSet("WS1", OBJPROP_COLOR, DarkGreen);
      ObjectSet("WS1", OBJPROP_STYLE, STYLE_DOT);
      ObjectCreate("WS2", OBJ_HLINE, 0, G_datetime_196, G_datetime_196);
      ObjectSet("WS2", OBJPROP_COLOR, DarkGreen);
      ObjectSet("WS2", OBJPROP_STYLE, STYLE_DOT);
      ObjectCreate("WS3", OBJ_HLINE, 0, G_datetime_204, G_datetime_204);
      ObjectSet("WS3", OBJPROP_COLOR, DarkGreen);
      ObjectSet("WS3", OBJPROP_STYLE, STYLE_DOT);
   }
}

// 9B1AEE847CFB597942D106A4135D4FE6
void f0_4() {
   if (alert_daily) {
      if (Bid > G_datetime_108 - daily_threshold * G_point_232 && Bid < G_datetime_108 + daily_threshold * G_point_232 && G_datetime_216 != G_datetime_108) {
         Alert("Price is approaching daily resistance line 1");
         G_datetime_216 = G_datetime_108;
      }
      if (Bid > G_datetime_116 - daily_threshold * G_point_232 && Bid < G_datetime_116 + daily_threshold * G_point_232 && G_datetime_216 != G_datetime_116) {
         Alert("Price is approaching daily resistance line 2");
         G_datetime_216 = G_datetime_116;
      }
      if (Bid > G_datetime_124 - daily_threshold * G_point_232 && Bid < G_datetime_124 + daily_threshold * G_point_232 && G_datetime_216 != G_datetime_124) {
         Alert("Price is approaching daily resistance line 3");
         G_datetime_216 = G_datetime_124;
      }
      if (Bid > G_datetime_132 - daily_threshold * G_point_232 && Bid < G_datetime_132 + daily_threshold * G_point_232 && G_datetime_216 != G_datetime_132) {
         Alert("Price is approaching daily support line 1");
         G_datetime_216 = G_datetime_132;
      }
      if (Bid > G_datetime_140 - daily_threshold * G_point_232 && Bid < G_datetime_140 + daily_threshold * G_point_232 && G_datetime_216 != G_datetime_140) {
         Alert("Price is approaching daily support line 2");
         G_datetime_216 = G_datetime_140;
      }
      if (Bid > G_datetime_148 - daily_threshold * G_point_232 && Bid < G_datetime_148 + daily_threshold * G_point_232 && G_datetime_216 != G_datetime_148) {
         Alert("Price is approaching daily support line 3");
         G_datetime_216 = G_datetime_148;
      }
      if (Bid > G_datetime_100 - daily_threshold * G_point_232 && Bid < G_datetime_100 + daily_threshold * G_point_232 && G_datetime_216 != G_datetime_100) {
         Alert("Price is approaching daily pivot point");
         G_datetime_216 = G_datetime_100;
      }
   }
   if (alert_weekly) {
      if (Bid > G_datetime_164 - weekly_threshold * G_point_232 && Bid < G_datetime_164 + weekly_threshold * G_point_232 && G_datetime_224 != G_datetime_164) {
         Alert("Price is approaching weekly resistance line 1");
         G_datetime_224 = G_datetime_164;
      }
      if (Bid > G_datetime_172 - weekly_threshold * G_point_232 && Bid < G_datetime_172 + weekly_threshold * G_point_232 && G_datetime_224 != G_datetime_172) {
         Alert("Price is approaching weekly resistance line 2");
         G_datetime_224 = G_datetime_172;
      }
      if (Bid > G_datetime_180 - weekly_threshold * G_point_232 && Bid < G_datetime_180 + weekly_threshold * G_point_232 && G_datetime_224 != G_datetime_180) {
         Alert("Price is approaching weekly resistance line 3");
         G_datetime_224 = G_datetime_180;
      }
      if (Bid > G_datetime_188 - weekly_threshold * G_point_232 && Bid < G_datetime_188 + weekly_threshold * G_point_232 && G_datetime_224 != G_datetime_188) {
         Alert("Price is approaching weekly support line 1");
         G_datetime_224 = G_datetime_188;
      }
      if (Bid > G_datetime_196 - weekly_threshold * G_point_232 && Bid < G_datetime_196 + weekly_threshold * G_point_232 && G_datetime_224 != G_datetime_196) {
         Alert("Price is approaching weekly support line 2");
         G_datetime_224 = G_datetime_196;
      }
      if (Bid > G_datetime_204 - weekly_threshold * G_point_232 && Bid < G_datetime_204 + weekly_threshold * G_point_232 && G_datetime_224 != G_datetime_204) {
         Alert("Price is approaching weekly support line 3");
         G_datetime_224 = G_datetime_204;
      }
      if (Bid > G_datetime_156 - weekly_threshold * G_point_232 && Bid < G_datetime_156 + weekly_threshold * G_point_232 && G_datetime_224 != G_datetime_156) {
         Alert("Price is approaching weekly pivot point");
         G_datetime_224 = G_datetime_156;
      }
   }
}

// 6ABA3523C7A75AAEA41CC0DEC7953CC5
void f0_2() {
   G_point_232 = Point;
   if (Digits == 3) G_point_232 = 0.01;
   if (Digits == 5) G_point_232 = 0.0001;
}

Recommend