#property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property indicator_separate_window #property indicator_minimum 0.0 #property indicator_maximum 100.0 #property indicator_buffers 6 #property indicator_color1 LightSeaGreen #property indicator_color2 Red #property indicator_color3 Black #property indicator_color4 Black #property indicator_color5 Green #property indicator_color6 Red extern int KPeriod = 5; extern int DPeriod = 3; extern int Slowing = 3; double gda_88[]; double gda_92[]; double gda_96[]; double gda_100[]; double gda_104[]; double gda_108[]; int gi_112 = 0; int gi_116 = 0; int init() { if (ObjectType("FXUltraLabel") != 23) ObjectDelete("FXUltraLabel"); if (ObjectFind("FXUltraLabel") == -1) ObjectCreate("FXUltraLabel", OBJ_LABEL, 0, Time[5], Close[5]); ObjectSetText("FXUltraLabel", "Stochastic Alert, IndicatorForex.com"); ObjectSet("FXUltraLabel", OBJPROP_XDISTANCE, 20); ObjectSet("FXUltraLabel", OBJPROP_YDISTANCE, 20); IndicatorBuffers(6); SetIndexStyle(2, DRAW_NONE); SetIndexBuffer(2, gda_96); SetIndexStyle(3, DRAW_NONE); SetIndexBuffer(3, gda_100); SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(0, gda_88); SetIndexStyle(1, DRAW_LINE); SetIndexBuffer(1, gda_92); SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 2); SetIndexEmptyValue(4, -1); SetIndexBuffer(4, gda_104); SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 2); SetIndexEmptyValue(5, -1); SetIndexBuffer(5, gda_108); string ls_0 = "Stochastic Alert(" + KPeriod + "," + DPeriod + "," + Slowing + ")"; IndicatorShortName(ls_0); SetIndexLabel(0, ls_0); SetIndexLabel(1, "Signal"); gi_112 = KPeriod + Slowing; gi_116 = gi_112 + DPeriod; SetIndexDrawBegin(0, gi_112); SetIndexDrawBegin(1, gi_116); return (0); } int deinit() { ObjectDelete("FXUltraLabel"); return (0); } int start() { double ld_12; double ld_20; double ld_28; double ld_36; double ld_44; if (ObjectType("FXUltraLabel") != 23) ObjectDelete("FXUltraLabel"); if (ObjectFind("FXUltraLabel") == -1) ObjectCreate("FXUltraLabel", OBJ_LABEL, 0, Time[5], Close[5]); ObjectSetText("FXUltraLabel", "Stochastic Alert, IndicatorForex.com"); ObjectSet("FXUltraLabel", OBJPROP_XDISTANCE, 20); ObjectSet("FXUltraLabel", OBJPROP_YDISTANCE, 20); int li_8 = IndicatorCounted(); if (Bars <= gi_116) return (0); if (li_8 < 1) { for (int li_0 = 1; li_0 <= gi_112; li_0++) gda_88[Bars - li_0] = 0; for (li_0 = 1; li_0 <= gi_116; li_0++) gda_92[Bars - li_0] = 0; } li_0 = Bars - KPeriod; if (li_8 > KPeriod) li_0 = Bars - li_8 - 1; while (li_0 >= 0) { ld_20 = 1000000; for (int li_4 = li_0 + KPeriod - 1; li_4 >= li_0; li_4--) { ld_12 = Low[li_4]; if (ld_20 > ld_12) ld_20 = ld_12; } gda_100[li_0] = ld_20; li_0--; } li_0 = Bars - KPeriod; if (li_8 > KPeriod) li_0 = Bars - li_8 - 1; while (li_0 >= 0) { ld_28 = -1000000; for (li_4 = li_0 + KPeriod - 1; li_4 >= li_0; li_4--) { ld_12 = High[li_4]; if (ld_28 < ld_12) ld_28 = ld_12; } gda_96[li_0] = ld_28; li_0--; } li_0 = Bars - gi_112; if (li_8 > gi_112) li_0 = Bars - li_8 - 1; while (li_0 >= 0) { ld_36 = 0.0; ld_44 = 0.0; for (li_4 = li_0 + Slowing - 1; li_4 >= li_0; li_4--) { ld_36 += Close[li_4] - gda_100[li_4]; ld_44 += gda_96[li_4] - gda_100[li_4]; } if (ld_44 == 0.0) gda_88[li_0] = 100.0; else gda_88[li_0] = 100.0 * (ld_36 / ld_44); li_0--; } if (li_8 > 0) li_8--; int li_52 = Bars - li_8; for (li_0 = 0; li_0 < li_52; li_0++) gda_92[li_0] = iMAOnArray(gda_88, Bars, DPeriod, 0, MODE_SMA, li_0); for (li_0 = 0; li_0 < li_52; li_0++) { if (gda_88[li_0] >= gda_92[li_0]) { gda_104[li_0] = gda_88[li_0]; gda_108[li_0] = -1; } else { gda_108[li_0] = gda_88[li_0]; gda_104[li_0] = -1; } } if (gda_108[1] != -1.0 && gda_108[2] == -1.0 && High[0] == Low[0] && High[0] == Close[0] && High[0] == Open[0]) Alert("Stochastic Alert: " + Symbol() + " alerts Short."); if (gda_104[1] != -1.0 && gda_104[2] == -1.0 && High[0] == Low[0] && High[0] == Close[0] && High[0] == Open[0]) Alert("Stochastic Alert: " + Symbol() + " alerts Long."); return (0); }