#property copyright "Copyright © 2009, fxsupertools.com" #property link "http://fxsupertools.com/" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Black #import "wininet.dll" int InternetAttemptConnect(int a0); int InternetOpenA(string a0, int a1, string a2, string a3, int a4); int InternetOpenUrlA(int a0, string a1, string a2, int a3, int a4, int a5); int InternetReadFile(int a0, int& a1[], int a2, int& a3[]); int InternetCloseHandle(int a0); #import extern bool lines = TRUE; extern bool texts = TRUE; bool gi_84 = TRUE; extern int total_in_list = 10; extern bool high = TRUE; extern bool medium = TRUE; extern bool low = TRUE; extern int update = 15; extern bool auto = TRUE; extern bool eur = TRUE; extern bool usd = TRUE; extern bool jpy = TRUE; extern bool gbp = TRUE; extern bool chf = TRUE; extern bool cad = TRUE; extern bool aud = TRUE; extern bool nzd = TRUE; extern color high_color = Blue; extern color medium_color = Sienna; extern color low_color = DarkSlateGray; bool gi_156 = TRUE; extern int server_timezone = 2; extern int show_timezone = 9; extern bool alerts = FALSE; extern int alert_before = 5; extern int alert_every = 30; int gi_180 = 0; string gsa_184[1000][10]; int gi_188 = 0; int gi_192 = 0; int g_datetime_196 = 0; string gsa_200[1000][2]; int gi_204 = 0; int init() { string ls_0; int l_file_8; string ls_12; if (auto) { ls_0 = Symbol(); if (StringFind(ls_0, "EUR") != -1) eur = TRUE; else eur = FALSE; if (StringFind(ls_0, "USD") != -1) usd = TRUE; else usd = FALSE; if (StringFind(ls_0, "JPY") != -1) jpy = TRUE; else jpy = FALSE; if (StringFind(ls_0, "GBP") != -1) gbp = TRUE; else gbp = FALSE; if (StringFind(ls_0, "CHF") != -1) chf = TRUE; else chf = FALSE; if (StringFind(ls_0, "CAD") != -1) cad = TRUE; else cad = FALSE; if (StringFind(ls_0, "AUD") != -1) aud = TRUE; else aud = FALSE; if (StringFind(ls_0, "NZD") != -1) nzd = TRUE; else nzd = FALSE; } if (gi_156) { l_file_8 = FileOpen("translate.txt", FILE_READ); if (l_file_8 > 0) { for (int l_index_20 = 0; !FileIsEnding(l_file_8); l_index_20++) { ls_12 = FileReadString(l_file_8); if (ls_12 == "") break; gsa_200[l_index_20][0] = ls_12; gsa_200[l_index_20][1] = FileReadString(l_file_8); if (gsa_200[l_index_20][1] == "") gsa_200[l_index_20][1] = gsa_200[l_index_20][0]; } gi_204 = l_index_20; FileClose(l_file_8); } } return (0); } int deinit() { for (int l_count_0 = 0; l_count_0 < gi_180; l_count_0++) { ObjectDelete("News Line " + l_count_0); ObjectDelete("News Text " + l_count_0); } return (0); } int start() { string ls_12; int li_20; string lsa_24[1000]; string lsa_28[10]; string lsa_32[3]; string lsa_36[2]; int li_40; bool li_44; int l_str2time_48; int l_str2time_52; color l_color_56; string ls_60; int li_68; string ls_72; string ls_0 = "2009.9.30"; int l_str2time_8 = StrToTime(ls_0); if (TimeCurrent() >= l_str2time_8) { Alert("You Need Update"); return (0); } string ls_80 = ""; if (!eur) ls_80 = ls_80 + "EUR|"; if (!usd) ls_80 = ls_80 + "USD|"; if (!jpy) ls_80 = ls_80 + "JPY|"; if (!gbp) ls_80 = ls_80 + "GBP|"; if (!chf) ls_80 = ls_80 + "CHF|"; if (!cad) ls_80 = ls_80 + "CAD|"; if (!aud) ls_80 = ls_80 + "AUD|"; if (!nzd) ls_80 = ls_80 + "NZD|"; string ls_88 = ""; if (!high) ls_88 = ls_88 + "High|"; if (!medium) ls_88 = ls_88 + "Medium|"; if (!low) ls_88 = ls_88 + "Low|"; int l_datetime_96 = TimeCurrent(); if (l_datetime_96 >= gi_188 + 60 * update) { for (int l_index_100 = 0; l_index_100 < gi_180; l_index_100++) { ObjectDelete("News Line " + l_index_100); ObjectDelete("News Text " + l_index_100); } gi_188 = l_datetime_96; ls_12 = ReadWebPage("http://www.dailyfx.com/calendar/Dailyfx_Global_Economic_Calendar.csv?direction=none&collector=allInFolderDateDesc&view=week&timezone=GMT¤cyFilter=" + ls_80 + "&importanceFilter=" + ls_88 + "&time=" + l_datetime_96); if (ls_12 == "") return (0); li_20 = StringFind(ls_12, "\r\n\r\n\r\n"); ls_12 = StringTrimRight(StringTrimLeft(StringSubstr(ls_12, li_20 + 6))); gi_180 = Explode(ls_12, "\r\n\r\n\r\n", lsa_24); for (l_index_100 = 0; l_index_100 < gi_180; l_index_100++) { Explode(lsa_24[l_index_100], ",", lsa_28); for (int l_index_104 = 0; l_index_104 < 10; l_index_104++) gsa_184[l_index_100][l_index_104] = lsa_28[l_index_104]; Explode(gsa_184[l_index_100][0], " ", lsa_32); li_40 = 0; if (lsa_32[1] == "Jan") li_40 = 1; else { if (lsa_32[1] == "Feb") li_40 = 2; else { if (lsa_32[1] == "Mar") li_40 = 3; else { if (lsa_32[1] == "Apr") li_40 = 4; else { if (lsa_32[1] == "May") li_40 = 5; else { if (lsa_32[1] == "Jun") li_40 = 6; else { if (lsa_32[1] == "Jul") li_40 = 7; else { if (lsa_32[1] == "Aug") li_40 = 8; else { if (lsa_32[1] == "Sep") li_40 = 9; else { if (lsa_32[1] == "Oct") li_40 = 10; else { if (lsa_32[1] == "Nov") li_40 = 11; else if (lsa_32[1] == "Dec") li_40 = 12; } } } } } } } } } } gsa_184[l_index_100][0] = Year() + "." + li_40 + "." + lsa_32[2]; Explode(gsa_184[l_index_100][1], " ", lsa_32); li_44 = lsa_32[1] == "PM"; Explode(lsa_32[0], ":", lsa_36); lsa_36[0] = StrToInteger(lsa_36[0]) % 12; if (li_44) lsa_36[0] = StrToInteger(lsa_36[0]) + 12; gsa_184[l_index_100][1] = lsa_36[0] + ":" + lsa_36[1]; l_str2time_48 = StrToTime(gsa_184[l_index_100][0] + " " + gsa_184[l_index_100][1]); gsa_184[l_index_100][0] = TimeToStr(l_str2time_48 + 60 * (60 * server_timezone), TIME_DATE); gsa_184[l_index_100][1] = TimeToStr(l_str2time_48 + 60 * (60 * server_timezone), TIME_MINUTES); gsa_184[l_index_100][9] = TimeToStr(l_str2time_48 + 60 * (60 * show_timezone), TIME_MINUTES); if (gi_156) { for (l_index_104 = 0; l_index_104 < gi_204; l_index_104++) { li_20 = StringFind(gsa_184[l_index_100][4], gsa_200[l_index_104][0]); if (li_20 != -1) gsa_184[l_index_100][4] = StringSubstr(gsa_184[l_index_100][4], 0, li_20) + gsa_200[l_index_104][1] + StringSubstr(gsa_184[l_index_100][4], li_20 + StringLen(gsa_200[l_index_104][0])); } } } l_str2time_52 = 0; for (l_index_100 = 0; l_index_100 < gi_180; l_index_100++) { if (StrToTime(gsa_184[l_index_100][0] + " " + gsa_184[l_index_100][1]) != l_str2time_52) { l_str2time_52 = StrToTime(gsa_184[l_index_100][0] + " " + gsa_184[l_index_100][1]); if (gsa_184[l_index_100][5] == "Low") l_color_56 = low_color; else { if (gsa_184[l_index_100][5] == "Medium") l_color_56 = medium_color; else if (gsa_184[l_index_100][5] == "High") l_color_56 = high_color; } ls_60 = ""; if (gsa_184[l_index_100][8] != "" || gsa_184[l_index_100][7] != "") ls_60 = "[" + gsa_184[l_index_100][8] + ", " + gsa_184[l_index_100][7] + "]"; if (gsa_184[l_index_100][6] != "") ls_60 = ls_60 + " " + gsa_184[l_index_100][6]; if (lines) { ObjectCreate("News Line " + l_index_100, OBJ_VLINE, 0, l_str2time_52, 0); ObjectSet("News Line " + l_index_100, OBJPROP_COLOR, l_color_56); ObjectSet("News Line " + l_index_100, OBJPROP_STYLE, STYLE_DASHDOTDOT); ObjectSet("News Line " + l_index_100, OBJPROP_BACK, TRUE); ObjectSetText("News Line " + l_index_100, gsa_184[l_index_100][9] + " " + gsa_184[l_index_100][4] + " " + ls_60, 8); } if (texts) { ObjectCreate("News Text " + l_index_100, OBJ_TEXT, 0, l_str2time_52, WindowPriceMin() + 0.8 * (WindowPriceMax() - WindowPriceMin())); ObjectSet("News Text " + l_index_100, OBJPROP_COLOR, l_color_56); ObjectSet("News Text " + l_index_100, OBJPROP_ANGLE, 90); ObjectSetText("News Text " + l_index_100, gsa_184[l_index_100][9] + " " + gsa_184[l_index_100][4] + " " + ls_60, 8); } } } for (l_index_100 = 0; l_index_100 < gi_180; l_index_100++) if (StrToTime(gsa_184[l_index_100][0] + " " + gsa_184[l_index_100][1]) > l_datetime_96) break; gi_192 = l_index_100; g_datetime_196 = 0; if (gi_84) { li_68 = 0; if (gi_192 >= 5) li_68 = gi_192 - 5; ls_72 = "_____ Past news ______________________\n"; for (l_index_100 = li_68; l_index_100 < li_68 + total_in_list && l_index_100 < gi_180; l_index_100++) { ls_60 = ""; if (gsa_184[l_index_100][8] != "" || gsa_184[l_index_100][7] != "") ls_60 = "[" + gsa_184[l_index_100][8] + ", " + gsa_184[l_index_100][7] + "]"; if (gsa_184[l_index_100][6] != "") ls_60 = ls_60 + " " + gsa_184[l_index_100][6]; ls_72 = ls_72 + gsa_184[l_index_100][9] + " " + StringSubstr(gsa_184[l_index_100][5], 0, 1) + " " + gsa_184[l_index_100][4] + " " + ls_60 + "\n"; if (l_index_100 == gi_192 - 1) ls_72 = ls_72 + "_____ Future News ________________________\n"; } Comment(ls_72); } } int l_str2time_108 = StrToTime(gsa_184[gi_192][0] + " " + gsa_184[gi_192][1]); if (l_datetime_96 >= l_str2time_108) { gi_188 = l_datetime_96 - 60 * update + 60; for (l_index_100 = 0; l_index_100 < gi_180; l_index_100++) if (StrToTime(gsa_184[l_index_100][0] + " " + gsa_184[l_index_100][1]) > l_datetime_96) break; gi_192 = l_index_100; g_datetime_196 = 0; if (gi_84) { li_68 = 0; if (gi_192 >= 5) li_68 = gi_192 - 5; ls_72 = ""; for (l_index_100 = li_68; l_index_100 < li_68 + 10 && l_index_100 < gi_180; l_index_100++) { ls_60 = ""; if (gsa_184[l_index_100][8] != "" || gsa_184[l_index_100][7] != "") ls_60 = "[" + gsa_184[l_index_100][8] + ", " + gsa_184[l_index_100][7] + "]"; if (gsa_184[l_index_100][6] != "") ls_60 = ls_60 + " " + gsa_184[l_index_100][6]; ls_72 = ls_72 + gsa_184[l_index_100][9] + " " + StringSubstr(gsa_184[l_index_100][5], 0, 1) + " " + gsa_184[l_index_100][4] + " " + ls_60 + "\n"; } Comment(ls_72); } } l_str2time_108 = StrToTime(gsa_184[gi_192][0] + " " + gsa_184[gi_192][1]); if (l_datetime_96 >= l_str2time_108 - 60 * alert_before) { if (l_datetime_96 >= g_datetime_196 + alert_every) { if (alerts) PlaySound("alert.wav"); Print("The next piece of news will be released in " + ((l_str2time_108 - l_datetime_96 - (l_str2time_108 - l_datetime_96) % 60) / 60) + " minute(s) " + ((l_str2time_108 - l_datetime_96) % 60) + " second(s)."); g_datetime_196 = l_datetime_96; } } return (0); } int Explode(string as_0, string as_8, string &asa_16[1000]) { int l_index_20 = 0; int li_24 = StringFind(as_0, as_8); while (li_24 != -1) { if (li_24 == 0) asa_16[l_index_20] = ""; else asa_16[l_index_20] = StringSubstr(as_0, 0, li_24); l_index_20++; as_0 = StringSubstr(as_0, li_24 + StringLen(as_8)); li_24 = StringFind(as_0, as_8); if (li_24 == -1 || as_0 == "") break; } asa_16[l_index_20] = as_0; return (l_index_20 + 1); } string ReadWebPage(string as_0) { int lia_8[256]; int lia_12[1]; int li_16; string ls_20; if (!IsDllsAllowed()) { Alert("You need to allow DLL usage in Settings"); return (""); } int li_28 = InternetAttemptConnect(0); if (li_28 != 0) { Alert("Error calling InternetAttemptConnect()"); return (""); } int li_32 = InternetOpenA("Microsoft Internet Explorer", 0, "", "", 0); if (li_32 <= 0) { Alert("Error calling InternetOpenA()"); return (""); } int li_36 = InternetOpenUrlA(li_32, as_0, "", 0, 0, 0); if (li_36 <= 0) { Alert("Error calling InternetOpenUrlA()"); InternetCloseHandle(li_32); return (-1); } string ls_ret_40 = ""; while (!IsStopped()) { for (int l_index_48 = 0; l_index_48 < 256; l_index_48++) lia_8[l_index_48] = 0; li_16 = InternetReadFile(li_36, lia_8, 1024, lia_12); if (lia_12[0] == 0) break; ls_20 = ""; for (l_index_48 = 0; l_index_48 < 256; l_index_48++) { ls_20 = ls_20 + CharToStr(lia_8[l_index_48] & 255); if (StringLen(ls_20) == lia_12[0]) break; ls_20 = ls_20 + CharToStr(lia_8[l_index_48] >> 8 & 255); if (StringLen(ls_20) == lia_12[0]) break; ls_20 = ls_20 + CharToStr(lia_8[l_index_48] >> 16 & 255); if (StringLen(ls_20) == lia_12[0]) break; ls_20 = ls_20 + CharToStr(lia_8[l_index_48] >> 24 & 255); } ls_ret_40 = ls_ret_40 + ls_20; Sleep(1); } if (ls_ret_40 == "") Alert("No loaded data"); InternetCloseHandle(li_32); return (ls_ret_40); }