#property copyright "PipsEC Robot" #property link "" extern string OrderOptions = "-------- Orders options --------"; extern double Lots = 0.0; extern int LotsPercent = 25; int gi_unused_96 = 30; bool gi_100 = FALSE; extern int TakeProfit = 30; extern bool TryTakeProfit = FALSE; extern int StopLoss = 49; bool gi_116 = TRUE; extern double SafeSpread = 3.0; extern int Slippage = 3; extern int MagicNumber = 6532; int gi_unused_136 = 50; int gi_140 = 5; string gs_unused_144 = "-------- Trade options --------"; int gi_152 = 10; int gi_156 = 0; int gi_160 = 0; bool gi_164 = FALSE; bool gi_168 = TRUE; string gs_unused_172 = "--------Transmite options--------"; bool gi_180 = FALSE; bool gi_184 = FALSE; bool gi_188 = FALSE; int gi_192 = 10; bool gi_196 = TRUE; int gi_200 = 10; bool gi_204 = FALSE; int gi_208 = 0; extern string TimeOptions = "-------- Time options --------"; bool gi_220 = FALSE; int gi_224 = 1; int gi_228 = 0; extern int OpenHour1 = 21; extern int CloseHour1 = 23; int gi_240 = 0; int gi_244 = 0; extern int GMToffset = 0; string gs_unused_252 = "-------- Other options --------"; bool gi_260 = TRUE; bool gi_264 = TRUE; int gi_unused_268 = 3; bool gi_272 = TRUE; bool gi_276 = TRUE; bool gi_280 = FALSE; bool gi_284 = FALSE; int gi_288 = 2; int gi_unused_292 = 20; int gi_unused_296 = 0; double gd_unused_300 = 2.5; int gi_unused_308 = 50; bool gi_312 = FALSE; bool gi_unused_316 = FALSE; bool gi_unused_320 = TRUE; bool gi_324 = FALSE; int gi_328; double gd_332; string g_comment_340; string gs_348; double g_lots_356; double g_high_364; double g_low_372; int gi_unused_380 = 0; int g_color_384 = Blue; int g_color_388 = Red; int gi_unused_392; int gi_unused_400; int gi_404; int gi_unused_408; int gi_unused_416 = 1; double g_time_420 = 0.0; double g_ord_profit_428; bool gi_unused_444 = FALSE; bool gi_unused_448 = FALSE; double gd_unused_452 = 0.0; double gd_unused_460 = 0.0; double gd_unused_468 = 0.0; double gd_unused_476 = 0.0; double gd_unused_484 = 50.0; double gd_unused_492 = 50.0; double gd_unused_500 = 0.0; double gd_unused_508 = 0.0; double gd_unused_516 = 50.0; double gd_unused_524 = 50.0; int g_count_532; int g_count_536; int gi_unused_540 = 99; int gi_unused_544 = 99; int gi_unused_548 = 1; int gi_552 = 10; int gi_556; int gi_560 = 0; int gi_564 = 0; int gi_568 = 1; int gi_572 = 2; int gi_576 = 3; int gi_580 = 4; int gi_584 = 5; int gi_588 = 0; int gi_592 = 0; int gi_596 = 1; int gi_600 = 2; int gi_604 = 3; int gi_608 = 4; int gi_612 = 5; int gi_616 = 6; int gi_620 = 7; bool gi_624 = TRUE; int gi_632; int gi_636; int gi_644; int gi_648; int gi_652; int gi_656; bool gi_660; bool gi_664 = FALSE; string gsa_668[4207]; int gia_672[5][4]; double gda_676[1][6]; double gda_680[1][8]; string gsa_684[20][2]; int init() { Comment(""); gs_348 = ""; if (Digits == 2) gi_328 = 10; else gi_328 = 1; gd_332 = gi_328 * Point; Slippage *= gi_328; g_comment_340 = "PipsEC Robot" + "1.01"; InitErrorArray(); OpenHour1 = (OpenHour1 + GMToffset) % 24; CloseHour1 = (CloseHour1 + GMToffset + 23) % 24 + 1; gi_240 = (gi_240 + GMToffset) % 24; gi_244 = (gi_244 + GMToffset + 23) % 24 + 1; if (gi_324) HideTestIndicators(TRUE); g_time_420 = Time[0]; ClearBuffer("ReceiveBuffer", gi_560); ClearBuffer("CommandBuffer", gi_588); ClearBuffer("CommentBuffer", 0); gs_348 = "Manual settings for " + AccountCompany() + " M" + Period() + "\n"; if (gi_100) { if (SetAutoSettings()) { gs_348 = "Automatic settings for " + AccountCompany() + " M" + Period() + "\n"; } } gi_644 = OpenHour1; gi_648 = CloseHour1; gi_652 = gi_240; gi_656 = gi_244; StartRulls(); if (Lots != 0.0) { gs_348 = gs_348 + "Lots = " + DoubleToStr(Lots, 2) + "\n"; } else { gs_348 = gs_348 + "LotsPercent = " + LotsPercent + " %" + "\n"; } gs_348 = gs_348 + ""; gs_348 = gs_348 + ""; gs_348 = gs_348 + ""; if (gi_184) SaveFileOrder(0, 99, 0, 0, 0, 0, 0); else Comments("Initial"); return (0); } int deinit() { ClearBuffer("ReceiveBuffer", gi_560); ClearBuffer("CommandBuffer", gi_588); ClearBuffer("CommentBuffer", 0); Comment(""); return (0); } int start() { if (!StartRulls()) return (0); if (gi_180) { if (ReadFileOrder()) CheckReceiveBuffer(); CheckCommandBuffer(); return (0); } PrepareIndicators(); if (isOrderSell() && !TimeCurrentBar()) { if (isGroDtoBuy() || isMinProfittoClose() || TryToCloseAgain()) { if (gi_404 < 0 && TryTakeProfit) return (0); CloseSellOrder(); return (0); } return (0); } if (isOrderBuy() && !TimeCurrentBar()) { if (isGroDtoSell() || isMinProfittoClose() || TryToCloseAgain()) { if (gi_404 < 0 && TryTakeProfit) return (0); CloseBuyOrder(); return (0); } return (0); } if (isGroDtoSell(1) && !TimeCurrentBar() && isTimetoTrade(OpenHour1, CloseHour1) || isTimetoTrade(gi_240, gi_244)) { SendSellOrder(StopLoss, TakeProfit); return (0); } if (isGroDtoBuy(1) && !TimeCurrentBar() && isTimetoTrade(OpenHour1, CloseHour1) || isTimetoTrade(gi_240, gi_244)) { SendBuyOrder(StopLoss, TakeProfit); return (0); } return (0); } bool TimeCurrentBar() { bool li_ret_0 = FALSE; if (gi_164 && Time[0] == g_time_420) li_ret_0 = TRUE; return (li_ret_0); } int isOrderSell() { bool li_ret_0 = FALSE; int l_pos_4 = 0; int l_ord_total_12 = OrdersTotal(); for (l_pos_4 = 0; l_pos_4 < l_ord_total_12; l_pos_4++) { OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderType() == OP_SELL) { if (!gi_184 && OrderMagicNumber() != MagicNumber) continue; li_ret_0 = TRUE; g_ord_profit_428 = OrderProfit(); gi_404 = (OrderOpenPrice() - Ask) / gd_332; break; } } if (gi_632 && !li_ret_0) if (OrderStopLoss() != 0.0 || OrderTakeProfit() != 0.0) g_time_420 = Time[0]; gi_632 = li_ret_0; return (li_ret_0); } int isOrderBuy() { bool li_ret_0 = FALSE; int l_pos_4 = 0; int l_ord_total_12 = OrdersTotal(); for (l_pos_4 = 0; l_pos_4 < l_ord_total_12; l_pos_4++) { OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderType() == OP_BUY) { if (!gi_184 && OrderMagicNumber() != MagicNumber) continue; li_ret_0 = TRUE; g_ord_profit_428 = OrderProfit(); gi_404 = (Bid - OrderOpenPrice()) / gd_332; break; } } if (gi_636 && !li_ret_0) if (OrderStopLoss() != 0.0 || OrderTakeProfit() != 0.0) g_time_420 = Time[0]; gi_636 = li_ret_0; return (li_ret_0); } int CloseBuyOrder() { bool l_bool_8; bool li_ret_0 = FALSE; int l_pos_4 = 0; int l_ord_total_12 = OrdersTotal(); for (l_pos_4 = 0; l_pos_4 < l_ord_total_12; l_pos_4++) { l_bool_8 = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderType() == OP_BUY) { if (isFreezLevel() == 0) { if (!gi_184 && OrderMagicNumber() == MagicNumber) { if (OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, g_color_384)) { li_ret_0 = TRUE; g_time_420 = Time[0]; gi_unused_544 = 0; gi_660 = FALSE; } else { Comments("Error close Buy order: " + PrintError(GetLastError())); gi_660 = TRUE; } } else { if (SaveFileOrder(Time[0], 98, OrderTicket(), OrderLots(), Bid, 0, 0)) { li_ret_0 = TRUE; g_time_420 = Time[0]; gi_unused_544 = 0; gi_660 = FALSE; } else { Comments("Error transmite Close Buy order"); gi_660 = TRUE; } } } } } return (li_ret_0); } int CloseSellOrder() { bool l_bool_8; bool li_ret_0 = FALSE; int l_pos_4 = 0; int l_ord_total_12 = OrdersTotal(); for (l_pos_4 = 0; l_pos_4 < l_ord_total_12; l_pos_4++) { l_bool_8 = OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderType() == OP_SELL) { if (isFreezLevel() == 0) { if (!gi_184 && OrderMagicNumber() == MagicNumber) { if (OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, g_color_388)) { li_ret_0 = TRUE; g_time_420 = Time[0]; gi_unused_544 = 1; gi_660 = FALSE; } else { Comments("Error close Sell order: " + PrintError(GetLastError())); gi_660 = TRUE; } } else { if (SaveFileOrder(Time[0], 98, OrderTicket(), OrderLots(), Ask, 0, 0)) { li_ret_0 = TRUE; g_time_420 = Time[0]; gi_unused_544 = 1; gi_660 = FALSE; } else { Comments("Error transmite Close Sell order"); gi_660 = TRUE; } } } } } return (li_ret_0); } int TryToCloseAgain() { bool li_ret_0 = FALSE; if (!gi_660) gi_556 = gi_208; else { gi_556--; if (gi_556 > 0) li_ret_0 = TRUE; else gi_660 = FALSE; } return (li_ret_0); } bool isFreezLevel() { double l_price_4; double ld_12; bool li_ret_0 = FALSE; if (gi_116) { if (OrderStopLoss() != 0.0 || OrderTakeProfit() != 0.0) { if (OrderType() == OP_BUY) l_price_4 = Bid; if (OrderType() == OP_SELL) l_price_4 = Ask; ld_12 = MarketInfo(Symbol(), MODE_FREEZELEVEL) * Point; if (OrderStopLoss() != 0.0 && ld_12 > MathAbs(l_price_4 - OrderStopLoss())) li_ret_0 = TRUE; if (OrderTakeProfit() != 0.0 && ld_12 > MathAbs(l_price_4 - OrderTakeProfit())) li_ret_0 = TRUE; } } return (li_ret_0); } bool SendBuyOrder(double a_price_0, double a_price_8) { int l_ticket_16 = 0; gi_660 = FALSE; if (a_price_0 != 0.0) { if (a_price_0 < MarketInfo(Symbol(), MODE_STOPLEVEL) / gi_328) a_price_0 = MarketInfo(Symbol(), MODE_STOPLEVEL) / gi_328; a_price_0 = NormalizeDouble(Bid - a_price_0 * gd_332, Digits); } if (a_price_8 != 0.0) { if (a_price_8 < MarketInfo(Symbol(), MODE_STOPLEVEL) / gi_328) a_price_8 = MarketInfo(Symbol(), MODE_STOPLEVEL) / gi_328; a_price_8 = NormalizeDouble(Ask + a_price_8 * gd_332, Digits); } if (!gi_184) { l_ticket_16 = OrderSend(Symbol(), OP_BUY, g_lots_356, Ask, Slippage, a_price_0, a_price_8, g_comment_340, MagicNumber, 0, g_color_384); if (l_ticket_16 > 0) { if (OrderSelect(l_ticket_16, SELECT_BY_TICKET, MODE_TRADES)) { g_time_420 = Time[0]; gi_unused_392 = Bars; gi_unused_400 = l_ticket_16; gi_unused_408 = 0; } } else { Comments("Error open Buy order : " + PrintError(GetLastError())); return (FALSE); } } else { if (SaveFileOrder(Time[0], 0, l_ticket_16, g_lots_356, Ask, a_price_0, a_price_8)) { g_time_420 = Time[0]; gi_unused_392 = Bars; gi_unused_408 = 0; } else { Comments("Error transmite open Buy order"); return (FALSE); } } return (TRUE); } bool SendSellOrder(double a_price_0, double a_price_8) { int l_ticket_16 = 0; gi_660 = FALSE; if (a_price_0 != 0.0) { if (a_price_0 < MarketInfo(Symbol(), MODE_STOPLEVEL) / gi_328) a_price_0 = MarketInfo(Symbol(), MODE_STOPLEVEL) / gi_328; a_price_0 = NormalizeDouble(Ask + a_price_0 * gd_332, Digits); } if (a_price_8 != 0.0) { if (a_price_8 < MarketInfo(Symbol(), MODE_STOPLEVEL) / gi_328) a_price_8 = MarketInfo(Symbol(), MODE_STOPLEVEL) / gi_328; a_price_8 = NormalizeDouble(Bid - a_price_8 * gd_332, Digits); } if (!gi_184) { l_ticket_16 = OrderSend(Symbol(), OP_SELL, g_lots_356, Bid, Slippage, a_price_0, a_price_8, g_comment_340, MagicNumber, 0, g_color_388); if (l_ticket_16 > 0) { if (OrderSelect(l_ticket_16, SELECT_BY_TICKET, MODE_TRADES)) { g_time_420 = Time[0]; gi_unused_392 = Bars; gi_unused_400 = l_ticket_16; gi_unused_408 = 0; } } else { Comments("Error open Sell order : " + PrintError(GetLastError())); return (FALSE); } } else { if (SaveFileOrder(Time[0], 1, l_ticket_16, g_lots_356, Bid, a_price_0, a_price_8)) { g_time_420 = Time[0]; gi_unused_392 = Bars; gi_unused_408 = 0; } else { Comments("Error transmite open Sell order"); return (FALSE); } } return (TRUE); } bool StartRulls() { int li_24; if (gi_220 && DayOfWeek() > 0) { OpenHour1 = gia_672[DayOfWeek() - 1][0]; CloseHour1 = gia_672[DayOfWeek() - 1][1]; gi_240 = gia_672[DayOfWeek() - 1][2]; gi_244 = gia_672[DayOfWeek() - 1][3]; } if (!gi_664) gi_664 = TRUE; else { if (gi_644 != OpenHour1 || gi_648 != CloseHour1 || gi_652 != gi_240 || gi_656 != gi_244) { gi_644 = OpenHour1; gi_648 = CloseHour1; gi_652 = gi_240; gi_656 = gi_244; Comments("Another trade time EA"); } } if (IsOptimization()) { if (OpenHour1 > 12) return (FALSE); if (CloseHour1 > 12) return (FALSE); if (gi_240 < 12) return (FALSE); if (gi_244 < 12) return (FALSE); if (OpenHour1 > CloseHour1 || gi_240 > gi_244) return (FALSE); } if (Bars < 100) { Comments("StartRulls() Bars less than 100"); return (FALSE); } if (IsTesting() || IsOptimization()) { gi_180 = FALSE; gi_184 = FALSE; } if (gi_180 && gi_184) return (FALSE); double ld_0 = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSTEP), 2); double ld_8 = NormalizeDouble(MarketInfo(Symbol(), MODE_MINLOT), 2); double ld_16 = NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT), 2); if (ld_0 == 0.01) li_24 = 2; else li_24 = 1; if (Lots == 0.0) g_lots_356 = NormalizeDouble(AccountFreeMargin() * LotsPercent / 100000.0, li_24); else g_lots_356 = Lots; if (g_lots_356 > ld_16) g_lots_356 = ld_16; if (g_lots_356 < ld_8) g_lots_356 = ld_8; return (TRUE); } int isMinProfittoClose() { bool li_ret_0 = FALSE; if (gi_404 > 0 && gi_404 >= gi_140 && gi_140 != 0) li_ret_0 = TRUE; return (li_ret_0); } int isGroDtoBuy(bool ai_0 = FALSE) { bool li_ret_4 = FALSE; if (ai_0) if (Ask - Bid > SafeSpread * gd_332) return (0); if (!gi_312) { if (Bid < g_low_372 - gd_332 * gi_160 || (gi_168 && Bid <= g_low_372 - gd_332 * gi_160)) li_ret_4 = TRUE; } else if (Bid > g_high_364 || (gi_168 && Bid >= g_high_364)) li_ret_4 = TRUE; return (li_ret_4); } int isGroDtoSell(bool ai_0 = FALSE) { bool li_ret_4 = FALSE; if (ai_0) if (Ask - Bid > SafeSpread * gd_332) return (0); if (!gi_312) { if (Bid > g_high_364 + gd_332 * gi_156 || (gi_168 && Bid >= g_high_364 + gd_332 * gi_156)) li_ret_4 = TRUE; } else if (Bid < g_low_372 || (gi_168 && Bid <= g_low_372)) li_ret_4 = TRUE; return (li_ret_4); } int isTimetoTrade(int ai_0, int ai_4) { bool li_ret_8 = FALSE; int l_hour_12 = Hour(); if (ai_0 > 23 || ai_0 < 0) ai_0 = 0; if (ai_4 > 23 || ai_4 < 0) ai_4 = 0; if (ai_0 < ai_4 && (Hour() >= ai_0 && Hour() < ai_4)) li_ret_8 = TRUE; if (ai_0 > ai_4 && Hour() >= ai_0 || Hour() < ai_4) li_ret_8 = TRUE; if (DayOfWeek() != gi_228 && gi_228 != 0) li_ret_8 = FALSE; return (li_ret_8); } bool SaveFileOrder(int ai_unused_0, int ai_4, int ai_8, double ad_12, double ad_20, double ad_28, double ad_36) { bool li_ret_48 = FALSE; string l_name_52 = Symbol() + ".csv"; int l_file_44 = FileOpen(l_name_52, FILE_CSV|FILE_WRITE, ';'); if (l_file_44 < 1) return (li_ret_48); FileWrite(l_file_44, ai_4, ad_12, ai_8, ad_20, DoubleToStr(ad_28, Digits), DoubleToStr(ad_36, Digits)); FileClose(l_file_44); li_ret_48 = TRUE; if (ai_4 == 0) Comments("BUY " + ai_4 + " ; " + g_lots_356 + " ; " + ai_8 + " ; " + ad_20 + " ; " + ad_28 + " ; " + ad_36); if (ai_4 == 1) Comments("SELL " + ai_4 + " ; " + g_lots_356 + " ; " + ai_8 + " ; " + ad_20 + " ; " + ad_28 + " ; " + ad_36); if (ai_4 == 98) Comments("CLOSE " + ai_4 + " ; " + g_lots_356 + " ; " + ai_8 + " ; " + ad_20 + " ; " + ad_28 + " ; " + ad_36); if (ai_4 == 99) Comments("NONE " + ai_4 + " ; " + g_lots_356 + " ; " + ai_8 + " ; " + ad_20 + " ; " + ad_28 + " ; " + ad_36); g_count_536++; if (g_count_536 > gi_552) g_count_536 = 0; int l_datetime_60 = TimeLocal(); if (gi_188) { li_ret_48 = FALSE; while (TimeLocal() - l_datetime_60 < gi_192) { if (!isFile()) { li_ret_48 = TRUE; break; } Sleep(25); } if (!li_ret_48) { if (gi_204) { if (FileErase(l_name_52)) Comments("SaveFileOrder(): Deleted expired file."); else Comments("SaveFileOrder(): Expired file deletion failed"); } else Comments("SaveFileOrder(): File expired"); } } l_datetime_60 = TimeLocal(); if (gi_196) { li_ret_48 = FALSE; while (TimeLocal() - l_datetime_60 < gi_200) { if (ai_4 == 1 && isOrderSell()) { li_ret_48 = TRUE; break; } if (ai_4 == 0 && isOrderBuy()) { li_ret_48 = TRUE; break; } if (ai_4 == 98 && !isOrderSell() && !isOrderBuy()) { li_ret_48 = TRUE; break; } if (ai_4 == 99) { li_ret_48 = TRUE; break; } Sleep(25); } if (!li_ret_48) { if (gi_204) { if (FileErase(l_name_52)) Comments("SaveFileOrder(): Deleted expired file."); else Comments("SaveFileOrder(): Expired file deletion failed"); } else Comments("SaveFileOrder(): File expired"); } } return (li_ret_48); } bool isFile() { bool li_ret_12 = FALSE; string l_name_4 = Symbol() + ".csv"; int l_file_0 = FileOpen(l_name_4, FILE_CSV|FILE_WRITE|FILE_READ); if (l_file_0 > 0 && FileSize(l_file_0) > 0) { FileClose(l_file_0); li_ret_12 = TRUE; } return (li_ret_12); } bool FileErase(string a_name_0) { bool li_ret_12 = FALSE; int l_file_8 = FileOpen(a_name_0, FILE_CSV|FILE_WRITE); if (l_file_8 > 0) { FileClose(l_file_8); li_ret_12 = TRUE; } return (li_ret_12); } int Comments(string as_0) { string ls_20; bool li_ret_8 = FALSE; if (gi_272) { ls_20 = ""; if (gi_276) ls_20 = ls_20 + TimeToStr(TimeCurrent(), TIME_SECONDS) + " : "; if (gi_280) ls_20 = ls_20 + g_comment_340; if (gi_284) ls_20 = ls_20 + "(" + MagicNumber + ")"; if (gi_280 || gi_284) ls_20 = ls_20 + ": "; Print(ls_20 + as_0); } if (gi_264) { if (gi_260) Comment(gs_348 + ls_20 + as_0); } else if (gi_260) Comment(ls_20 + as_0); return (li_ret_8); } bool ReadFileOrder() { int l_file_0; string ls_8; string l_name_16; bool li_ret_24 = FALSE; if (gi_624) { for (int l_count_4 = 0; l_count_4 < gi_552 + 1; l_count_4++) { l_name_16 = Symbol() + ((MagicNumber + Period())) + "_" + l_count_4 + ".csv"; l_file_0 = FileOpen(l_name_16, FILE_CSV|FILE_READ); if (!(l_file_0 < 0)) { g_count_532 = l_count_4; gi_624 = FALSE; FileClose(l_file_0); break; } } } if (gi_624) return (li_ret_24); l_name_16 = Symbol() + ((MagicNumber + Period())) + "_" + g_count_532 + ".csv"; l_file_0 = FileOpen(l_name_16, FILE_CSV|FILE_READ); if (l_file_0 > 0) { ls_8 = FileReadString(l_file_0); gda_676[gi_560][gi_564] = StrToInteger(ls_8); ls_8 = FileReadString(l_file_0); gda_676[gi_560][gi_568] = StrToInteger(ls_8); ls_8 = FileReadString(l_file_0); gda_676[gi_560][gi_572] = StrToInteger(ls_8); ls_8 = FileReadString(l_file_0); gda_676[gi_560][gi_576] = StrToDouble(ls_8); ls_8 = FileReadString(l_file_0); gda_676[gi_560][gi_580] = StrToDouble(ls_8); ls_8 = FileReadString(l_file_0); gda_676[gi_560][gi_584] = StrToDouble(ls_8); FileClose(l_file_0); FileDelete(l_name_16); g_count_532++; if (g_count_532 > gi_552) g_count_532 = 0; Comments("ReadFileOrder(): File read " + l_name_16); li_ret_24 = TRUE; } return (TRUE); } int CheckReceiveBuffer() { bool li_ret_0 = FALSE; if (gda_676[gi_560][gi_568] != 99.0) { if (gda_676[gi_560][gi_568] == 98.0) { if (gda_680[gi_588][gi_604] != 0.0 && gda_676[gi_560][gi_572] == gda_680[gi_588][gi_600]) { gda_680[gi_588][gi_596] = 98; gda_680[gi_588][gi_612] = gda_676[gi_560][gi_576]; li_ret_0 = TRUE; } } if (gda_676[gi_560][gi_568] == 0.0 || gda_676[gi_560][gi_568] == 1.0 && gda_680[gi_588][gi_596] == 99.0) { gda_680[gi_588][gi_592] = gda_676[gi_560][gi_564]; gda_680[gi_588][gi_596] = gda_676[gi_560][gi_568]; gda_680[gi_588][gi_600] = gda_676[gi_560][gi_572]; gda_680[gi_588][gi_608] = gda_676[gi_560][gi_576]; gda_680[gi_588][gi_616] = gda_676[gi_560][gi_580]; gda_680[gi_588][gi_620] = gda_676[gi_560][gi_584]; li_ret_0 = TRUE; } } ClearBuffer("ReceiveBuffer", gi_560); return (li_ret_0); } int CheckCommandBuffer() { bool li_ret_0 = FALSE; if (gda_680[gi_588][gi_596] != 99.0) { if (gda_680[gi_588][gi_592] + gi_288 * (60 * Period()) <= Time[0]) { if (gda_680[gi_588][gi_596] == 0.0 && gda_680[gi_588][gi_608] >= Ask) if (SendBuyOrder(gda_680[gi_588][gi_616], gda_680[gi_588][gi_620])) li_ret_0 = TRUE; if (gda_680[gi_588][gi_596] == 1.0 && gda_680[gi_588][gi_608] <= Bid) if (SendSellOrder(gda_680[gi_588][gi_616], gda_680[gi_588][gi_620])) li_ret_0 = TRUE; } if (gda_680[gi_588][gi_592] + gi_288 * (60 * Period()) <= Time[0]) { } } return (li_ret_0); } int ClearBuffer(string as_0, int ai_unused_8) { bool li_ret_12 = FALSE; if (as_0 == "ReceiveBuffer") { gda_676[gi_560][gi_564] = 0; gda_676[gi_560][gi_568] = 99; gda_676[gi_560][gi_572] = 0; gda_676[gi_560][gi_576] = 0; gda_676[gi_560][gi_580] = 0; gda_676[gi_560][gi_584] = 0; } if (as_0 == "CommandBuffer") { gda_676[gi_588][gi_592] = 0; gda_676[gi_588][gi_596] = 99; gda_676[gi_588][gi_600] = 0; gda_676[gi_588][gi_604] = 0; gda_676[gi_588][gi_608] = 0; gda_676[gi_588][gi_612] = 0; gda_676[gi_588][gi_616] = 0; gda_676[gi_588][gi_620] = 0; } if (as_0 == "CommentBuffer") { for (int l_index_16 = 0; l_index_16 < 20; l_index_16++) { gsa_684[l_index_16][0] = ""; gsa_684[l_index_16][1] = ""; } } return (li_ret_12); } string PrintError(int ai_0) { return (gsa_668[ai_0]); } void InitErrorArray() { gsa_668[0] = "No errors"; gsa_668[1] = "No errors, but no resulting"; gsa_668[2] = "General fault"; gsa_668[3] = "Fault parameters"; gsa_668[4] = "Trade busy"; gsa_668[5] = "Old version of terminal"; gsa_668[6] = "Not connect"; gsa_668[7] = "Rules not good for you"; gsa_668[8] = "Very many orders"; gsa_668[9] = "Invalid operation disrupt the server"; gsa_668[64] = "blocked account"; gsa_668[65] = "Invalid account number"; gsa_668[128] = "Expired expectations of the transaction"; gsa_668[129] = "Invalid price"; gsa_668[130] = "Wrong foot"; gsa_668[131] = "Invalid volume"; gsa_668[132] = "The market is closed"; gsa_668[133] = "Trade is prohibited"; gsa_668[134] = "Not enough money for the transaction"; gsa_668[135] = "Price has changed"; gsa_668[136] = "No price"; gsa_668[137] = "Broker busy"; gsa_668[138] = "New prices"; gsa_668[139] = "Order has been blocked and processed"; gsa_668[140] = "Allow only buy"; gsa_668[141] = "Too many bugs"; gsa_668[145] = "Modification is prohibited, as the warrant is too close to the market"; gsa_668[146] = "subsystem busy trade"; gsa_668[147] = "Using the date of expiry of the warrant is prohibited broker"; gsa_668[148] = "The number of open orders and deferred reached the limit set by the broker"; gsa_668[4000] = "No errors"; gsa_668[4001] = "Invalid Index function"; gsa_668[4002] = "Index array - out of range"; gsa_668[4003] = "No memory to stack functions"; gsa_668[4004] = "stack overflow after recursive call"; gsa_668[4005] = "At no memory of the stack to pass options"; gsa_668[4006] = "No memory for a string parameter"; gsa_668[4007] = "No memory for a temporary line"; gsa_668[4008] = "Neinitsializirovannaya line"; gsa_668[4009] = "Neinitsializirovannaya line in the array"; gsa_668[4010] = "No memory for an array string"; gsa_668[4011] = "Too long line"; gsa_668[4012] = "Balance of dividing by zero"; gsa_668[4013] = "The division by zero"; gsa_668[4014] = "Unknown command"; gsa_668[4015] = "Invalid conversion"; gsa_668[4016] = "Neinitsializirovanny array"; gsa_668[4017] = "Challenge DLL not allowed "; gsa_668[4018] = "Can not load library"; gsa_668[4019] = "Can not call"; gsa_668[4020] = "Challenge external library functions are not allowed "; gsa_668[4021] = "Not enough memory to the line, recovery of the function"; gsa_668[4022] = "system busy"; gsa_668[4050] = "Wrong number of parameters function"; gsa_668[4051] = "Invalid value functions"; gsa_668[4052] = "Internal error string functions"; gsa_668[4053] = "Error array"; gsa_668[4054] = "Misuse of solid-taymserii"; gsa_668[4055] = "user error indicator"; gsa_668[4056] = "Arrays incompatible"; gsa_668[4057] = "Error processing globalnyeh variables"; gsa_668[4058] = "global variable is not detected"; gsa_668[4059] = "function is not allowed in test mode"; gsa_668[4060] = "function is not allowed"; gsa_668[4061] = "Error sending"; gsa_668[4062] = "expected parameter type string"; gsa_668[4063] = "expected parameter type integer"; gsa_668[4064] = "expected parameter type double"; gsa_668[4065] = "As expected array parameter"; gsa_668[4066] = "The requested historical data in a state of renewal"; gsa_668[4067] = "Error executing trading operations"; gsa_668[4099] = "End file"; gsa_668[4100] = "error when working with the file"; gsa_668[4101] = "Invalid file name"; gsa_668[4102] = "Too many open files"; gsa_668[4103] = "Can not open file"; gsa_668[4104] = "Incompatible regime access to the file"; gsa_668[4105] = "No warrant is not selected"; gsa_668[4106] = "Unknown symbol"; gsa_668[4107] = "Invalid setting prices for commercial functions"; gsa_668[4108] = "Wrong number tiketa"; gsa_668[4109] = "Trade is not allowed. You need to include the option Allow an adviser to trade in the properties of expert"; gsa_668[4110] = "Long positions are not allowed. You should check the properties of expert"; gsa_668[4111] = "Short positions are not allowed. You should check the properties of expert"; gsa_668[4200] = "Object already exists"; gsa_668[4201] = "Requested an unknown object property"; gsa_668[4202] = "The object does not exist"; gsa_668[4203] = "Unknown type of object"; gsa_668[4204] = "No, the object name "; gsa_668[4205] = "Error coordinates object"; gsa_668[4206] = "said subwindow Not Found"; gsa_668[4207] = "error when working with the object"; } void PrepareIndicators() { g_high_364 = High[iHighest(NULL, 0, MODE_HIGH, gi_152, 1)]; g_low_372 = Low[iLowest(NULL, 0, MODE_LOW, gi_152, 1)]; } bool SetAutoSettings() { bool li_ret_0 = FALSE; if (AccountCompany() == "FIBO Group, Ltd.") { if (Symbol() == "EURGBP" && Period() == PERIOD_M5) { gi_152 = 24; gi_164 = FALSE; gi_168 = TRUE; if (gi_220) { OpenHour1 = 0; CloseHour1 = 1; gi_240 = 23; gi_244 = 0; } if (gi_224 == 0) li_ret_0 = TRUE; } if (Symbol() == "EURGBP" && Period() == PERIOD_M15) { gi_152 = 10; gi_164 = FALSE; gi_168 = TRUE; if (gi_220) { OpenHour1 = 0; CloseHour1 = 1; gi_240 = 22; gi_244 = 0; } gia_672[0][0] = 0; gia_672[0][1] = 1; gia_672[0][2] = 22; gia_672[0][3] = 24; gia_672[1][0] = 0; gia_672[1][1] = 1; gia_672[1][2] = 22; gia_672[1][3] = 24; gia_672[2][0] = 0; gia_672[2][1] = 1; gia_672[2][2] = 22; gia_672[2][3] = 24; gia_672[3][0] = 0; gia_672[3][1] = 1; gia_672[3][2] = 22; gia_672[3][3] = 24; gia_672[4][0] = 0; gia_672[4][1] = 1; gia_672[4][2] = 22; gia_672[4][3] = 24; if (gi_224 == 1) { gia_672[0][0] = 0; gia_672[0][1] = 1; gia_672[0][2] = 20; gia_672[0][3] = 24; gia_672[1][0] = 0; gia_672[1][1] = 2; gia_672[1][2] = 18; gia_672[1][3] = 24; gia_672[2][0] = 0; gia_672[2][1] = 0; gia_672[2][2] = 21; gia_672[2][3] = 24; gia_672[3][0] = 0; gia_672[3][1] = 6; gia_672[3][2] = 20; gia_672[3][3] = 24; gia_672[4][0] = 0; gia_672[4][1] = 3; gia_672[4][2] = 22; gia_672[4][3] = 24; } li_ret_0 = TRUE; } } if (AccountCompany() == "ODL Securities") { if (Symbol() == "EURGBP" && Period() == PERIOD_M5) { gi_152 = 24; gi_164 = FALSE; gi_168 = TRUE; if (gi_220) { OpenHour1 = 0; CloseHour1 = 5; gi_240 = 22; gi_244 = 0; } li_ret_0 = TRUE; } if (Symbol() == "EURGBP" && Period() == PERIOD_M15) { gi_152 = 9; gi_164 = FALSE; gi_168 = TRUE; if (gi_220) { OpenHour1 = 0; CloseHour1 = 5; gi_240 = 22; gi_244 = 0; } li_ret_0 = TRUE; } if (Symbol() == "EURCHF" && Period() == PERIOD_M15) { gi_152 = 15; gi_164 = FALSE; gi_168 = TRUE; if (gi_220) { OpenHour1 = 0; CloseHour1 = 1; gi_240 = 22; gi_244 = 0; } li_ret_0 = TRUE; } } if (AccountCompany() == "Alpari Ltd.") { if (Symbol() == "EURGBP" && Period() == PERIOD_M15) { gi_152 = 18; gi_164 = FALSE; gi_168 = TRUE; if (gi_220) { OpenHour1 = 0; CloseHour1 = 1; gi_240 = 22; gi_244 = 0; } if (gi_224 == 0) { gia_672[0][0] = 0; gia_672[0][1] = 1; gia_672[0][2] = 22; gia_672[0][3] = 24; gia_672[1][0] = 0; gia_672[1][1] = 1; gia_672[1][2] = 22; gia_672[1][3] = 24; gia_672[2][0] = 0; gia_672[2][1] = 1; gia_672[2][2] = 22; gia_672[2][3] = 24; gia_672[3][0] = 0; gia_672[3][1] = 1; gia_672[3][2] = 22; gia_672[3][3] = 24; gia_672[4][0] = 0; gia_672[4][1] = 1; gia_672[4][2] = 22; gia_672[4][3] = 24; } if (gi_224 == 1) { gia_672[0][0] = 0; gia_672[0][1] = 1; gia_672[0][2] = 20; gia_672[0][3] = 24; gia_672[1][0] = 0; gia_672[1][1] = 2; gia_672[1][2] = 18; gia_672[1][3] = 24; gia_672[2][0] = 0; gia_672[2][1] = 0; gia_672[2][2] = 21; gia_672[2][3] = 24; gia_672[3][0] = 0; gia_672[3][1] = 6; gia_672[3][2] = 20; gia_672[3][3] = 24; gia_672[4][0] = 0; gia_672[4][1] = 3; gia_672[4][2] = 22; gia_672[4][3] = 24; } li_ret_0 = TRUE; } } if (AccountCompany() == "Private Consulting Corp.") { if (Symbol() == "EURCHF" && Period() == PERIOD_M1) { gi_152 = 1; gi_164 = FALSE; gi_168 = FALSE; if (gi_220) { OpenHour1 = 0; CloseHour1 = 1; gi_240 = 23; gi_244 = 0; } if (gi_224 == 0) { gia_672[0][0] = 0; gia_672[0][1] = 1; gia_672[0][2] = 23; gia_672[0][3] = 24; gia_672[1][0] = 0; gia_672[1][1] = 1; gia_672[1][2] = 23; gia_672[1][3] = 24; gia_672[2][0] = 0; gia_672[2][1] = 1; gia_672[2][2] = 23; gia_672[2][3] = 24; gia_672[3][0] = 0; gia_672[3][1] = 1; gia_672[3][2] = 23; gia_672[3][3] = 24; gia_672[4][0] = 0; gia_672[4][1] = 1; gia_672[4][2] = 23; gia_672[4][3] = 24; } if (gi_224 == 1) { gia_672[0][0] = 0; gia_672[0][1] = 0; gia_672[0][2] = 21; gia_672[0][3] = 24; gia_672[1][0] = 0; gia_672[1][1] = 1; gia_672[1][2] = 23; gia_672[1][3] = 24; gia_672[2][0] = 0; gia_672[2][1] = 0; gia_672[2][2] = 23; gia_672[2][3] = 24; gia_672[3][0] = 0; gia_672[3][1] = 0; gia_672[3][2] = 22; gia_672[3][3] = 24; gia_672[4][0] = 0; gia_672[4][1] = 6; gia_672[4][2] = 24; gia_672[4][3] = 24; } if (gi_224 > 1) { gia_672[0][0] = 0; gia_672[0][1] = 1; gia_672[0][2] = 21; gia_672[0][3] = 24; gia_672[1][0] = 0; gia_672[1][1] = 7; gia_672[1][2] = 23; gia_672[1][3] = 24; gia_672[2][0] = 0; gia_672[2][1] = 0; gia_672[2][2] = 23; gia_672[2][3] = 24; gia_672[3][0] = 0; gia_672[3][1] = 7; gia_672[3][2] = 21; gia_672[3][3] = 24; gia_672[4][0] = 0; gia_672[4][1] = 8; gia_672[4][2] = 24; gia_672[4][3] = 24; } li_ret_0 = TRUE; } } return (li_ret_0); }