#property copyright "Copyright © 2009.05.17, SwingMan" #property link "" #property indicator_separate_window #property indicator_minimum -3.0 #property indicator_maximum 3.0 #property indicator_buffers 8 #property indicator_color1 LimeGreen #property indicator_color2 OliveDrab #property indicator_color3 Green #property indicator_color4 IndianRed #property indicator_color5 Sienna #property indicator_color6 Red #property indicator_color7 Gray #property indicator_color8 Gray #property indicator_width1 3 extern int Nbars = 3000; extern bool Draw_HourVertLines = TRUE; string gs_84 = "H1Scalper OscD1_v3"; int gi_92 = 3; string gs_96 = "Signal_"; int gi_104 = 9; double gd_108 = 0.0; int gi_unused_116 = 21; int gi_120 = 27; double gd_124 = 1.5; int gi_132 = 3; int gi_136 = 0; double g_ibuf_140[]; double g_ibuf_144[]; double g_ibuf_148[]; double g_ibuf_152[]; double g_ibuf_156[]; double g_ibuf_160[]; double g_ibuf_164[]; double g_ibuf_168[]; int gi_172 = -1; int gi_unused_176 = 0; int init() { gi_172 = WindowFind(gs_84); SetIndexBuffer(0, g_ibuf_140); SetIndexStyle(0, DRAW_HISTOGRAM); SetIndexLabel(0, "long1"); SetIndexBuffer(1, g_ibuf_144); SetIndexStyle(1, DRAW_HISTOGRAM); SetIndexLabel(1, "long2"); SetIndexBuffer(2, g_ibuf_148); SetIndexStyle(2, DRAW_HISTOGRAM); SetIndexLabel(2, "long3"); SetIndexBuffer(3, g_ibuf_160); SetIndexStyle(3, DRAW_HISTOGRAM); SetIndexLabel(3, "short1"); SetIndexBuffer(4, g_ibuf_164); SetIndexStyle(4, DRAW_HISTOGRAM); SetIndexLabel(4, "short2"); SetIndexBuffer(5, g_ibuf_168); SetIndexStyle(5, DRAW_HISTOGRAM); SetIndexLabel(5, "short3"); SetIndexBuffer(6, g_ibuf_152); SetIndexStyle(6, DRAW_HISTOGRAM); SetIndexLabel(6, NULL); SetIndexBuffer(7, g_ibuf_156); SetIndexStyle(7, DRAW_HISTOGRAM); SetIndexLabel(7, NULL); return (0); } int deinit() { ObjectsDeleteAll(EMPTY, OBJ_VLINE); return (0); } int start() { double l_iclose_12; double l_ihigh_20; double l_ilow_28; int li_36; int li_40; double l_ima_44; double l_ima_52; double l_ima_60; double l_ima_68; int li_76; double l_icustom_80; int li_88; double ld_92; int li_100; bool l_bool_104; double ld_108; double l_bool_116; if (gi_172 == -1) gi_172 = WindowFind(gs_84); int li_0 = IndicatorCounted(); if (li_0 > 0) li_0--; int li_4 = Bars - li_0; for (int li_8 = li_4; li_8 >= 0; li_8--) { l_iclose_12 = iClose(Symbol(), Period(), li_8); l_ihigh_20 = iHigh(Symbol(), Period(), li_8 + 1); l_ilow_28 = iLow(Symbol(), Period(), li_8 + 1); Get_HiloMavgTrend(li_36, l_ima_44, l_ima_52, li_8); Get_HiloMavgTrend(li_40, l_ima_60, l_ima_68, li_8 + 1); Get_HullTrend(li_76, l_icustom_80, li_8); Get_BBandsTrend(li_88, ld_92, li_8); if (li_76 == 1) { li_100 = l_icustom_80 > l_ima_44; l_bool_104 = l_iclose_12 > l_ima_44 && l_ihigh_20 > l_ima_60; if (li_100 == 1 && li_88 == 1 && l_bool_104 == TRUE) { g_ibuf_140[li_8] = EMPTY_VALUE; g_ibuf_144[li_8] = EMPTY_VALUE; g_ibuf_148[li_8] = 3; g_ibuf_160[li_8] = EMPTY_VALUE; g_ibuf_164[li_8] = EMPTY_VALUE; g_ibuf_168[li_8] = EMPTY_VALUE; Write_Label(gi_172, gi_92, gs_96, "LONG", "", gi_104, 32768, 0, 2, 0, 2); } else { if (li_88 == 1 && l_bool_104 == TRUE) { g_ibuf_140[li_8] = EMPTY_VALUE; g_ibuf_144[li_8] = 2; g_ibuf_148[li_8] = EMPTY_VALUE; g_ibuf_160[li_8] = EMPTY_VALUE; g_ibuf_164[li_8] = EMPTY_VALUE; g_ibuf_168[li_8] = EMPTY_VALUE; Write_Label(gi_172, gi_92, gs_96, "L2", "", gi_104, 32768, 0, 2, 0, 2); } else { if (l_bool_104 == TRUE) { g_ibuf_140[li_8] = 1; g_ibuf_144[li_8] = EMPTY_VALUE; g_ibuf_148[li_8] = EMPTY_VALUE; g_ibuf_160[li_8] = EMPTY_VALUE; g_ibuf_164[li_8] = EMPTY_VALUE; g_ibuf_168[li_8] = EMPTY_VALUE; Write_Label(gi_172, gi_92, gs_96, "L1", "", gi_104, 32768, 0, 2, 0, 2); } else { g_ibuf_152[li_8] = gd_108; g_ibuf_156[li_8] = -gd_108; g_ibuf_140[li_8] = EMPTY_VALUE; g_ibuf_144[li_8] = EMPTY_VALUE; g_ibuf_148[li_8] = EMPTY_VALUE; g_ibuf_160[li_8] = EMPTY_VALUE; g_ibuf_164[li_8] = EMPTY_VALUE; g_ibuf_168[li_8] = EMPTY_VALUE; Delete_OwnObjects(gs_96); } } } } else { if (li_76 == -1) { ld_108 = l_icustom_80 < l_ima_52; l_bool_116 = l_iclose_12 < l_ima_52 && l_ilow_28 < l_ima_68; if (ld_108 == 1.0 && li_88 == -1 && l_bool_116 == 1.0) { g_ibuf_140[li_8] = EMPTY_VALUE; g_ibuf_144[li_8] = EMPTY_VALUE; g_ibuf_148[li_8] = EMPTY_VALUE; g_ibuf_160[li_8] = EMPTY_VALUE; g_ibuf_164[li_8] = EMPTY_VALUE; g_ibuf_168[li_8] = -3; Write_Label(gi_172, gi_92, gs_96, "SHORT", "", gi_104, 255, 0, 2, 0, 2); } else { if (li_88 == -1 && l_bool_116 == 1.0) { g_ibuf_140[li_8] = EMPTY_VALUE; g_ibuf_144[li_8] = EMPTY_VALUE; g_ibuf_148[li_8] = EMPTY_VALUE; g_ibuf_160[li_8] = EMPTY_VALUE; g_ibuf_164[li_8] = -2; g_ibuf_168[li_8] = EMPTY_VALUE; Write_Label(gi_172, gi_92, gs_96, "S2", "", gi_104, 255, 0, 2, 0, 2); } else { if (l_bool_116 == 1.0) { g_ibuf_140[li_8] = EMPTY_VALUE; g_ibuf_144[li_8] = EMPTY_VALUE; g_ibuf_148[li_8] = EMPTY_VALUE; g_ibuf_160[li_8] = -1; g_ibuf_164[li_8] = EMPTY_VALUE; g_ibuf_168[li_8] = EMPTY_VALUE; Write_Label(gi_172, gi_92, gs_96, "S1", "", gi_104, 255, 0, 2, 0, 2); } else { g_ibuf_152[li_8] = gd_108; g_ibuf_156[li_8] = -gd_108; g_ibuf_140[li_8] = EMPTY_VALUE; g_ibuf_144[li_8] = EMPTY_VALUE; g_ibuf_148[li_8] = EMPTY_VALUE; g_ibuf_160[li_8] = EMPTY_VALUE; g_ibuf_164[li_8] = EMPTY_VALUE; g_ibuf_168[li_8] = EMPTY_VALUE; Delete_OwnObjects(gs_96); } } } } } Draw_HourVerticalLines(li_8); } return (0); } void Draw_HourVerticalLines(int ai_0) { int l_datetime_4; int l_datetime_8; string l_time2str_12; string l_time2str_20; if (Draw_HourVertLines == TRUE && Period() < PERIOD_M15 && ai_0 <= Nbars) { l_datetime_4 = iTime(Symbol(), Period(), ai_0); l_datetime_8 = iTime(Symbol(), Period(), ai_0 + 1); l_time2str_12 = TimeToStr(l_datetime_4, TIME_MINUTES); l_time2str_20 = TimeToStr(l_datetime_8, TIME_MINUTES); if (l_time2str_12 == "00:00" || (l_time2str_12 == "00:01" && l_time2str_20 != "00:00") || l_time2str_12 == "01:00" || (l_time2str_12 == "01:01" && l_time2str_20 != "01:00") || l_time2str_12 == "02:00" || (l_time2str_12 == "02:01" && l_time2str_20 != "02:00") || l_time2str_12 == "03:00" || (l_time2str_12 == "03:01" && l_time2str_20 != "03:00") || l_time2str_12 == "04:00" || (l_time2str_12 == "04:01" && l_time2str_20 != "04:00") || l_time2str_12 == "05:00" || (l_time2str_12 == "05:01" && l_time2str_20 != "05:00") || l_time2str_12 == "06:00" || (l_time2str_12 == "06:01" && l_time2str_20 != "06:00") || l_time2str_12 == "07:00" || (l_time2str_12 == "07:01" && l_time2str_20 != "07:00") || l_time2str_12 == "08:00" || (l_time2str_12 == "08:01" && l_time2str_20 != "08:00") || l_time2str_12 == "09:00" || (l_time2str_12 == "09:01" && l_time2str_20 != "09:00") || l_time2str_12 == "10:00" || (l_time2str_12 == "10:01" && l_time2str_20 != "10:00") || l_time2str_12 == "11:00" || (l_time2str_12 == "11:01" && l_time2str_20 != "11:00") || l_time2str_12 == "12:00" || (l_time2str_12 == "12:01" && l_time2str_20 != "12:00") || l_time2str_12 == "13:00" || (l_time2str_12 == "13:01" && l_time2str_20 != "13:00") || l_time2str_12 == "14:00" || (l_time2str_12 == "14:01" && l_time2str_20 != "14:00") || l_time2str_12 == "15:00" || (l_time2str_12 == "15:01" && l_time2str_20 != "15:00") || l_time2str_12 == "16:00" || (l_time2str_12 == "16:01" && l_time2str_20 != "16:00") || l_time2str_12 == "17:00" || (l_time2str_12 == "17:01" && l_time2str_20 != "17:00") || l_time2str_12 == "18:00" || (l_time2str_12 == "18:01" && l_time2str_20 != "18:00") || l_time2str_12 == "19:00" || (l_time2str_12 == "19:01" && l_time2str_20 != "19:00") || l_time2str_12 == "20:00" || (l_time2str_12 == "20:01" && l_time2str_20 != "20:00") || l_time2str_12 == "21:00" || (l_time2str_12 == "21:01" && l_time2str_20 != "21:00") || l_time2str_12 == "22:00" || (l_time2str_12 == "22:01" && l_time2str_20 != "22:00") || l_time2str_12 == "23:00" || (l_time2str_12 == "23:01" && l_time2str_20 != "23:00")) { SetVerticalLine("TimeHour_", l_datetime_4, STYLE_DOT, DarkGray); gi_unused_176 = l_datetime_4; } } } void SetVerticalLine(string a_name_0, int ai_8, int a_style_12, color a_color_16) { a_name_0 = a_name_0 + TimeToStr(ai_8, TIME_DATE|TIME_MINUTES|TIME_SECONDS); ObjectCreate(a_name_0, OBJ_VLINE, 0, ai_8, 0); ObjectSet(a_name_0, OBJPROP_COLOR, a_color_16); ObjectSet(a_name_0, OBJPROP_STYLE, a_style_12); } void Get_BBandsTrend(int &ai_0, double ad_unused_4, int ai_12) { int li_16 = 20; int li_20 = 2; double ld_24 = 1.0; bool li_32 = TRUE; bool li_36 = TRUE; bool li_40 = FALSE; double l_icustom_44 = iCustom(Symbol(), Period(), "BBANDS~1", li_16, li_20, ld_24, li_32, li_36, Nbars, li_40, 4, ai_12); double l_icustom_52 = iCustom(Symbol(), Period(), "BBANDS~1", li_16, li_20, ld_24, li_32, li_36, Nbars, li_40, 5, ai_12); if (l_icustom_52 == EMPTY_VALUE) { ai_0 = 1; ad_unused_4 = l_icustom_44; return; } if (l_icustom_44 == EMPTY_VALUE) { ai_0 = -1; ad_unused_4 = l_icustom_52; } } void Get_HiloMavgTrend(int &ai_0, double &a_ima_4, double &a_ima_12, int ai_20) { int l_period_24 = 21; int li_28 = 1; double l_iclose_32 = iClose(Symbol(), Period(), ai_20); double l_iclose_40 = iClose(Symbol(), Period(), ai_20 + 1); a_ima_4 = iMA(Symbol(), Period(), l_period_24, li_28, MODE_SMA, PRICE_HIGH, ai_20); a_ima_12 = iMA(Symbol(), Period(), l_period_24, li_28, MODE_SMA, PRICE_LOW, ai_20); double l_ima_48 = iMA(Symbol(), Period(), l_period_24, li_28, MODE_SMA, PRICE_HIGH, ai_20 + 1); double l_ima_56 = iMA(Symbol(), Period(), l_period_24, li_28, MODE_SMA, PRICE_LOW, ai_20 + 1); ai_0 = 0; if (l_iclose_40 >= l_ima_48 && l_iclose_32 >= a_ima_4) { ai_0 = 1; return; } if (l_iclose_40 <= l_ima_56 && l_iclose_32 <= a_ima_12) ai_0 = -1; } void Get_HullTrend(int &ai_0, double &a_icustom_4, int ai_12) { double l_icustom_16 = iCustom(Symbol(), Period(), "smHull Mavg", gi_120, gd_124, gi_132, gi_136, 0, ai_12); double l_icustom_24 = iCustom(Symbol(), Period(), "smHull Mavg", gi_120, gd_124, gi_132, gi_136, 1, ai_12); double l_icustom_32 = iCustom(Symbol(), Period(), "smHull Mavg", gi_120, gd_124, gi_132, gi_136, 0, ai_12 + 1); double l_icustom_40 = iCustom(Symbol(), Period(), "smHull Mavg", gi_120, gd_124, gi_132, gi_136, 1, ai_12 + 1); if (l_icustom_16 != l_icustom_24) { if (l_icustom_16 != EMPTY_VALUE) { ai_0 = 1; a_icustom_4 = l_icustom_16; } else { if (l_icustom_24 != EMPTY_VALUE) { ai_0 = -1; a_icustom_4 = l_icustom_24; } } } else { if (l_icustom_32 != EMPTY_VALUE) { ai_0 = 1; a_icustom_4 = l_icustom_32; } else { if (l_icustom_40 != EMPTY_VALUE) { ai_0 = -1; a_icustom_4 = l_icustom_40; } } } } 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, int ai_52) { string ls_56 = as_8 + "1" + ai_52; string ls_64 = as_8 + "2" + ai_52; SetLabelObject(ai_0, ai_4, ls_56, as_16, ai_32, ai_36, ai_44, ai_52); SetLabelObject(ai_0, ai_4, ls_64, as_24, ai_32, ai_40, ai_48, ai_52); } 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 Delete_OwnObjects(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++; } li_8 = 0; while (li_8 <= ObjectsTotal()) { if (StringFind(ObjectName(li_8), as_0) >= 0) ObjectDelete(ObjectName(li_8)); else li_8++; } }