#property copyright "Copyright © 2007, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 White #import "FXI.dll" string gGrab(string a0, string a1); #import "fxi_upd.dll" string returnReg(string a0, string a1); void runUpdater(); #import int g_file_76; bool gi_80 = FALSE; extern string Copyright = "Copyright Sharptrade Partners, LLC - 2009"; double g_ibuf_92[]; double gd_96 = 1.01; bool gi_104 = FALSE; bool gi_108 = TRUE; int gi_112 = -1; double g_ibuf_116[]; double gda_120[]; double gda_unused_124[]; double gda_unused_128[]; double gda_unused_132[]; double gda_unused_136[]; int g_time_140 = 0; double gd_144; int loginStart() { int l_str2int_0; bool li_4; int li_8; g_file_76 = FileOpen("fxi_t.bin", FILE_CSV|FILE_READ); if (g_file_76 < 1) li_4 = FALSE; else { l_str2int_0 = StrToInteger(FileReadString(g_file_76)); FileClose(g_file_76); li_4 = TRUE; } if (TimeLocal() - l_str2int_0 >= 604800 || li_4 == FALSE) { li_8 = doLogin(); switch (li_8) { case 0: Alert("Logged in"); g_file_76 = FileOpen("fxi_t.bin", FILE_WRITE, 8); if (g_file_76 < 1) { Print("Cannot open password cache!"); return (0); } FileWrite(g_file_76, TimeLocal()); FileClose(g_file_76); checkVersions(); break; case 1: Alert("Invalid key provided!! Please re-install the software with the correct key."); gi_80 = TRUE; break; case 4: Alert("Your account has been disabled! Please contact support@fximpact.com"); gi_80 = TRUE; break; case 5: Alert("Server error!! Please make sure you are connected to the Internet and try again."); gi_80 = TRUE; break; case 6: Alert("No key found in your registry (bad install)! Please re-install the product."); gi_80 = TRUE; } } return (0); } int doLogin() { string ls_0 = returnReg("Software\\FXI\\Triad", "fname"); string ls_8 = returnReg("Software\\FXI\\Triad", "lname"); string ls_16 = returnReg("Software\\FXI\\Triad", "email"); string ls_24 = returnReg("Software\\FXI\\Triad", "key"); if (ls_24 == "") return (6); string ls_32 = "fname=" + ls_0; ls_32 = ls_32 + "&lname=" + ls_8; ls_32 = ls_32 + "&email=" + ls_16; ls_32 = ls_32 + "&key=" + ls_24; string ls_40 = gGrab("http://www.foreximpact.com/triad/t_login.php", ls_32); if (StringSubstr(ls_40, 0, 1) == "0") return (0); if (StringSubstr(ls_40, 0, 1) == "1") return (1); if (StringSubstr(ls_40, 0, 1) == "4") return (4); return (5); } void checkVersions() { string lsa_28[50]; int li_36; int li_40; string ls_48; string ls_56; string ls_64; string ls_0 = "http://www.foreximpact.com/triad/versions.txt"; string ls_8 = gGrab(ls_0, ""); int l_str2dbl_24 = -1; int l_file_32 = FileOpen("fxi_versions.txt", FILE_CSV|FILE_WRITE, ","); if (l_file_32 < 1) Print("Can NOT load the versions.txt file! Not updating indicators..."); FileWrite(l_file_32, ls_8); FileClose(l_file_32); l_file_32 = FileOpen("fxi_versions.txt", FILE_CSV|FILE_READ, ","); if (l_file_32 < 1) Print("Can NOT load the versions.txt file! Not updating indicators..."); string ls_16 = FileReadString(l_file_32); l_str2dbl_24 = StrToDouble(ls_16); int l_index_44 = 0; if (l_str2dbl_24 > 0) { for (int l_count_72 = 0; l_count_72 < l_str2dbl_24; l_count_72++) { ls_16 = FileReadString(l_file_32); li_40 = StringFind(ls_16, ".", 0); ls_48 = StringSubstr(ls_16, 0, li_40); li_36 = StringFind(ls_16, " ", 0); ls_56 = StringSubstr(ls_16, li_36 + 1, StringLen(ls_16) - (li_36 + 1)); if (!checkIndyVersion(ls_48, ls_56)) { ls_64 = StringSubstr(ls_16, 0, li_36); lsa_28[l_index_44] = ls_64; l_index_44++; } } FileClose(l_file_32); Print("Number of indicators to update -- ", l_index_44); if (l_index_44 > 0) { l_file_32 = FileOpen("fxi_update.txt", FILE_CSV|FILE_WRITE, ","); if (l_file_32 < 1) Print("Can not open fxi_update.txt for writing! Exiting..."); else { FileWrite(l_file_32, l_index_44); for (int l_index_76 = 0; l_index_76 < l_index_44; l_index_76++) { Print("Updating Indicator -- ", lsa_28[l_index_76]); FileWrite(l_file_32, lsa_28[l_index_76]); } FileClose(l_file_32); runUpdater(); } } } else FileClose(l_file_32); } bool checkIndyVersion(string as_0, string as_8) { Print("Checking indy " + as_0 + " with version " + as_8); double l_str2dbl_16 = StrToDouble(as_8); double l_icustom_24 = iCustom(Symbol(), 0, as_0, "verCheckInfo", 0, 0); Print("Returned version : ", l_icustom_24); if (l_icustom_24 > 0.0 && l_icustom_24 < l_str2dbl_16) return (FALSE); if (l_icustom_24 == 0.0) return (FALSE); return (TRUE); } int init() { if (checkVerInfo()) return (0); IndicatorBuffers(1); SetIndexBuffer(0, g_ibuf_116); SetIndexStyle(0, DRAW_LINE); SetIndexLabel(0, "FXI Ratchet"); loginStart(); return (0); } int deinit() { return (0); } int start() { if (Copyright == "verCheckInfo") { g_ibuf_92[0] = gd_96; return (0); } if (gi_80) return (0); int l_ind_counted_0 = IndicatorCounted(); int li_4 = Bars - l_ind_counted_0 - 1; if (li_4 > 0) li_4--; if (li_4 < 0) return (-1); for (int li_8 = li_4; li_8 >= 0; li_8--) { if (gi_104) gd_144 = Close[li_8]; else gd_144 = Open[li_8]; if (gi_112 == -1) { if (Open[li_8] > Close[li_8]) { gi_112 = 2; gda_120[li_8] = gi_112; g_time_140 = Time[li_8]; g_ibuf_116[li_8] = High[li_8 + 1]; } else { gi_112 = 1; gda_120[li_8] = gi_112; g_time_140 = Time[li_8]; g_ibuf_116[li_8] = Low[li_8 + 1]; } } if (gi_112 == 1 && Time[li_8] > g_time_140) { gda_120[li_8] = gda_120[li_8 + 1]; if (gi_108) { if (Open[li_8 + 1] < Close[li_8 + 1]) g_ibuf_116[li_8] = g_ibuf_116[li_8 + 1] + (Close[li_8 + 1] - (Open[li_8 + 1])); else g_ibuf_116[li_8] = g_ibuf_116[li_8 + 1]; } else g_ibuf_116[li_8] = g_ibuf_116[li_8 + 1] + MathAbs(Close[li_8 + 1] - (Open[li_8 + 1])); if (gd_144 < g_ibuf_116[li_8]) { g_time_140 = Time[li_8]; g_ibuf_116[li_8] = High[li_8 + 1]; gi_112 = 2; gda_120[li_8] = gi_112; } } if (gi_112 == 2 && Time[li_8] > g_time_140) { gda_120[li_8] = gda_120[li_8 + 1]; if (gi_108) { if (Open[li_8 + 1] > Close[li_8 + 1]) g_ibuf_116[li_8] = g_ibuf_116[li_8 + 1] - (Open[li_8 + 1] - (Close[li_8 + 1])); else g_ibuf_116[li_8] = g_ibuf_116[li_8 + 1]; } else g_ibuf_116[li_8] = g_ibuf_116[li_8 + 1] - MathAbs(Open[li_8 + 1] - (Close[li_8 + 1])); if (gd_144 > g_ibuf_116[li_8]) { gi_112 = 1; gda_120[li_8] = gi_112; g_time_140 = Time[li_8]; g_ibuf_116[li_8] = Low[li_8 + 1]; } } } return (0); } bool checkVerInfo() { if (Copyright == "verCheckInfo") { IndicatorBuffers(1); SetIndexBuffer(0, g_ibuf_92); SetIndexStyle(0, DRAW_NONE); return (TRUE); } return (FALSE); }