//+------------------------------------------------------------------+ //| Hammadi_New_V3_ind.mq4 | //| Copyright © 2011,Hamady. | //| M_ELHamady@yahoo.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011,Hamady." #property link "M_ELHamady@yahoo.com" #property indicator_chart_window extern int Shift = 23; extern color Color0 = Red; extern color Color1 = Yellow; extern color Color2 = Aqua; extern bool UseSound = True; extern string SoundB = "Buy.wav"; extern string SoundS = "Sell.wav"; extern string SoundC = "Cheng.wav"; datetime time; //int timeframe=60; string P0 = "P0"; string P1 = "P1"; string P2 = "P2"; string Signal = "Wait for a signal"; string name = "PoLEVELS"; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators time = 0; ObjectCreate("P0 line", OBJ_TREND, 0, Time[Shift], 0, Time[0], 0); ObjectSet("P0 line", OBJPROP_RAY, TRUE); ObjectSet("P0 line", OBJPROP_STYLE, STYLE_DASH); ObjectSet("P0 line", OBJPROP_COLOR, Color0); //---- ObjectCreate("P1 line", OBJ_TREND, 0, Time[Shift], 0, Time[0], 0); ObjectSet("P1 line", OBJPROP_RAY, TRUE); ObjectSet("P1 line", OBJPROP_STYLE, STYLE_DASH); ObjectSet("P1 line", OBJPROP_COLOR, Color1); //---- ObjectCreate("P2 line", OBJ_TREND, 0, Time[Shift], 0, Time[0], 0); ObjectSet("P2 line", OBJPROP_RAY, TRUE); ObjectSet("P2 line", OBJPROP_STYLE, STYLE_DASH); ObjectSet("P2 line", OBJPROP_COLOR, Color2); //---- ObjectCreate("P0 label", OBJ_TEXT, 0, Time[0], 0); ObjectCreate("P1 label", OBJ_TEXT, 0, Time[0], 0); ObjectCreate("P2 label", OBJ_TEXT, 0, Time[0], 0); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- Comment(""); ObjectDelete("P0 line"); ObjectDelete("P0 label"); //---- ObjectDelete("P1 line"); ObjectDelete("P1 label"); //---- ObjectDelete("P2 line"); ObjectDelete("P2 label"); //---- ObjectDelete("HB"); ObjectDelete("CC"); ObDeleteObjectsByPrefix(name); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { double P=Point; if (time == Time[0]) return (0); int error_132 = GetLastError(); if (error_132 == 4066/* HISTORY_WILL_UPDATED */) { Sleep(1000); if (iClose(NULL, 0, 0) != Close[0]) { Sleep(1000); return (0); } } //---- //double iOpen_M15 = iOpen(NULL, PERIOD_M15, 1); //double iClose_M15 = iClose(NULL, PERIOD_M15, 1); //---- double ihigh_0 = iHigh(NULL, PERIOD_H1, 0); double ilow_0 = iLow(NULL, PERIOD_H1, 0); double iClose_0 = iClose(NULL, PERIOD_H1, 0); double P0 = (ihigh_0 + ilow_0)/2 ; //---- double ihigh_1 = iHigh(NULL, PERIOD_H1, 1); double ilow_1 = iLow(NULL, PERIOD_H1, 1); double iClose_1 = iClose(NULL, PERIOD_H1, 1); double P1 = (ihigh_1 + ilow_1 + iClose_1 + iClose_1)/4 ; //---- double ihigh_2 = iHigh(NULL, PERIOD_H1, 2); double ilow_2 = iLow(NULL, PERIOD_H1, 2); double iClose_2 = iClose(NULL, PERIOD_H1, 2); double P2 = (ihigh_2 + ilow_2 + iClose_2 + iClose_2)/4 ; //---- double C0= iClose_0,A=(C0-P0)/P,B=(C0-P1)/P,C=(P0-P1)/P,D=(P1-P2)/P; //---- ObjectSetText("P0 label", " P0 ", 8, "Fixedsys", Red); ObjectSetText("P1 label", " P1 ", 8, "Fixedsys", Yellow); ObjectSetText("P2 label", " P2 ", 8, "Fixedsys", Aqua); //---- ObjectMove("P0 label", 0, Time[0], P0); ObjectMove("P1 label", 0, Time[0], P1); ObjectMove("P2 label", 0, Time[0], P2); //---- ObjectMove("P0 line", 0, Time[Shift+5], P0); ObjectMove("P0 line", 1, Time[0], P0); //---- ObjectMove("P1 line", 0, Time[Shift], P1); ObjectMove("P1 line", 1, Time[0], P1); //---- ObjectMove("P2 line", 0, Time[Shift], P2); ObjectMove("P2 line", 1, Time[0], P2); //---- RefreshRates(); if(A>0 && B>6 && C>0 && D>0) //&& iClose_M15>iOpen_M15 Signal = "Buy"; if(UseSound==True&&Signal == "Buy")PlaySound(SoundB); if(A<0 && B<-6 && C<0 && D<0) //&& iClose_M15>> " + Signal + "", 10, "Tahoma Bold", IndianRed); time = Time[0]; return(0); } //+------------------------------------------------------------------+ void ObDeleteObjectsByPrefix(string as) { string name; int str_len = StringLen(as); int j = 0; while (j < ObjectsTotal()) { name = ObjectName(j); if (StringSubstr(name, 0, str_len) != as) { j++; continue; } ObjectDelete(name); } } //+------------------------------------------------------------------+