#property copyright "InsightNext" #property link "http://tq-support.sub.jp/blog/" #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_color3 Green #property indicator_color4 Blue #property indicator_color5 Red #property indicator_color6 Orange #property indicator_color7 Purple #property indicator_color8 Gray int gi_76 = 20110630; extern int starttime = 8; extern int endtime = 20; extern int exit_limit_pips = 600; extern int exit_stop_pips = 50; extern int max_pips = 100; extern bool high_sensitive = TRUE; extern int candle_filter = 50; extern int entry_bb_width = 0; extern bool enable_pivot_filter = TRUE; extern int ema_filter = 15; extern bool enable_pre_signal = TRUE; extern int pre_entry_pips = 10; extern int pre_exit_pips = 5; extern bool enable_send_mail = TRUE; extern bool enable_Hit_alert = TRUE; extern int Hit_alert1 = 10; extern int Hit_alert2 = 30; extern int Hit_alert3 = 50; extern int Hit_alert4 = 100; extern int Hit_alert5 = 150; extern int Hit_alert6 = 200; extern bool enable_Pivot_alert = TRUE; extern int pivot_start_hour = 0; extern bool show_result = TRUE; extern color result_color = DeepPink; extern bool enable_re_entry = TRUE; int gi_184; int gi_188; bool gi_192 = FALSE; bool gi_196 = FALSE; bool gi_200 = FALSE; int gi_204 = 0; bool gi_208 = FALSE; string gs_exit_212 = "EXIT"; int gi_220 = 0; int gi_224 = 0; int gi_228 = 0; int gi_232 = 0; int gi_236 = 0; int gi_240 = 0; int gi_244 = 0; int gi_248 = 0; int gi_252 = 0; int gi_256 = 0; int gi_260 = 3; double g_ibuf_264[]; double g_ibuf_268[]; double g_ibuf_272[]; double g_ibuf_276[]; double g_ibuf_280[]; double g_ibuf_284[]; double g_ibuf_288[]; double g_ibuf_292[]; int init() { IndicatorBuffers(8); IndicatorShortName("TQ"); SetIndexBuffer(0, g_ibuf_264); SetIndexBuffer(1, g_ibuf_268); SetIndexBuffer(2, g_ibuf_272); SetIndexBuffer(3, g_ibuf_276); SetIndexBuffer(4, g_ibuf_280); SetIndexBuffer(5, g_ibuf_284); SetIndexBuffer(6, g_ibuf_288); SetIndexBuffer(7, g_ibuf_292); SetIndexStyle(0, DRAW_ARROW); SetIndexArrow(0, 233); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, 234); SetIndexStyle(2, DRAW_ARROW); SetIndexArrow(2, SYMBOL_STOPSIGN); SetIndexStyle(5, DRAW_ARROW); SetIndexArrow(5, 171); SetIndexStyle(6, DRAW_ARROW); SetIndexArrow(6, 80); SetIndexStyle(7, DRAW_NONE); SetIndexLabel(0, "Buy"); SetIndexLabel(1, "Selll"); SetIndexLabel(2, "Exit"); SetIndexLabel(3, "BuyPosition"); SetIndexLabel(4, "SellPosition"); SetIndexLabel(5, "Limit"); SetIndexLabel(6, "Pre"); SetIndexLabel(7, NULL); gi_184 = 0; gi_188 = 0; gi_196 = FALSE; return (0); } int start() { int li_20; int l_ind_counted_0 = IndicatorCounted(); int li_4 = Bars - l_ind_counted_0 - 1; double ld_8 = 0; for (int li_16 = li_4; li_16 >= 0; li_16--) { li_20 = beforeLoop(li_16); if (li_20 != 2) { if (li_20 == 3) return (0); if (gi_208 && gi_196 == FALSE && gi_184 == 0) { if (checkPreEntryStatus(li_16)) { if (gi_188 == 1) preAlert(Symbol(), "[BUY]", getNumber(Bid), ""); else if (gi_188 == -1) preAlert(Symbol(), "[SELL]", getNumber(Bid), ""); } } if (gi_204 != FALSE) { resetModoriVector(li_16); if (checkModoriEntryStatus(li_16, gi_204)) { if (gi_204 == TRUE) doBuy(li_16); else doSell(li_16); } } if (gi_184 == 0 && g_ibuf_272[li_16] == EMPTY_VALUE) { g_ibuf_292[li_16] = EMPTY_VALUE; g_ibuf_276[li_16] = EMPTY_VALUE; g_ibuf_280[li_16] = EMPTY_VALUE; } if (gi_184 == 0) { if (checkEntryStatus(li_16)) { if (gi_188 == 1) doBuy(li_16); else if (gi_188 == -1) doSell(li_16); } } else { if (gi_184 != 0) { if (gi_208) { winAlert(Bid); pivotAlert(Bid); } g_ibuf_292[li_16] = Close[li_16]; if (gi_184 == 1) g_ibuf_276[li_16] = Close[li_16]; else if (gi_184 == -1) g_ibuf_280[li_16] = Close[li_16]; ld_8 = checkExitStatus(li_16); if (ld_8 != 0.0) { doExit(li_16, ld_8); continue; } } if (gi_184 != 0 && gi_200 == FALSE && gi_208) if (checkPreExitStatus()) preExitAlert(Symbol(), "[EXIT]", getNumber(Bid), ""); } } } return (0); } int checkTF(int ai_0) { int lia_8[4]; int lia_16[4]; lia_8[0] = iCustom(NULL, Period(), "TQ_02", 0, ai_0); lia_8[1] = iCustom(NULL, Period(), "TQ_02", 2, ai_0); lia_8[2] = iCustom(NULL, Period(), "TQ_02", 4, ai_0); lia_8[3] = iCustom(NULL, Period(), "TQ_02", 6, ai_0); if (high_sensitive) lia_8[3] = 1; bool li_12 = TRUE; for (int l_index_4 = 0; l_index_4 <= 3; l_index_4++) { if (!(lia_8[l_index_4] == 1 || lia_8[l_index_4] == 2 || lia_8[l_index_4] == 3 || lia_8[l_index_4] == 4)) { li_12 = FALSE; break; } } if (li_12) return (1); lia_16[0] = iCustom(NULL, Period(), "TQ_02", 1, ai_0); lia_16[1] = iCustom(NULL, Period(), "TQ_02", 3, ai_0); lia_16[2] = iCustom(NULL, Period(), "TQ_02", 5, ai_0); lia_16[3] = iCustom(NULL, Period(), "TQ_02", 7, ai_0); if (high_sensitive) lia_16[3] = 1; bool li_20 = TRUE; for (l_index_4 = 0; l_index_4 <= 3; l_index_4++) { if (!(lia_16[l_index_4] == 1 || lia_16[l_index_4] == 2 || lia_16[l_index_4] == 3 || lia_16[l_index_4] == 4)) { li_20 = FALSE; break; } } if (li_20) return (-1); return (0); } int checkSARVector(int ai_0, int ai_4) { double ld_8 = High[ai_0]; double ld_16 = Low[ai_0]; if (gi_208) { ld_8 = Bid; ld_16 = Bid; } double ld_24 = getEntryValue(ai_0, ai_4); if (ai_4 == 1) if (ld_8 > fetchSARHigh(ai_0 + 2) && MathAbs(fetchSARHigh(ai_0 + 2) - ld_24) < pips2money(candle_filter)) return (1); if (ai_4 == -1) if (ld_16 < fetchSARLow(ai_0 + 2) && MathAbs(fetchSARLow(ai_0 + 2) - ld_24) < pips2money(candle_filter)) return (1); return (0); } double getEntryValue(int ai_0, int ai_4) { double ld_32; double ld_8 = High[ai_0]; double ld_16 = Low[ai_0]; if (gi_208) { ld_8 = Bid; ld_16 = Bid; } double ld_ret_24 = 0; if (ai_4 == 1) { ld_32 = fetchSARHigh(ai_0 + 2); if (ld_8 > ld_32) ld_ret_24 = ld_32; } if (ai_4 == -1) { ld_32 = fetchSARLow(ai_0 + 2); if (ld_16 < ld_32) ld_ret_24 = ld_32; } if (ld_ret_24 == 0.0) ld_ret_24 = Open[ai_0]; if (ld_ret_24 > High[ai_0] || ld_ret_24 < Low[ai_0]) ld_ret_24 = Open[ai_0]; if (gi_208) ld_ret_24 = Bid; return (ld_ret_24); } bool checkEntryStatus(int ai_0) { int li_4 = getVector(ai_0); if (enable_re_entry == FALSE) if (g_ibuf_272[ai_0] != EMPTY_VALUE) return (FALSE); if (li_4 == 0) return (FALSE); if (checkSARVector(ai_0, li_4) == 0) return (FALSE); if (checkBBWidth(ai_0) == 0) return (FALSE); if (enable_pivot_filter) if (checkPivotEntryStatus(ai_0, li_4) == 0) return (FALSE); if (checkEmaEntryStatus(ai_0, li_4) == 0) { gi_204 = li_4; return (FALSE); } return (TRUE); } bool checkPreEntryStatus(int ai_0) { int lia_12[2]; int lia_20[2]; bool li_24; int li_4 = 0; lia_12[0] = iCustom(NULL, Period(), "TQ_02", 2, ai_0); lia_12[1] = iCustom(NULL, Period(), "TQ_02", 4, ai_0); bool li_16 = TRUE; for (int l_index_8 = 0; l_index_8 <= 1; l_index_8++) { if (!(lia_12[l_index_8] == 1 || lia_12[l_index_8] == 2 || lia_12[l_index_8] == 3 || lia_12[l_index_8] == 4)) { li_16 = FALSE; break; } } if (li_16) li_4 = 1; if (li_4 == 0) { lia_20[0] = iCustom(NULL, Period(), "TQ_02", 3, ai_0); lia_20[1] = iCustom(NULL, Period(), "TQ_02", 5, ai_0); li_24 = TRUE; for (l_index_8 = 0; l_index_8 <= 1; l_index_8++) { if (!(lia_20[l_index_8] == 1 || lia_20[l_index_8] == 2 || lia_20[l_index_8] == 3 || lia_20[l_index_8] == 4)) { li_24 = FALSE; break; } } if (li_24) li_4 = -1; } if (li_4 == 0) return (FALSE); if (li_4 == 1) { if (fetchSARHigh(ai_0 + 2) - Bid < pips2money(pre_entry_pips)) return (TRUE); return (FALSE); } if (li_4 == -1) { if (Bid - fetchSARLow(ai_0 + 2) < pips2money(pre_entry_pips)) return (TRUE); return (FALSE); } return (FALSE); } bool checkPreExitStatus() { double ld_0; double ld_8; if (gi_184 == 1) { ld_0 = fetchSARLow(2); if (Bid < ld_0 + pips2money(pre_exit_pips)) return (TRUE); } if (gi_184 == -1) { ld_8 = fetchSARHigh(2); if (Bid > ld_8 - pips2money(pre_exit_pips)) return (TRUE); } return (FALSE); } double checkExitStatus(int ai_0) { double ld_44; double ld_52; double ld_4 = Close[ai_0]; double ld_12 = Close[ai_0]; if (gi_208) { ld_4 = Bid; ld_12 = Bid; } else { if (gi_184 == 1) { ld_4 = High[ai_0]; ld_12 = Low[ai_0]; } else { ld_4 = Low[ai_0]; ld_12 = High[ai_0]; } } double ld_20 = getRecentEntryRate(ai_0, gi_184); if (gi_184 == 1 && ld_4 >= ld_20 + pips2money(exit_limit_pips)) { gs_exit_212 = "LIMIT"; return (ld_20 + pips2money(exit_limit_pips)); } if (gi_184 == -1 && ld_12 <= ld_20 - pips2money(exit_limit_pips)) { gs_exit_212 = "LIMIT"; return (ld_20 - pips2money(exit_limit_pips)); } double ld_ret_28 = 0; double ld_ret_36 = 0; if (gi_184 == 1) { ld_44 = fetchSARLow(ai_0 + 2); if (High[ai_0] < ld_44 || Low[ai_0] < ld_44 || Open[ai_0] < ld_44 || Close[ai_0] < ld_44) ld_ret_28 = ld_44; } if (gi_184 == -1) { ld_52 = fetchSARHigh(ai_0 + 2); if (High[ai_0] > ld_52 || Low[ai_0] > ld_52 || Open[ai_0] > ld_52 || Close[ai_0] > ld_52) ld_ret_28 = ld_52; } if (gi_184 == 1 && ld_12 <= ld_20 - pips2money(exit_stop_pips)) ld_ret_36 = ld_20 - pips2money(exit_stop_pips); else if (gi_184 == -1 && ld_12 >= ld_20 + pips2money(exit_stop_pips)) ld_ret_36 = ld_20 + pips2money(exit_stop_pips); if (ld_ret_28 != 0.0 || ld_ret_36 != 0.0) { if (ld_ret_28 != 0.0 && ld_ret_36 == 0.0) { gs_exit_212 = "EXIT"; return (ld_ret_28); } if (ld_ret_28 == 0.0 && ld_ret_36 != 0.0) { gs_exit_212 = "EXIT"; return (ld_ret_36); } if (gi_184 == 1) { if (ld_ret_28 > ld_ret_36) { gs_exit_212 = "EXIT"; return (ld_ret_28); } gs_exit_212 = "EXIT"; return (ld_ret_36); } if (gi_184 == -1) { if (ld_ret_28 < ld_ret_36) { gs_exit_212 = "EXIT"; return (ld_ret_28); } gs_exit_212 = "EXIT"; return (ld_ret_36); } } double l_ima_60 = iMA(NULL, 0, 50, 0, MODE_EMA, PRICE_CLOSE, ai_0); if (gi_184 == 1) if (ld_12 < l_ima_60) return (l_ima_60); if (gi_184 == -1) if (ld_12 > l_ima_60) return (l_ima_60); return (0); } int checkBBWidth(int a_shift_0) { double ld_4 = iBands(NULL, 0, 21, 3, 0, PRICE_CLOSE, MODE_UPPER, a_shift_0) - iBands(NULL, 0, 21, 3, 0, PRICE_CLOSE, MODE_LOWER, a_shift_0); if (ld_4 >= entry_bb_width * Point) return (1); return (0); } int checkPivotEntryStatus(int ai_0, int ai_4) { double ld_24; double ld_40; double ld_48; double ld_64; double ld_8 = getEntryValue(ai_0, ai_4); if (ai_4 == 1) { ld_48 = fetchPivot(ai_0, 4); if (ld_8 <= ld_48) return (0); ld_40 = fetchPivot(ai_0, 0); if (ld_8 >= ld_40) return (0); return (1); } if (ai_4 == -1) { ld_24 = fetchPivot(ai_0, 2); if (ld_8 >= ld_24) return (0); ld_64 = fetchPivot(ai_0, 6); if (ld_8 <= ld_64) return (0); return (1); } return (0); } int checkEmaEntryStatus(int ai_0, int ai_4) { double ld_8 = getEntryValue(ai_0, ai_4); double l_ima_16 = iMA(NULL, 0, 50, 0, MODE_EMA, PRICE_CLOSE, ai_0); if (ai_4 == 1) if (ld_8 > l_ima_16 + pips2money(ema_filter)) return (0); if (ai_4 == -1) if (ld_8 < l_ima_16 - pips2money(ema_filter)) return (0); return (1); } bool checkModoriEntryStatus(int ai_0, int ai_4) { double l_iadx_12; double l_iadx_20; double ld_28; int l_period_8 = 10; if (ai_4 == 0) return (FALSE); if (ai_4 == 1) { l_iadx_12 = iADX(NULL, 0, l_period_8, PRICE_CLOSE, MODE_PLUSDI, ai_0); l_iadx_20 = iADX(NULL, 0, l_period_8, PRICE_CLOSE, MODE_PLUSDI, ai_0 + 1); if (l_iadx_12 > l_iadx_20) { ld_28 = iMA(NULL, 0, 50, 0, MODE_EMA, PRICE_CLOSE, ai_0) + pips2money(ema_filter); if (ld_28 > Low[ai_0] && ld_28 < High[ai_0]) return (TRUE); } } if (ai_4 == -1) { l_iadx_12 = iADX(NULL, 0, l_period_8, PRICE_CLOSE, MODE_MINUSDI, ai_0); l_iadx_20 = iADX(NULL, 0, l_period_8, PRICE_CLOSE, MODE_MINUSDI, ai_0 + 1); if (l_iadx_12 > l_iadx_20) { ld_28 = iMA(NULL, 0, 50, 0, MODE_EMA, PRICE_CLOSE, ai_0) - pips2money(ema_filter); if (ld_28 > Low[ai_0] && ld_28 < High[ai_0]) return (TRUE); } } return (FALSE); } void resetModoriVector(int ai_0) { double ld_4; double l_ima_12; if (gi_184 == 0) { ld_4 = Close[ai_0]; if (gi_208) ld_4 = Bid; else { if (gi_204 == TRUE) ld_4 = Low[ai_0]; else ld_4 = High[ai_0]; } if (gi_204 == TRUE) if (ld_4 < fetchSARLow(ai_0 + 2)) gi_204 = FALSE; if (gi_204 == -1) if (ld_4 > fetchSARHigh(ai_0 + 2)) gi_204 = FALSE; l_ima_12 = iMA(NULL, 0, 50, 0, MODE_EMA, PRICE_CLOSE, ai_0); if (gi_204 == TRUE) if (ld_4 <= l_ima_12) gi_204 = FALSE; if (gi_204 == -1) if (ld_4 >= l_ima_12) gi_204 = FALSE; } } int getVector(int ai_0) { return (checkTF(ai_0)); } double fetchSARHigh(int ai_0) { return (iCustom(NULL, Period(), "TQ_01", 0, ai_0)); } double fetchSARLow(int ai_0) { return (iCustom(NULL, Period(), "TQ_01", 1, ai_0)); } double fetchPivot(int ai_0, int ai_4) { return (iCustom(NULL, Period(), "TQ_04", pivot_start_hour, ai_4, ai_0)); } void doBuy(int ai_0) { gi_184 = 1; if (gi_204 == TRUE) g_ibuf_264[ai_0] = iMA(NULL, 0, 50, 0, MODE_EMA, PRICE_CLOSE, ai_0) + pips2money(ema_filter); else g_ibuf_264[ai_0] = getEntryValue(ai_0, 1); g_ibuf_292[ai_0] = g_ibuf_264[ai_0]; g_ibuf_276[ai_0] = g_ibuf_264[ai_0]; gi_204 = FALSE; if (gi_208) { Alert(getTitle(0, Symbol(), "[BUY]", getNumber(Bid), "")); customSendMailByParam(0, Symbol(), "[BUY]", getNumber(Bid), ""); } } void doSell(int ai_0) { gi_184 = -1; if (gi_204 == -1) g_ibuf_268[ai_0] = iMA(NULL, 0, 50, 0, MODE_EMA, PRICE_CLOSE, ai_0) - pips2money(ema_filter); else g_ibuf_268[ai_0] = getEntryValue(ai_0, -1); g_ibuf_292[ai_0] = g_ibuf_268[ai_0]; g_ibuf_280[ai_0] = g_ibuf_268[ai_0]; gi_204 = FALSE; if (gi_208) { Alert(getTitle(0, Symbol(), "[SELL]", getNumber(Bid), "")); customSendMailByParam(0, Symbol(), "[SELL]", getNumber(Bid), ""); } } void doExit(int ai_0, double ad_4) { string ls_unused_28; string l_dbl2str_36; string ls_44; g_ibuf_272[ai_0] = ad_4; g_ibuf_292[ai_0] = ad_4; if (gi_184 == 1) g_ibuf_276[ai_0] = ad_4; if (gi_184 == -1) g_ibuf_280[ai_0] = ad_4; double ld_12 = getRecentEntryRate(ai_0, gi_184); double ld_20 = gi_184 * (ad_4 - ld_12); ld_20 /= Point; ld_20 = MathCeil(ld_20); if (show_result) createTradeResultLabel(ai_0, ld_20, gi_184); gi_184 = 0; gi_220 = FALSE; gi_224 = FALSE; gi_228 = FALSE; gi_232 = FALSE; gi_236 = FALSE; gi_240 = FALSE; gi_244 = FALSE; gi_248 = FALSE; gi_252 = FALSE; gi_256 = FALSE; gi_204 = FALSE; if (ld_20 >= max_pips) gi_192 = TRUE; if (gi_208 || ai_0 == 1) { l_dbl2str_36 = DoubleToStr(ld_20, 0); if (ld_20 > 0.0) ls_44 = "+" + l_dbl2str_36; else ls_44 = l_dbl2str_36; Alert(getTitle(0, Symbol(), "[" + gs_exit_212 + "]", getNumber(ad_4), ls_44)); customSendMailByParam(0, Symbol(), "[" + gs_exit_212 + "]", getNumber(ad_4), ls_44); } gs_exit_212 = "EXIT"; } void winAlert(double ad_0) { double ld_8; double ld_16 = getRecentEntryRate(0, gi_184); if (gi_184 == 1) ld_8 = ad_0 - ld_16; else ld_8 = ld_16 - ad_0; if (ld_8 >= pips2money(Hit_alert6) && !gi_240) { gi_240 = TRUE; gi_236 = TRUE; gi_232 = TRUE; gi_228 = TRUE; gi_224 = TRUE; gi_220 = TRUE; doWinAlert(Hit_alert6, ad_0); return; } if (ld_8 >= pips2money(Hit_alert5) && !gi_236) { gi_236 = TRUE; gi_232 = TRUE; gi_228 = TRUE; gi_224 = TRUE; gi_220 = TRUE; doWinAlert(Hit_alert5, ad_0); return; } if (ld_8 >= pips2money(Hit_alert4) && !gi_232) { gi_232 = TRUE; gi_228 = TRUE; gi_224 = TRUE; gi_220 = TRUE; doWinAlert(Hit_alert4, ad_0); return; } if (ld_8 >= pips2money(Hit_alert3) && !gi_228) { gi_228 = TRUE; gi_224 = TRUE; gi_220 = TRUE; doWinAlert(Hit_alert3, ad_0); return; } if (ld_8 < pips2money(Hit_alert3) && ld_8 >= pips2money(Hit_alert2) && !gi_224) { gi_224 = TRUE; gi_220 = TRUE; doWinAlert(Hit_alert2, ad_0); return; } if (ld_8 < pips2money(Hit_alert3) && ld_8 < pips2money(Hit_alert2) && ld_8 >= pips2money(Hit_alert1) && !gi_220) { gi_220 = TRUE; doWinAlert(Hit_alert1, ad_0); return; } } void doWinAlert(int ai_0, int ai_unused_4) { string ls_8; if (enable_Hit_alert) { ls_8 = "+" + ai_0; Alert(getTitle(0, Symbol(), "[HIT]", getNumber(Bid), ls_8)); customSendMailByParam(0, Symbol(), "[HIT]", getNumber(Bid), ls_8); } } void pivotAlert(double ad_0) { double ld_8; double ld_16; int li_48; double ld_40 = getRecentEntryRate(0, gi_184); if (gi_184 == 1) li_48 = money2pips(ad_0 - ld_40); else li_48 = ld_40 - ad_0; if (gi_184 == 1) { ld_16 = fetchPivot(0, 0); ld_8 = fetchPivot(0, 1); if (!gi_244) { if (ld_40 >= ld_16) { gi_244 = TRUE; gi_248 = TRUE; } } if (!gi_248) if (ld_40 >= ld_8) gi_248 = TRUE; if (!gi_244 && ad_0 >= ld_16) { gi_244 = TRUE; gi_248 = TRUE; doPivotAlert(li_48, ad_0); return; } if (!(!gi_248 && ad_0 >= ld_8)) return; gi_248 = TRUE; doPivotAlert(li_48, ad_0); return; } double ld_32 = fetchPivot(0, 6); double ld_24 = fetchPivot(0, 5); if (!gi_256) { if (ld_40 <= ld_32) { gi_256 = TRUE; gi_252 = TRUE; } } if (!gi_252) if (ld_40 <= ld_24) gi_252 = TRUE; if (!gi_256 && ad_0 <= ld_32) { gi_256 = TRUE; gi_252 = TRUE; doPivotAlert(li_48, ad_0); return; } if (!gi_252 && ad_0 <= ld_24) { gi_252 = TRUE; doPivotAlert(li_48, ad_0); return; } } void doPivotAlert(int ai_0, int ai_unused_4) { string ls_8; if (enable_Hit_alert) { ls_8 = "+" + ai_0; Alert(getTitle(0, Symbol(), "[PIVOT]", getNumber(Bid), ls_8)); customSendMailByParam(0, Symbol(), "[PIVOT]", getNumber(Bid), ls_8); } } int checkActivate(int ai_0) { double ld_4 = MathCeil(getActivateValue(ai_0)); double ld_12 = MathCeil(iCustom(NULL, Period(), "TQ_pass", 0, ai_0)); if (MathAbs(ld_4 - ld_12) <= 50.0) return (1); return (0); } double getRecentEntryRate(int ai_0, int ai_4) { for (int l_count_8 = 0; l_count_8 < 100; l_count_8++) { if (ai_4 == 1) if (g_ibuf_264[ai_0 + l_count_8] != EMPTY_VALUE) return (g_ibuf_264[ai_0 + l_count_8]); if (ai_4 == -1) if (g_ibuf_268[ai_0 + l_count_8] != EMPTY_VALUE) return (g_ibuf_268[ai_0 + l_count_8]); } return (0.0); } void createTradeResultLabel(int ai_0, double ad_4, int ai_12) { string l_str_concat_16; ad_4 = MathCeil(ad_4); if (ad_4 > 0.0) l_str_concat_16 = StringConcatenate("+", ad_4); else l_str_concat_16 = StringConcatenate("", ad_4); double l_price_24 = High[ai_0] + 5.0 * Point; if (ai_12 == 1) l_price_24 = Low[ai_0] + 5.0 * Point; l_price_24 -= 10 * ai_12 * Point; string l_name_32 = "text_object_" + Time[ai_0]; if (!ObjectCreate(l_name_32, OBJ_TEXT, 0, Time[ai_0], l_price_24)) { Print("Error: can\'t create text_object! code #", GetLastError()); return; } ObjectSetText(l_name_32, l_str_concat_16, 25, "Times New Roman", result_color); } int deinit() { ObjectsDeleteAll(0, OBJ_TEXT); return (0); } double getActivateValue(int ai_0) { return (iMA(NULL, 0, 8, 0, MODE_SMA, PRICE_CLOSE, ai_0) * gi_260); } double pips2money(int ai_0) { return (ai_0 * Point); } int money2pips(double ad_0) { return (MathCeil(ad_0 / Point)); } string getNumber(double ad_0) { if (ad_0 > 10.0) return (DoubleToStr(ad_0, 2)); return (DoubleToStr(ad_0, 4)); } string getTime() { string ls_12; string ls_20; string ls_28; int l_hour_0 = TimeHour(TimeLocal()); int l_minute_4 = TimeMinute(TimeLocal()); int l_second_8 = TimeSeconds(TimeLocal()); if (l_hour_0 < 10) ls_12 = "0" + l_hour_0; else ls_12 = "" + l_hour_0; if (l_minute_4 < 10) ls_20 = "0" + l_minute_4; else ls_20 = "" + l_minute_4; if (l_second_8 < 10) ls_28 = "0" + l_second_8; else ls_28 = "" + l_second_8; return (ls_12 + ":" + ls_20 + ":" + ls_28); } int checkTime(int ai_0) { int l_hour_4 = TimeHour(Time[ai_0]); if (starttime == endtime) gi_192 = FALSE; if (starttime >= endtime) { if (endtime <= l_hour_4 && l_hour_4 < starttime) { gi_192 = FALSE; return (0); } return (1); } if (starttime < endtime) { if (starttime <= l_hour_4 && l_hour_4 < endtime) return (1); gi_192 = FALSE; return (0); } return (0); } int beforeLoop(int ai_0) { gi_188 = getVector(ai_0); if (StringFind(Symbol(), "USD") == -1 || StringFind(Symbol(), "JPY") == -1) return (3); if (checkExpires() == 0) return (3); if (ai_0 == 0 && Volume[0] == 1.0) { gi_196 = FALSE; gi_200 = FALSE; } if (ai_0 == 0 || (ai_0 == 1 && Volume[0] == 1.0)) gi_208 = TRUE; else gi_208 = FALSE; if (checkActivate(1) == 0) return (3); if (!checkTime(ai_0) && gi_184 != 1 && gi_184 != -1) return (2); if (gi_192) return (2); return (1); } void preAlert(string as_0, string as_8, string as_16, string as_24) { if (gi_208) { g_ibuf_288[0] = Low[0] - (Ask - Bid); if (enable_pre_signal == FALSE || gi_196) return; Alert(getTitle(1, as_0, as_8, as_16, as_24)); customSendMailByParam(1, as_0, as_8, as_16, as_24); gi_196 = TRUE; } } void preExitAlert(string as_0, string as_8, string as_16, string as_24) { if (gi_208) { g_ibuf_288[0] = Low[0] - (Ask - Bid); if (enable_pre_signal == FALSE || gi_200) return; Alert(getTitle(1, as_0, as_8, as_16, as_24)); customSendMailByParam(1, as_0, as_8, as_16, as_24); gi_200 = TRUE; } } void customSendMailByParam(bool ai_0, string as_4, string as_12, string as_20, string as_28) { string ls_36 = getTitle(ai_0, as_4, as_12, as_20, as_28); string ls_44 = ""; if (ai_0) as_12 = "[!!]" + as_12; ls_44 = ls_44 + "currency: " + as_4 + "\r\n"; ls_44 = ls_44 + "action: " + as_12 + "\r\n"; ls_44 = ls_44 + "rate: " + as_20 + "\r\n"; ls_44 = ls_44 + "pips: " + as_28 + "\r\n"; ls_44 = ls_44 + "date: " + getTime(); customSendMail(ls_36, ls_44); } void customSendMail(string as_0, string as_8) { if (enable_send_mail) SendMail(as_0, as_8); } string getTitle(bool ai_0, string as_4, string as_12, string as_20, string as_28) { string ls_ret_36 = ""; if (ai_0) ls_ret_36 = "[!!] "; else ls_ret_36 = ""; if (as_28 == "") ls_ret_36 = ls_ret_36 + as_4 + " " + as_12 + " " + as_20 + " - " + getTime(); else ls_ret_36 = ls_ret_36 + as_4 + " " + as_12 + " " + as_20 + "(" + as_28 + ")" + " - " + getTime(); return (ls_ret_36); } int checkExpires() { int l_year_0 = TimeYear(TimeLocal()); int l_month_4 = TimeMonth(TimeLocal()); int l_day_8 = TimeDay(TimeLocal()); int li_12 = 10000 * l_year_0 + 100 * l_month_4 + l_day_8; if (li_12 > gi_76) return (0); return (1); }