#property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Lime #property indicator_color2 Aqua #property indicator_color3 Red int g_color_76 = Green; int g_color_80 = Fuchsia; extern bool ShowGraf = FALSE; extern int CountBarsForShift = 12; extern int CountBarsForAverage = 77; extern double Target = 1.5; double g_ibuf_104[]; double g_ibuf_108[]; double g_ibuf_112[]; int init() { SetIndexShift(0, 0); IndicatorShortName("STOP Indicator(" + CountBarsForAverage + "," + Target + ")"); SetIndexDrawBegin(0, CountBarsForAverage); SetIndexDrawBegin(1, CountBarsForAverage); SetIndexDrawBegin(2, CountBarsForAverage); SetIndexBuffer(0, g_ibuf_104); SetIndexBuffer(1, g_ibuf_108); SetIndexBuffer(2, g_ibuf_112); SetIndexStyle(0, DRAW_NONE); if (ShowGraf) { SetIndexStyle(1, DRAW_LINE, EMPTY, EMPTY, g_color_76); SetIndexStyle(2, DRAW_LINE, EMPTY, EMPTY, g_color_80); } else { SetIndexStyle(1, DRAW_NONE, EMPTY, EMPTY, g_color_76); SetIndexStyle(2, DRAW_NONE, EMPTY, EMPTY, g_color_80); } SetIndexLabel(0, "MAX(" + CountBarsForAverage + "," + Target + ")"); SetIndexLabel(1, "MAXUp(" + CountBarsForAverage + "," + Target + ")"); SetIndexLabel(2, "MAXDn(" + CountBarsForAverage + "," + Target + ")"); return (0); } int deinit() { ObjectDelete("StopUpTxt"); ObjectDelete("StopDnTxt"); ObjectDelete("StopUpLine"); ObjectDelete("StopDnLine"); return (0); } int start() { int li_4 = IndicatorCounted(); double ld_20 = Ask - Bid; double ld_28 = 0; double ld_36 = 0; if (li_4 < 0) return (-1); if (li_4 > 0) li_4--; int li_0 = Bars - li_4; ObjectCreate("StopUpLine", OBJ_HLINE, 0, Time[0], Open[0]); ObjectSet("StopUpLine", OBJPROP_STYLE, STYLE_SOLID); ObjectSet("StopUpLine", OBJPROP_COLOR, g_color_76); ObjectCreate("StopUpTxt", OBJ_TEXT, 0, Time[0], Close[0]); ObjectCreate("StopDnLine", OBJ_HLINE, 0, Time[0], Open[0]); ObjectSet("StopDnLine", OBJPROP_STYLE, STYLE_SOLID); ObjectSet("StopDnLine", OBJPROP_COLOR, g_color_80); ObjectCreate("StopDnTxt", OBJ_TEXT, 0, Time[0], Close[0]); for (int li_8 = li_0; li_8 >= 0; li_8--) { ld_28 = 0; for (int li_16 = CountBarsForAverage; li_16 > 0; li_16--) ld_28 += MathAbs(High[li_16 + li_8] - (Low[li_16 + li_8])); ld_36 = ld_28 / CountBarsForAverage; g_ibuf_108[li_8] = Open[li_8] + Target * ld_36 + ld_20; g_ibuf_112[li_8] = Open[li_8] - Target * ld_36; ObjectMove("StopUpLine", 0, Time[0], g_ibuf_108[li_8]); ObjectSetText("StopUpTxt", DoubleToStr(g_ibuf_108[li_8], Digits) + "(+" + DoubleToStr((g_ibuf_108[li_8] - Open[li_8]) * MathPow(10, Digits), 0) + ")", 12, "Terminal", g_color_76); ObjectMove("StopUpTxt", 0, Time[0] + 60 * CountBarsForShift * Period(), g_ibuf_108[li_8]); ObjectMove("StopUpTxt", 1, Time[0] + 60 * CountBarsForShift * Period(), g_ibuf_108[li_8]); ObjectMove("StopDnLine", 0, Time[0], g_ibuf_112[li_8]); ObjectSetText("StopDnTxt", DoubleToStr(g_ibuf_112[li_8], Digits) + "(" + DoubleToStr((g_ibuf_112[li_8] - Open[li_8]) * MathPow(10, Digits), 0) + ")", 12, "Terminal", g_color_80); ObjectMove("StopDnTxt", 0, Time[0] + 60 * CountBarsForShift * Period(), g_ibuf_112[li_8]); ObjectMove("StopDnTxt", 1, Time[0] + 60 * CountBarsForShift * Period(), g_ibuf_112[li_8]); } return (0); }