/* Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] Website: http://purebeam.biz E-mail : purebeam@gmail.com */ #property copyright "© 2016.07.14 SwingMan" #property link "" #property indicator_separate_window #property indicator_levelcolor Gold #property indicator_levelstyle 0 #property indicator_buffers 8 #property indicator_color1 DeepPink #property indicator_color2 LimeGreen #property indicator_color3 Tomato #property indicator_color4 Tomato #property indicator_color5 Tomato #property indicator_color6 DeepSkyBlue #property indicator_color7 DeepSkyBlue #property indicator_color8 DeepSkyBlue #include extern int Period_Statistic = 120; extern int Number_Bars = 500; extern int Number_Levels = 3; extern int ShiftDays_ForReference = 1; extern bool Close_asReferencePrice = TRUE; string gs_96 = "SpielersHedge DivergenceStdDev_v3"; string gs_104 = "SHDStd_3_"; double g_ibuf_112[]; double g_ibuf_116[]; double g_ibuf_120[]; double g_ibuf_124[]; double g_ibuf_128[]; double g_ibuf_132[]; double g_ibuf_136[]; double g_ibuf_140[]; string gs_144; double gd_152; double gd_160; int gi_168; int gi_172; double gd_176; int gi_184 = 8; int gi_188 = 1; int gi_unused_192 = 80; int gi_196 = 2; int gi_unused_200 = 60; int gi_unused_204 = 30; int gi_208 = 5; int gi_212; int gi_216 = 10; void Get_MedRange_DevRange(double ada_0[], double ada_4[], int ai_8, int ai_12, int ai_16, double &a_ima_on_arr_20, double &a_istddev_on_arr_28) { double lda_36[1000]; ArraySetAsSeries(lda_36, TRUE); int l_period_40 = ai_12 - ai_8 + 1; int li_44 = -1; for (int li_48 = ai_8; li_48 < ai_12; li_48++) { li_44++; lda_36[li_44] = MathMax(MathAbs(ada_0[li_48]), MathAbs(ada_4[li_48])); } int li_52 = 0; int li_56 = 0; a_ima_on_arr_20 = iMAOnArray(lda_36, li_52, l_period_40, ai_16, MODE_SMA, li_56); a_istddev_on_arr_28 = iStdDevOnArray(lda_36, li_52, l_period_40, ai_16, MODE_SMA, li_56); } void Write_Label(int ai_0, int ai_4, string as_8, string as_16, string as_24, int ai_32, int ai_36, int ai_40, int ai_44, int ai_48) { string ls_52 = as_8 + "1" + ai_48; string ls_60 = as_8 + "2" + ai_48; SetLabelObject(ai_0, ai_4, ls_52, as_16, ai_32, ai_36, ai_40, ai_48); SetLabelObject(ai_0, ai_4, ls_60, as_24, ai_32, ai_36, ai_44, ai_48); } void SetLabelObject(int a_window_0, int a_corner_4, string a_name_8, string a_text_16, int a_fontsize_24, color a_color_28, int a_x_32, int a_y_36) { ObjectCreate(a_name_8, OBJ_LABEL, a_window_0, 0, 0); ObjectSetText(a_name_8, a_text_16, a_fontsize_24, "Arial Bold", a_color_28); ObjectSet(a_name_8, OBJPROP_CORNER, a_corner_4); ObjectSet(a_name_8, OBJPROP_XDISTANCE, a_x_32); ObjectSet(a_name_8, OBJPROP_YDISTANCE, a_y_36); } void SetArrowObject(int a_window_0, int a_corner_4, string a_name_8, int ai_16, int a_fontsize_20, color a_color_24, int a_x_28, int a_y_32) { ObjectCreate(a_name_8, OBJ_LABEL, a_window_0, 0, 0); ObjectSetText(a_name_8, CharToStr(ai_16), a_fontsize_20, "Wingdings", a_color_24); ObjectSet(a_name_8, OBJPROP_CORNER, a_corner_4); ObjectSet(a_name_8, OBJPROP_XDISTANCE, a_x_28); ObjectSet(a_name_8, OBJPROP_YDISTANCE, a_y_32); } void Write_Text(string a_name_0, string a_text_8, int a_window_16, int a_corner_20, int a_datetime_24, double a_price_28, int a_fontsize_36, color a_color_40) { ObjectCreate(a_name_0, OBJ_TEXT, a_window_16, a_datetime_24, a_price_28); ObjectSetText(a_name_0, a_text_8, a_fontsize_36, "Arial Bold", a_color_40); ObjectSet(a_name_0, OBJPROP_CORNER, a_corner_20); ObjectSet(a_name_0, OBJPROP_TIME1, a_datetime_24); ObjectSet(a_name_0, OBJPROP_PRICE1, a_price_28); } void DeleteOwnObjects(string as_0) { int li_8 = 0; while (li_8 <= ObjectsTotal()) { if (StringFind(ObjectName(li_8), as_0) >= 0) ObjectDelete(ObjectName(li_8)); else li_8++; } } int init() { string ls_0; if (Close_asReferencePrice == TRUE) { ls_0 = "C,"; ls_0 = ls_0 + ShiftDays_ForReference + ", "; } else { ls_0 = "O,"; ls_0 = ls_0 + ShiftDays_ForReference + ", "; } ls_0 = ls_0 + Period_Statistic; gs_144 = gs_96 + " (" + ls_0 + ") "; IndicatorShortName(gs_144); SetIndexBuffer(0, g_ibuf_112); SetIndexBuffer(1, g_ibuf_116); SetIndexBuffer(2, g_ibuf_120); SetIndexBuffer(3, g_ibuf_124); SetIndexBuffer(4, g_ibuf_128); SetIndexBuffer(5, g_ibuf_132); SetIndexBuffer(6, g_ibuf_136); SetIndexBuffer(7, g_ibuf_140); SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1); SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1); SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 1); SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 1); if (Number_Levels == 1) { SetIndexStyle(3, DRAW_NONE); SetIndexStyle(6, DRAW_NONE); SetIndexStyle(4, DRAW_NONE); SetIndexStyle(7, DRAW_NONE); } else { if (Number_Levels == 2) { SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 1); SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 1); SetIndexStyle(4, DRAW_NONE); SetIndexStyle(7, DRAW_NONE); } else { if (Number_Levels == 3) { SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 1); SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 1); SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 1); SetIndexStyle(7, DRAW_LINE, STYLE_SOLID, 1); } } } SetIndexLabel(0, "Ratio SHORT trade"); SetIndexLabel(1, "Ratio LONG trade"); SetIndexLabel(2, "Level1"); if (Number_Levels == 2) { SetIndexLabel(3, "Level2"); SetIndexLabel(4, NULL); } if (Number_Levels == 3) { SetIndexLabel(3, "Level2"); SetIndexLabel(4, "Level3"); } SetIndexLabel(5, NULL); SetIndexLabel(6, NULL); SetIndexLabel(7, NULL); return (0); } int deinit() { DeleteOwnObjects(gs_104); return (0); } int start() { int lia_12[]; double l_ihigh_20; double l_ilow_28; double l_ima_on_arr_44; double l_istddev_on_arr_52; ArrayCopySeries(lia_12, 5, Symbol(), PERIOD_D1); int li_16 = IndicatorCounted(); if (li_16 > 0) li_16--; int li_8 = Bars - li_16; int li_0 = 0; int l_index_4 = 0; while (li_0 < li_8) { if (Time[li_0] < lia_12[l_index_4]) l_index_4++; if (Close_asReferencePrice == TRUE) gd_152 = iClose(Symbol(), PERIOD_D1, l_index_4 + ShiftDays_ForReference); else gd_152 = iOpen(Symbol(), PERIOD_D1, l_index_4 + ShiftDays_ForReference - 1); if (li_0 == 0) gd_176 = gd_152; l_ihigh_20 = iHigh(Symbol(), Period(), li_0); l_ilow_28 = iLow(Symbol(), Period(), li_0); if (gd_152 != 0.0) { g_ibuf_112[li_0] = 100.0 * (l_ihigh_20 - gd_152) / gd_152; g_ibuf_116[li_0] = 100.0 * (l_ilow_28 - gd_152) / gd_152; } li_0++; } double l_iclose_36 = iClose(Symbol(), Period(), 0); gd_160 = 100.0 * (l_iclose_36 - gd_176) / gd_176; for (li_0 = 0; li_0 < Number_Bars; li_0++) { Get_MedRange_DevRange(g_ibuf_112, g_ibuf_116, li_0, li_0 + Period_Statistic, 1, l_ima_on_arr_44, l_istddev_on_arr_52); g_ibuf_120[li_0] = l_ima_on_arr_44; g_ibuf_124[li_0] = g_ibuf_120[li_0] + l_istddev_on_arr_52; g_ibuf_128[li_0] = g_ibuf_124[li_0] + l_istddev_on_arr_52; g_ibuf_132[li_0] = -l_ima_on_arr_44; g_ibuf_136[li_0] = g_ibuf_132[li_0] - l_istddev_on_arr_52; g_ibuf_140[li_0] = g_ibuf_136[li_0] - l_istddev_on_arr_52; } Write_TradingLevels(); Write_CurrentRange(); return (0); } void Write_TradingLevels() { string ls_0; string ls_8; string ls_16; int li_36; int li_44; string ls_92; int li_100; gi_168 = WindowFind(gs_144); int li_32 = 0; gi_212 = gi_208; gi_188 = TRUE; int li_40 = 42495; int li_48 = 10; double l_iclose_52 = iClose(Symbol(), Period(), 0); string ls_24 = "(" + DoubleToStr(gd_176, Digits) + " / " + DoubleToStr(l_iclose_52, Digits) + ")"; double ld_60 = g_ibuf_112[li_32]; double ld_68 = g_ibuf_116[li_32]; double ld_76 = MathAbs(ld_68 - g_ibuf_132[li_32]); double ld_84 = MathAbs(ld_60 - g_ibuf_120[li_32]); if (gd_160 < 0.0) gi_172 = 1; else gi_172 = -1; if (gi_172 == 1) { li_44 = 32768; if (gd_160 < g_ibuf_132[li_32]) { ls_92 = "LONG"; li_100 = 233; } else { ls_92 = "wait long"; li_100 = 216; } if (gd_160 < g_ibuf_132[li_32]) li_36 = 0; if (gd_160 <= g_ibuf_132[li_32] && gd_160 > g_ibuf_136[li_32]) li_36 = 1; if (gd_160 <= g_ibuf_136[li_32] && gd_160 > g_ibuf_140[li_32]) li_36 = 2; if (gd_160 <= g_ibuf_140[li_32]) li_36 = 3; ls_0 = "1.= " + DoubleToStr(g_ibuf_132[li_32], 2) + "%"; ls_8 = "2.= " + DoubleToStr(g_ibuf_136[li_32], 2) + "%"; ls_16 = "3.= " + DoubleToStr(g_ibuf_140[li_32], 2) + "%"; } else { li_44 = 255; if (gd_160 >= g_ibuf_120[li_32]) { ls_92 = "SHORT"; li_100 = 234; } else { ls_92 = "wait short"; li_100 = 216; } if (gd_160 > g_ibuf_120[li_32]) li_36 = 0; if (gd_160 >= g_ibuf_120[li_32] && gd_160 < g_ibuf_124[li_32]) li_36 = 1; if (gd_160 >= g_ibuf_124[li_32] && gd_160 < g_ibuf_128[li_32]) li_36 = 2; if (gd_160 >= g_ibuf_128[li_32]) li_36 = 3; ls_0 = "1.= " + DoubleToStr(g_ibuf_120[li_32], 2) + "%"; ls_8 = "2.= " + DoubleToStr(g_ibuf_124[li_32], 2) + "%"; ls_16 = "3.= " + DoubleToStr(g_ibuf_128[li_32], 2) + "%"; } string ls_104 = "Range: " + DoubleToStr(gd_160, 2) + "%"; string ls_112 = "Level: " + li_36; Write_Label(gi_168, gi_188, gs_104, ls_104, "", gi_184, li_40, gi_196, gi_196, gi_212); gi_212 += gi_216; Write_Label(gi_168, gi_188, gs_104, ls_24, "", gi_184, li_40, gi_196, gi_196, gi_212); gi_212 += gi_216; Write_Label(gi_168, gi_188, gs_104, ls_112, "", gi_184, li_40, gi_196, gi_196, gi_212); gi_212 += gi_216; gi_212 += 5; Write_Label(gi_168, gi_188, gs_104, ls_0, "", gi_184, li_40, gi_196, gi_196, gi_212); gi_212 += gi_216; Write_Label(gi_168, gi_188, gs_104, ls_8, "", gi_184, li_40, gi_196, gi_196, gi_212); gi_212 += gi_216; Write_Label(gi_168, gi_188, gs_104, ls_16, "", gi_184, li_40, gi_196, gi_196, gi_212); gi_212 += gi_216; li_40 = 55295; gi_212 += 5; Write_Label(gi_168, gi_188, gs_104, ls_92, "", gi_184, li_40, gi_196 + 20, gi_196, gi_212); SetArrowObject(gi_168, gi_188, gs_104 + "a", li_100, li_48, li_44, gi_196 + 5, gi_212); } void Write_CurrentRange() { int li_20; string ls_28; bool li_0 = FALSE; double ld_4 = 9; double ld_12 = 1.0; if (gd_160 > 0.0) li_20 = 255; else li_20 = 16760576; datetime l_time_24 = Time[0]; if (gd_160 > 0.0) ls_28 = "+"; else ls_28 = ""; double ld_36 = gd_160 + ld_4 * ld_12 / 100.0; string ls_44 = " " + ls_28 + DoubleToStr(gd_160, 2) + "%"; Write_Text(gs_104 + "Range", ls_44, gi_168, li_0, l_time_24, ld_36, ld_4, li_20); }