Код:
extern int AngleCheck = 18; extern int TakeProfit = 10; extern int StopLoss = 30; extern int MinProfitValue = 1; extern bool ExtrimProfit = FALSE; extern double Lots = 0.1; extern bool UseMM = FALSE; extern int DepoPercent = 10; int g_magic_112; int g_pos_116; int g_error_120; int g_spread_124; int gi_128; int g_leverage_132; int g_hour_136; int gi_140; int gi_144; bool gi_148 = FALSE; bool gi_152 = FALSE; bool gi_156 = FALSE; double gd_160; double gd_168; double gd_176; double gd_unused_184; double gd_unused_192; double g_lots_200; int g_datetime_208; string g_comment_212 = "Stomper_"; string gs_dummy_220; string gs_dummy_228; string g_text_236; string gs_244; int gia_252[300]; string gsa_256[4207]; int init() { g_leverage_132 = AccountLeverage(); InitErrorArray(); g_spread_124 = MarketInfo(Symbol(), MODE_SPREAD); gd_176 = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSTEP), 2); gd_unused_184 = NormalizeDouble(MarketInfo(Symbol(), MODE_MINLOT), 2); gd_unused_192 = NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT), 2); if (gd_176 == 0.01) gi_128 = 2; else gi_128 = 1; g_magic_112 = StringGetChar(Symbol(), 0) + StringGetChar(Symbol(), 1) + 100 * StringGetChar(Symbol(), 3) + 100 * StringGetChar(Symbol(), 4) + 100000 * Period(); return (0); } int deinit() { ObjectDelete("Comment"); ObjectDelete("Comment2"); return (0); } int start() { gi_148 = FALSE; gi_152 = FALSE; gi_156 = FALSE; int li_0 = MarketInfo(Symbol(), MODE_STOPLEVEL); if (TakeProfit < li_0) TakeProfit = li_0; g_hour_136 = Hour(); if (StopLoss < li_0) StopLoss = li_0; int li_4 = MarketInfo(Symbol(), MODE_SPREAD); if (!ExtrimProfit) { gi_140 = gia_252[250] + 1; gi_144 = gia_252[120] - 4; } else { gi_140 = gia_252[250] - 1; gi_144 = gia_252[120] - 2; } if (g_hour_136 >= gi_140 || g_hour_136 <= gi_144) gi_156 = TRUE; gd_160 = High[iHighest(NULL, 0, MODE_HIGH, AngleCheck, 1)]; gd_168 = Low[iLowest(NULL, 0, MODE_LOW, AngleCheck, 1)]; if (gd_168 - Bid == 0.0) gi_148 = TRUE; if (Bid - gd_160 == 0.0) gi_152 = TRUE; if (!UseMM) g_lots_200 = Lots; else g_lots_200 = NormalizeDouble(AccountFreeMargin() * DepoPercent / 100000.0 / (g_leverage_132 / 100), gi_128); if (IsConnected()) { if (IsDemo()) gs_244 = "Demo"; else gs_244 = "Real"; ObjectCreate("Comment", OBJ_LABEL, 0, 0, 1.0); ObjectSet("Comment", OBJPROP_CORNER, 0); ObjectSet("Comment", OBJPROP_XDISTANCE, 3); ObjectSet("Comment", OBJPROP_YDISTANCE, 25); g_text_236 = "Broker: " + AccountCompany() + " AccountNumber: " + AccountNumber() + " Trading lot: " + gs_244; ObjectSetText("Comment", g_text_236, 10, "Times New Roman", Yellow); ObjectSet("Comment", OBJPROP_TIMEFRAMES, NULL); ObjectSet("Comment", OBJPROP_BACK, FALSE); } else ObjectDelete("Comment"); ObjectCreate("Comment2", OBJ_LABEL, 0, 0, 1.0); ObjectSet("Comment2", OBJPROP_CORNER, 0); ObjectSet("Comment2", OBJPROP_XDISTANCE, 3); ObjectSet("Comment2", OBJPROP_YDISTANCE, 50); g_text_236 = "Account Balance: " + DoubleToStr(AccountBalance(), gi_128) + " Account Balance: " + DoubleToStr(g_lots_200, gi_128); ObjectSetText("Comment2", g_text_236, 10, "Times New Roman", Yellow); ObjectSet("Comment2", OBJPROP_TIMEFRAMES, NULL); ObjectSet("Comment2", OBJPROP_BACK, FALSE); for (g_pos_116 = 0; g_pos_116 < OrdersTotal(); g_pos_116++) { if (OrderSelect(g_pos_116, SELECT_BY_POS)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_112) { if (OrderType() == OP_BUY) if ((MinProfitValue > 0 && Close[0] - OrderOpenPrice() >= (MinProfitValue + li_4) * Point) || TimeCurrent() - OrderOpenTime() >= 60 * (Period() * StopLoss)) OrderClose(OrderTicket(), OrderLots(), Bid, g_spread_124, Blue); if (OrderType() == OP_SELL) if ((MinProfitValue > 0 && OrderOpenPrice() - Close[0] >= (MinProfitValue + li_4) * Point) || TimeCurrent() - OrderOpenTime() >= 60 * (Period() * StopLoss)) OrderClose(OrderTicket(), OrderLots(), Ask, g_spread_124, Red); } } } if (gi_148 && gi_156 && IsTradeAllowed() && AccountFreeMarginCheck(Symbol(), OP_BUY, g_lots_200) > 0.0 && SymbolOrders() < 1 && TimeCurrent() - g_datetime_208 >= 60 * Period()) { for (g_pos_116 = 0; g_pos_116 <= 1; g_pos_116++) { RefreshRates(); OrderSend(Symbol(), OP_BUY, g_lots_200, Ask, g_spread_124, Bid - StopLoss * Point, Ask + TakeProfit * Point, g_comment_212, g_magic_112, 0, Blue); g_error_120 = GetLastError(); if (g_error_120 == 0/* NO_ERROR */) { g_datetime_208 = TimeCurrent(); break; } Print("Trial №", g_pos_116 + 1, "- Error opening: ", PrintError(g_error_120)); } } if (gi_152 && gi_156 && IsTradeAllowed() && AccountFreeMarginCheck(Symbol(), OP_BUY, g_lots_200) > 0.0 && SymbolOrders() < 1 && TimeCurrent() - g_datetime_208 >= 60 * Period()) { for (g_pos_116 = 0; g_pos_116 <= 1; g_pos_116++) { RefreshRates(); OrderSend(Symbol(), OP_SELL, g_lots_200, Bid, g_spread_124, Ask + StopLoss * Point, Bid - TakeProfit * Point, g_comment_212, g_magic_112, 0, Red); g_error_120 = GetLastError(); if (g_error_120 == 0/* NO_ERROR */) { g_datetime_208 = TimeCurrent(); break; } Print("Trial №", g_pos_116 + 1, "- Error opening: ", PrintError(g_error_120)); } } return (0); } int SymbolOrders() { int li_ret_0; for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) { if (OrderSelect(l_pos_4, SELECT_BY_POS)) { if (OrderSymbol() == Symbol()) if (OrderMagicNumber() == g_magic_112) li_ret_0++; } } return (li_ret_0); } string PrintError(int ai_0) { return (gsa_256[ai_0]); } void InitErrorArray() { gsa_256[0] = "No errors"; gsa_256[1] = "No errors, but the result is unknown"; gsa_256[2] = "total error"; gsa_256[3] = "Invalid parameters"; gsa_256[4] = "server busy shopping"; gsa_256[5] = "The old version of the client terminal"; gsa_256[6] = "No connection with commercial service"; gsa_256[7] = "not enough rights"; gsa_256[8] = "Too often requests"; gsa_256[9] = "Invalid operation disrupt the server"; gsa_256[64] = "blocked account"; gsa_256[65] = "Invalid account number"; gsa_256[128] = "Expired expectations of the transaction"; gsa_256[129] = "Invalid value"; gsa_256[130] = "Wrong Foot"; gia_252[120] = 5; gsa_256[131] = "Invalid volume"; gsa_256[132] = "The market is closed"; gsa_256[133] = "Trade is prohibited"; gsa_256[134] = "Not enough money for the transaction"; gsa_256[135] = "Price changed"; gsa_256[136] = "No price"; gsa_256[137] = "The broker is busy"; gsa_256[138] = "New prices"; gia_252[250] = 21; gsa_256[139] = "Order has been blocked and processed"; gsa_256[140] = "Only buy"; gsa_256[141] = "Too many bugs"; gsa_256[145] = "Modification is prohibited, as well as the warrant is too close to the market"; gsa_256[146] = "subsystem busy trade"; gsa_256[147] = "Use of the expiry of the warrant is prohibited broker"; gsa_256[148] = "The number of open and pending orders had reached the limit set by the broker"; gsa_256[4000] = "No errors"; gsa_256[4001] = "Invalid pointer function"; gsa_256[4002] = "index of the array - is out of range"; gsa_256[4003] = "No memory for the stack functions"; gsa_256[4004] = "Stack after recursive call"; gsa_256[4005] = "The stack has no memory for settings"; gsa_256[4006] = "No memory for the string value"; gsa_256[4007] = "No memory for a temporary line"; gsa_256[4008] = "Neinitsializirovannaya line"; gsa_256[4009] = "Neinitsializirovannaya line in the array"; gsa_256[4010] = "No memory for the string array"; gsa_256[4011] = "Too long line"; gsa_256[4012] = "The balance of dividing by zero"; gsa_256[4013] = "division by zero "; gsa_256[4014] = "Neizvestnaya team"; gsa_256[4015] = "Bad move"; gsa_256[4016] = "uninitialized array"; gsa_256[4017] = "Call DLL is not permitted"; gsa_256[4018] = "Can not load library"; gsa_256[4019] = "You can not call"; gsa_256[4020] = "Challenge external library functions are not allowed"; gsa_256[4021] = "Not enough memory to the line, recovery of function"; gsa_256[4022] = "System busy"; gsa_256[4050] = "Wrong number of parameters of the function"; gsa_256[4051] = "Invalid value of the function"; gsa_256[4052] = "Internal error string function"; gsa_256[4053] = "Error Array"; gsa_256[4054] = "Misuse of solid-taymserii"; gsa_256[4055] = "Error custom indicator"; gsa_256[4056] = "Arrays are incompatible"; gsa_256[4057] = "Error processing globalnyeh variables"; gsa_256[4058] = "A global variable is not detected"; gsa_256[4059] = "function is not permitted in test mode"; gsa_256[4060] = "function is not permitted"; gsa_256[4061] = "Error sending"; gsa_256[4062] = "expected value of type string"; gsa_256[4063] = "expected value of type integer"; gsa_256[4064] = "parameter type is expected to double"; gsa_256[4065] = "An option is expected to range"; gsa_256[4066] = "The requested historical data in a position to update"; gsa_256[4067] = "Error executing trading transactions"; gsa_256[4099] = "End of File"; gsa_256[4100] = "Error in a file"; gsa_256[4101] = "Invalid filename"; gsa_256[4102] = "Too many open files"; gsa_256[4103] = "Can not open file"; gsa_256[4104] = "Incompatible mode of access to the file"; gsa_256[4105] = "No warrant is not selected"; gsa_256[4106] = "unknown character"; gsa_256[4107] = "Invalid setting prices for commercial functions"; gsa_256[4108] = "Wrong number Ticket"; gsa_256[4109] = "Trade is not allowed. It is necessary to enable the option Allow an adviser to trade in the properties of an expert"; gsa_256[4110] = "Long positions are not allowed. You should check the properties of an expert"; gsa_256[4111] = "Short positions are not allowed. You should check the properties of an expert"; gsa_256[4200] = "Object already there"; gsa_256[4201] = "Requested an unknown object properties"; gsa_256[4202] = "Object does not exist "; gsa_256[4203] = "Unknown type of object"; gsa_256[4204] = "None of the facility"; gsa_256[4205] = "Error coordinates"; gsa_256[4206] = "Not Found specified subwindow"; gsa_256[4207] = "Error with the object"; }