#property copyright "Copyright © 2008, Limited Maintenance Trading" #property link "http://www.lmt-forex-forula.com" extern bool EnableAlertPopup = TRUE; extern bool EnableAlertEmail = FALSE; extern bool EnableAlertSound = TRUE; extern string AlertSoundFilename = "alert.wav"; extern bool DarkChartBackground = TRUE; extern int StatusInfoSpacing = 15; string gs_104 = ""; int gi_112 = 1; string gs_unused_116 = "D1"; int g_period_124 = 100; double gd_128 = 0.75; int gi_136 = 1; double gd_140 = 0.5; int gi_148 = 1; int gi_152 = 3; string gs_unused_156 = "lmt"; string gs_trigger_164 = "trigger"; string gs_trend_172 = "trend"; int gi_180 = 0; double gd_184 = 0.0; double gd_192 = 0.0; int gi_200 = 0; int g_datetime_204 = 0; string gs_208; string get_timeframe_code(int ai_0) { if (ai_0 == 1) return ("-M1"); if (ai_0 == 5) return ("-M5"); if (ai_0 == 15) return ("-M15"); if (ai_0 == 30) return ("-M30"); if (ai_0 == 60) return ("-H1"); if (ai_0 == 240) return ("-H4"); if (ai_0 == 1440) return ("-D1"); if (ai_0 == 10080) return ("-W1"); if (ai_0 == 43200) return ("-MN1"); return (-1); } int get_timeframe_value(string as_0) { string ls_8 = StringTrimLeft(StringTrimRight(as_0)); if (ls_8 == "M1") return (1); if (ls_8 == "M5") return (5); if (ls_8 == "M15") return (15); if (ls_8 == "M30") return (30); if (ls_8 == "H1") return (60); if (ls_8 == "H4") return (240); if (ls_8 == "D1") return (1440); if (ls_8 == "W1") return (10080); if (ls_8 == "MN1") return (43200); return (-1); } int get_higher_timeframe(int ai_0) { string ls_4 = StringTrimLeft(StringTrimRight(gs_104)); if (ls_4 != "") return (get_timeframe_value(ls_4)); if (ai_0 == 1) return (5); if (ai_0 == 5) return (15); if (ai_0 == 15) return (30); if (ai_0 == 30) return (60); if (ai_0 == 60) return (240); if (ai_0 == 240) return (1440); if (ai_0 == 1440) return (10080); if (ai_0 == 10080) return (43200); return (-1); } int init() { g_datetime_204 = TimeCurrent(); return (0); } int deinit() { ObjectDelete("L.M.T.trends"); ObjectDelete("L.M.T.arrow"); ObjectDelete("L.M.T.stoploss"); ObjectDelete("L.M.T.firsttarget"); ObjectDelete("L.M.T.alert"); ObjectDelete("L.M.T.last"); return (0); } int validate_display_monitor() { color l_color_8; color l_color_12; color l_color_16; color l_color_20; int l_x_0 = 5; int l_y_4 = 25; if (DarkChartBackground) { l_color_8 = LightGreen; l_color_12 = Red; l_color_16 = LightBlue; l_color_20 = LightBlue; } else { l_color_8 = Green; l_color_12 = Red; l_color_16 = Black; l_color_20 = Black; } if (ObjectFind("L.M.T.trends") == -1) { if (ObjectCreate("L.M.T.trends", OBJ_LABEL, 0, 0, 0)) { ObjectSet("L.M.T.trends", OBJPROP_XDISTANCE, l_x_0); ObjectSet("L.M.T.trends", OBJPROP_YDISTANCE, l_y_4 - 2); } } Print("Trend Direction: ", gi_180); string ls_24 = "Trend Direction = "; string ls_unused_32 = ""; if (gi_180 == 1) ObjectSetText("L.M.T.trends", ls_24 + "Up", 11, "Arial Black", l_color_8); else { if (gi_180 == 2) ObjectSetText("L.M.T.trends", ls_24 + "Down", 11, "Arial Black", l_color_12); else if (gi_180 == 0) ObjectSetText("L.M.T.trends", ls_24 + "None", 11, "Arial Black", l_color_16); } l_y_4 += StatusInfoSpacing; if (ObjectFind("L.M.T.stoploss") == -1) { if (ObjectCreate("L.M.T.stoploss", OBJ_LABEL, 0, 0, 0)) { ObjectSet("L.M.T.stoploss", OBJPROP_XDISTANCE, l_x_0); ObjectSet("L.M.T.stoploss", OBJPROP_YDISTANCE, l_y_4); } } string l_str_concat_40 = StringConcatenate("Initial Stoploss = ", DoubleToStr(gd_184 / Point, 0), " pips"); ObjectSetText("L.M.T.stoploss", l_str_concat_40, 11, "Arial Black", l_color_20); l_y_4 += StatusInfoSpacing; if (ObjectFind("L.M.T.firsttarget") == -1) { if (ObjectCreate("L.M.T.firsttarget", OBJ_LABEL, 0, 0, 0)) { ObjectSet("L.M.T.firsttarget", OBJPROP_XDISTANCE, l_x_0); ObjectSet("L.M.T.firsttarget", OBJPROP_YDISTANCE, l_y_4); } } string l_str_concat_48 = StringConcatenate("Initial Target = ", DoubleToStr(gd_192 / Point, 0), " pips"); ObjectSetText("L.M.T.firsttarget", l_str_concat_48, 11, "Arial Black", l_color_20); l_y_4 += StatusInfoSpacing; if (ObjectFind("L.M.T.alert") == -1) { if (ObjectCreate("L.M.T.alert", OBJ_LABEL, 0, 0, 0)) { ObjectSet("L.M.T.alert", OBJPROP_XDISTANCE, l_x_0); ObjectSet("L.M.T.alert", OBJPROP_YDISTANCE, l_y_4); } } string l_text_56 = "Candle Close = " + TimeToStr(60 * Period() - (TimeCurrent() - Time[0]), TIME_SECONDS); ObjectSetText("L.M.T.alert", l_text_56, 11, "Arial Black", l_color_20); ObjectsRedraw(); return (0); } int start() { int li_52; double l_icustom_64; string ls_76; int l_timeframe_0 = Period(); int li_4 = get_higher_timeframe(l_timeframe_0); int li_8 = gi_200; if (li_4 == -1) { Print("[", "L.M.T", "] - ERROR: Trends highstoploss_atr_timeframeer timeframe is error"); return (0); } double l_icustom_12 = iCustom(Symbol(), l_timeframe_0, gs_trend_172, 0, gi_112); double l_icustom_20 = iCustom(Symbol(), l_timeframe_0, gs_trend_172, 1, gi_112); if (l_icustom_12 == EMPTY_VALUE) gi_180 = 2; else if (l_icustom_20 == EMPTY_VALUE) gi_180 = 1; gd_184 = iATR(Symbol(), get_timeframe_value(l_timeframe_0), g_period_124, gi_136) * gd_128; gd_192 = gd_184 * gd_140; double l_icustom_28 = iCustom(Symbol(), 0, gs_trigger_164, 0, gi_148); double l_icustom_36 = iCustom(Symbol(), 0, gs_trigger_164, 1, gi_148); double l_icustom_44 = iCustom(Symbol(), 0, gs_trigger_164, 2, gi_148); int li_56 = 0; if (l_icustom_28 == 0.0) { li_52 = 2; li_56 = 1; } else { if (l_icustom_36 == 0.0) { li_52 = 1; li_56 = 0; } } gi_200 = 1; if (gi_180 == li_52) { for (int li_60 = gi_148 + 1; li_60 <= gi_148 + gi_152; li_60++) { l_icustom_64 = iCustom(Symbol(), l_timeframe_0, gs_trigger_164, li_56, li_60); if (l_icustom_64 != 0.0) { gi_200 = 2; break; } } } else gi_200 = 2; validate_display_monitor(); bool li_72 = FALSE; if (g_datetime_204 < Time[0] && li_8 != 1) { g_datetime_204 = TimeCurrent(); if (gi_200 == 1) li_72 = TRUE; } if (li_72) { Print("[", "L.M.T", "] : Alert On ", TimeToStr(TimeCurrent())); gs_208 = "Last LMT Signal on " + Symbol() + get_timeframe_code(Period()) + " at " + TimeToStr(TimeCurrent(), TIME_MINUTES) + " on " + TimeToStr(TimeCurrent(), TIME_DATE); if (ObjectFind("L.M.T.arrow") == -1) ObjectCreate("L.M.T.arrow", OBJ_VLINE, 0, 0, 0); ObjectSet("L.M.T.arrow", OBJPROP_TIME1, Time[1]); if (li_52 == 1) ObjectSet("L.M.T.arrow", OBJPROP_COLOR, LightGreen); else if (gi_180 == 2) ObjectSet("L.M.T.arrow", OBJPROP_COLOR, Red); if (EnableAlertPopup) Alert("LMT Signal on ", Symbol(), get_timeframe_code(Period())); if (EnableAlertEmail) { SendMail("LMT Signal on " + Symbol() + get_timeframe_code(Period()), "LMT Signal on triggered at " + TimeToStr(TimeCurrent(), TIME_MINUTES) + " chart time (" + TimeToStr(TimeLocal(), TIME_MINUTES) + " local time) on " + TimeToStr(TimeCurrent(), TIME_DATE)); } if (EnableAlertSound) { ls_76 = StringTrimLeft(StringTrimRight(AlertSoundFilename)); if (ls_76 == "") ls_76 = "alert.wav"; PlaySound(ls_76); } } Comment(gs_208); return (0); }