#property indicator_chart_window extern bool Alert.With.Sound = TRUE; extern bool Show.Information.Label = TRUE; extern color Label.Color = Red; extern int Label.Font.Size = 9; int g_time_92 = 0; int gi_unused_96 = 0; string gs_unused_100 = ""; double gd_108 = 1.0; int g_timeframe_116 = PERIOD_M15; int init() { IndicatorDigits(2); if (Digits == 5 || Digits == 3) gd_108 = 10; string ls_0 = "Alex Alert"; IndicatorShortName(ls_0); SetIndexLabel(0, ls_0); switch (Period()) { case PERIOD_M1: g_timeframe_116 = 5; break; case PERIOD_M5: g_timeframe_116 = 15; break; case PERIOD_M15: g_timeframe_116 = 60; break; case PERIOD_M30: g_timeframe_116 = 240; break; case PERIOD_H1: g_timeframe_116 = 240; break; case PERIOD_H4: g_timeframe_116 = 1440; break; case PERIOD_D1: g_timeframe_116 = 10080; break; case PERIOD_W1: g_timeframe_116 = 43200; break; default: Print("Not valid period"); } return (0); } int start() { if (AlexAlert(0)) { if (MaAlert(0, 0) && MaAlert(1, 1) || MaAlert(1, 2) || MaAlert(1, 3) || MaAlert(1, 4) || MaAlert(1, 5)) { if (Time[0] > g_time_92 && iMA(NULL, g_timeframe_116, 20, 0, MODE_EMA, PRICE_CLOSE, 0) >= iMA(NULL, g_timeframe_116, 9, 0, MODE_EMA, PRICE_CLOSE, 0) && iMA(NULL, g_timeframe_116, 9, 0, MODE_EMA, PRICE_CLOSE, 0) >= iMA(NULL, g_timeframe_116, 5, 0, MODE_EMA, PRICE_CLOSE, 0)) DoAlert("Alex prepare to sell " + Symbol() + " " + Period() + " min ", 0); g_time_92 = Time[0]; } } if (AlexAlert(1)) { if (MaAlert(1, 0) && MaAlert(0, 1) || MaAlert(0, 2) || MaAlert(0, 3) || MaAlert(0, 4) || MaAlert(0, 5)) { if (Time[0] > g_time_92 && iMA(NULL, g_timeframe_116, 20, 0, MODE_EMA, PRICE_CLOSE, 0) <= iMA(NULL, g_timeframe_116, 9, 0, MODE_EMA, PRICE_CLOSE, 0) && iMA(NULL, g_timeframe_116, 9, 0, MODE_EMA, PRICE_CLOSE, 0) <= iMA(NULL, g_timeframe_116, 5, 0, MODE_EMA, PRICE_CLOSE, 0)) DoAlert("Alex prepare to buy " + Symbol() + " " + Period() + " min ", 1); g_time_92 = Time[0]; } } if (Show.Information.Label) SetLabels(); else { deleteObject("Time"); deleteObject("Spread"); } string ls_0 = "" + "------------------------------------------------" + "\n" + " © 2010 www.fxusa.info" + "\n" + " version 1.3" + "\n" + "------------------------------------------------"; Comment(ls_0); return (0); } bool AlexAlert(int ai_0) { bool li_ret_4 = FALSE; if (ai_0 == 0) { if (iCustom(NULL, 0, "RSI", 0, 0) < 50.0 && iCustom(NULL, 0, "RSI", 0, 1) > 50.0 || iCustom(NULL, 0, "RSI", 0, 2) > 50.0 || iCustom(NULL, 0, "RSI", 0, 3) > 50.0) li_ret_4 = TRUE; } if (ai_0 == 1) { if (iCustom(NULL, 0, "RSI", 0, 0) > 50.0 && iCustom(NULL, 0, "RSI", 0, 1) < 50.0 || iCustom(NULL, 0, "RSI", 0, 2) < 50.0 || iCustom(NULL, 0, "RSI", 0, 3) < 50.0) li_ret_4 = TRUE; } return (li_ret_4); } int MaAlert(int ai_0, int ai_4) { bool li_ret_8 = FALSE; if (ai_0 == 0) if (iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, ai_4) > iMA(NULL, 0, 9, 0, MODE_EMA, PRICE_CLOSE, ai_4) && iMA(NULL, 0, 9, 0, MODE_EMA, PRICE_CLOSE, ai_4) > iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, ai_4)) li_ret_8 = TRUE; if (ai_0 == 1) if (iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, ai_4) < iMA(NULL, 0, 9, 0, MODE_EMA, PRICE_CLOSE, ai_4) && iMA(NULL, 0, 9, 0, MODE_EMA, PRICE_CLOSE, ai_4) < iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, ai_4)) li_ret_8 = TRUE; return (li_ret_8); } void DoAlert(string as_0, int ai_8) { int li_12; bool li_16 = TRUE; if (ai_8 == 0) { if (ObjectFind("Alex_down") != -1) { li_12 = ObjectGet("Alex_down", OBJPROP_TIME1); if (li_12 == Time[1] || li_12 == Time[2]) li_16 = FALSE; } } if (ai_8 == 1) { if (ObjectFind("Alex_up") != -1) { li_12 = ObjectGet("Alex_up", OBJPROP_TIME1); if (li_12 == Time[1] || li_12 == Time[2]) li_16 = FALSE; } } if (li_16) { if (Alert.With.Sound) Alert(as_0); if (!Alert.With.Sound) MessageBox(as_0, "Alex Alert", 0); createArrow(ai_8); } } void createArrow(int ai_0) { deleteObject("Alex_down"); deleteObject("Alex_up"); if (ai_0 == 0) { ObjectCreate("Alex_down", OBJ_ARROW, 0, Time[0], High[1] + 7.0 * Point); ObjectSet("Alex_down", OBJPROP_STYLE, STYLE_DOT); ObjectSet("Alex_down", OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN); ObjectSet("Alex_down", OBJPROP_COLOR, Red); return; } ObjectCreate("Alex_up", OBJ_ARROW, 0, Time[0], Low[1] - 7.0 * Point); ObjectSet("Alex_up", OBJPROP_STYLE, STYLE_DOT); ObjectSet("Alex_up", OBJPROP_ARROWCODE, SYMBOL_ARROWUP); ObjectSet("Alex_up", OBJPROP_COLOR, Green); } void deleteObject(string a_name_0) { if (ObjectFind(a_name_0) != -1) ObjectDelete(a_name_0); } void SetLabels() { if (ObjectFind("Time") == -1) ObjectCreate("Time", OBJ_LABEL, 0, 0, 0); ObjectSet("Time", OBJPROP_CORNER, 2); ObjectSet("Time", OBJPROP_XDISTANCE, 15); ObjectSet("Time", OBJPROP_YDISTANCE, 20); ObjectSet("Time", OBJPROP_BACK, TRUE); int li_16 = Time[0] + 60 * Period() - TimeCurrent(); int li_20 = li_16 % 60; li_16 = (li_16 - li_16 % 60) / 60; string l_text_0 = li_16 + " minutes " + li_20 + " seconds left "; ObjectSetText("Time", l_text_0, Label.Font.Size, "Tahoma", Label.Color); if (ObjectFind("Spread") == -1) ObjectCreate("Spread", OBJ_LABEL, 0, 0, 0); ObjectSet("Spread", OBJPROP_CORNER, 2); ObjectSet("Spread", OBJPROP_XDISTANCE, 15); ObjectSet("Spread", OBJPROP_YDISTANCE, 35); ObjectSet("Spread", OBJPROP_BACK, TRUE); double ld_24 = (Ask - Bid) / Point / gd_108; string l_text_8 = "Broker Spread for " + Symbol() + " : " + DoubleToStr(ld_24, 2); ObjectSetText("Spread", l_text_8, Label.Font.Size, "Tahoma", Label.Color);