Iceman777 Posted February 8, 2010 Report Share Posted February 8, 2010 http://www.4shared.com/file/215242811/16cf3880/Slave.html (part of Genius EA) http://www.4shared.com/file/217306470/18a9a5ef/ForexSprinter.html (Sprinter) Quote Link to comment Share on other sites More sharing options...
Cyrillic Posted February 8, 2010 Report Share Posted February 8, 2010 Re: can someone please add hidden SL and TP to these two EA's? can you post the code right here. Thank you. edit. Sprinter has hidden tp build in. Quote [spoiler:26ukmy10]Never trust, never fear, never beg[/spoiler:26ukmy10] Link to comment Share on other sites More sharing options...
Iceman777 Posted February 8, 2010 Author Report Share Posted February 8, 2010 Re: can someone please add hidden SL and TP to these two EA's? OK, here they are, Yes sprinter has TP hidden so looking for hidden SL for that one. Attached in my original post are the actual MQ4 files Sprinter #property copyright "ForexSprinter" #property link "http://www.forexsprinter.com" extern string INFO = " ForexSprinter "; extern string OWN = "Copyright © 2009, ForexSprinter"; extern double Pipsaway = 5.0; extern double PipsTrail = 8.0; extern double TP = 5.0; extern double TPFake = 20.0; extern double SL = 29.0; extern int writelog = 0; extern int BEPips = 0; extern int TrailingStop = 0; extern string RiskManage = "If Lots set to 0 money management is according to RiskPercent"; extern double Lots = 1.0; extern int RiskPercent = 2; extern int Slippage = 3; extern string TradeLog = "MI_Log"; double g_price_192; double g_price_200; double g_price_208; double g_price_216; double g_price_224; double g_price_232; double gd_240; int g_magic_248 = 828636; string g_name_252; string gs_unused_260 = "ForexSprinter"; double gd_268; double gd_276; bool g_bool_284; int init() { g_bool_284 = Lots == 0.0; if (Digits % 2 == 1) { gd_268 = 10.0 * Point; gd_276 = Digits - 1; Slippage = 10 * Slippage; } else { gd_268 = Point; gd_276 = Digits; } return (0); } int deinit() { return (0); } double LotsOptimized() { double l_lots_0 = Lots; if (g_bool_284) l_lots_0 = MathMax(NormalizeDouble(MathFloor(AccountFreeMargin() * RiskPercent / 100.0) / 100.0, 2), MarketInfo(Symbol(), MODE_MINLOT)); return (l_lots_0); } int CheckOrdersCondition() { int l_count_0 = 0; for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) { OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_248) l_count_0 += 1000; if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_248) l_count_0 += 100; if (OrderType() == OP_BUYLIMIT && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_248) l_count_0 += 10; if (OrderType() == OP_SELLLIMIT && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_248) l_count_0++; } return (l_count_0); } void OpenSellLimit(double a_lots_0, double a_price_8, double a_price_16, double a_price_24, int a_magic_32) { int l_ticket_36; int l_count_44 = 0; if (!GlobalVariableCheck("InTrade")) { while (l_count_44 < 3) { GlobalVariableSet("InTrade", TimeCurrent()); l_ticket_36 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots_0, a_price_8, Slippage, a_price_16, a_price_24, "EA Order", a_magic_32, 0, Red); Print("OrderSend(" + Symbol() + ", OP_SELLLIMIT, " + DoubleToStr(a_lots_0, 2) + ", " + DoubleToStr(a_price_8, Digits) + ", 30, " + DoubleToStr(a_price_16, Digits) + ", " + DoubleToStr(a_price_24, Digits) + " ,\"EA Order\", " + a_magic_32 + " ,0,Red)=" + l_ticket_36); if (writelog == 1) Write("in function OpenBuyLimit OrderSend Executed , ticket =" + l_ticket_36); GlobalVariableDel("InTrade"); if (l_ticket_36 <= 0) { if (writelog == 1) Write("Error Accured : " + ErrorDescription(GetLastError()) + " BuyLimit @ " + a_price_8 + " SL @ " + a_price_16 + " TPFake @" + a_price_24); l_count_44++; } else l_count_44 = 3; } } } int OpenBuyLimit(double a_lots_0, double a_price_8, double a_price_16, double a_price_24, int a_magic_32) { int l_ticket_36; int l_count_44 = 0; if (!GlobalVariableCheck("InTrade")) { while (l_count_44 < 3) { GlobalVariableSet("InTrade", TimeCurrent()); l_ticket_36 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_0, a_price_8, Slippage, a_price_16, a_price_24, "EA Order", a_magic_32, 0, Red); Print("OrderSend(" + Symbol() + ", OP_BUYLIMIT, " + DoubleToStr(a_lots_0, 2) + ", " + DoubleToStr(a_price_8, Digits) + ", 30, " + DoubleToStr(a_price_16, Digits) + ", " + DoubleToStr(a_price_24, Digits) + " ,\"EA Order\", " + a_magic_32 + " ,0,Red)=" + l_ticket_36); if (writelog == 1) Write("in function OpenSellLimit OrderSend Executed , ticket =" + l_ticket_36); GlobalVariableDel("InTrade"); if (l_ticket_36 <= 0) { if (writelog == 1) Write("Error Accured : " + ErrorDescription(GetLastError()) + " BuyLimit @ " + a_price_8 + " SL @ " + a_price_16 + " TPFake @" + a_price_24); l_count_44++; } else l_count_44 = 3; } } return (0); } void DoBE(int ai_0) { for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) { OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_248) { if (OrderType() == OP_BUY) { if (Bid - OrderOpenPrice() > ai_0 * gd_268) { if (OrderStopLoss() < OrderOpenPrice()) { if (writelog == 1) Write("Movine StopLoss of Buy Order to BE+1"); OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + gd_268, OrderTakeProfit(), 255); } } } if (OrderType() == OP_SELL) { if (OrderOpenPrice() - Ask > ai_0 * gd_268) { if (OrderStopLoss() > OrderOpenPrice()) { if (writelog == 1) Write("Movine StopLoss of Buy Order to BE+1"); OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - gd_268, OrderTakeProfit(), 255); } } } } } } void DoTrail() { for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) { OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_248) { if (OrderType() == OP_BUY) { if (Bid - OrderOpenPrice() > gd_268 * TrailingStop) { if (OrderStopLoss() < Bid - gd_268 * TrailingStop) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid - gd_268 * TrailingStop, OrderTakeProfit(), 0, Green); return; } } } if (OrderType() == OP_SELL) { if (OrderOpenPrice() - Ask > gd_268 * TrailingStop) { if (OrderStopLoss() > Ask + gd_268 * TrailingStop || OrderStopLoss() == 0.0) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + gd_268 * TrailingStop, OrderTakeProfit(), 0, Red); return; } } } } } } int CloseOrder(int a_ticket_0, double a_lots_4, int ai_12) { int l_error_20; double l_price_28; if (ai_12 == 0) l_price_28 = MarketInfo(Symbol(), MODE_BID); if (ai_12 == 1) l_price_28 = MarketInfo(Symbol(), MODE_ASK); int l_digits_24 = MarketInfo(Symbol(), MODE_DIGITS); if (l_digits_24 > 0) l_price_28 = NormalizeDouble(l_price_28, l_digits_24); int l_count_16 = 0; while (l_count_16 < 3) { if (!OrderClose(a_ticket_0, a_lots_4, l_price_28, 3, Violet)) { l_error_20 = GetLastError(); Print(l_count_16, " Error closing order : (", l_error_20, ") " + ErrorDescription(l_error_20)); if (l_error_20 > 0/* NO_ERROR */) l_count_16++; } else l_count_16 = 3; } return (0); } bool CheckExitCondition(int ai_0, double ad_4) { switch (ai_0) { case 0: if (Bid >= ad_4 + TP * gd_268) return (TRUE); case 1: if (Ask <= ad_4 - TP * gd_268) return (TRUE); } return (FALSE); } int HandleOpenPositions() { for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol()) { if (OrderMagicNumber() == g_magic_248) { if (OrderType() == OP_BUY) if (CheckExitCondition(0, OrderOpenPrice())) CloseOrder(OrderTicket(), OrderLots(), 0); if (OrderType() == OP_SELL) if (CheckExitCondition(1, OrderOpenPrice())) CloseOrder(OrderTicket(), OrderLots(), 1); } } } return (0); } void DoModifyPendings() { for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) { OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_248 && OrderType() == OP_BUYLIMIT) { if (Bid > OrderOpenPrice() + PipsTrail * gd_268) { g_price_200 = OrderOpenPrice() + PipsTrail * gd_268; g_price_216 = g_price_200 - SL * gd_268; g_price_232 = g_price_200 + TPFake * gd_268; if (writelog == 1) Write("in function DoModifyPendings , SellLimit OrderModify Executed, Sell Stop was @ " + DoubleToStr(OrderOpenPrice(), 4) + " it changed to " + DoubleToStr(g_price_200, 4)); OrderModify(OrderTicket(), g_price_200, g_price_216, g_price_232, 0, Red); } } if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_248 && OrderType() == OP_SELLLIMIT) { if (OrderOpenPrice() - Ask > PipsTrail * gd_268) { g_price_192 = OrderOpenPrice() - PipsTrail * gd_268; g_price_208 = g_price_192 + SL * gd_268; g_price_224 = g_price_192 - TPFake * gd_268; if (writelog == 1) Write("in function DoModifyPendings , BuyLimit OrderModify Executed, Buy Stop was @ " + DoubleToStr(OrderOpenPrice(), 4) + " it changed to " + DoubleToStr(g_price_192, 4)); OrderModify(OrderTicket(), g_price_192, g_price_208, g_price_224, 0, Red); } } } } int Write(string as_0) { int l_file_8 = FileOpen(g_name_252, FILE_CSV|FILE_WRITE|FILE_READ, "/t"); FileSeek(l_file_8, 0, SEEK_END); FileWrite(l_file_8, as_0 + " Time " + TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS)); FileClose(l_file_8); return (0); } int start() { int li_20; string ls_0 = "2010.03.07"; int l_str2time_8 = StrToTime(ls_0); if (TimeCurrent() >= l_str2time_8) { Alert("This Robot Has Been Expired. Please contact http://www.forexsprinter.com for update."); return (0); } if (writelog == 1) g_name_252 = Symbol() + TradeLog + "-" + Month() + "-" + Day() + ".txt"; if (BEPips > 0) DoBE(BEPips); if (TrailingStop > 0) DoTrail(); int li_16 = CheckOrdersCondition() % 1000; Comment("\n" + "ForexSprinter" + "\n\nSELL LIMIT@ ", DoubleToStr(g_price_192, gd_276), " Stoploss @ ", DoubleToStr(g_price_208, gd_276), " TakeProfit @ ", DoubleToStr(g_price_224, gd_276), "\nBUY LIMIT @ ", DoubleToStr(g_price_200, gd_276), " StopLoss @ ", DoubleToStr(g_price_216, gd_276), " TakeProfit @ ", DoubleToStr(g_price_232, gd_276), "\nMoney Management : ", g_bool_284, " RiskPercent: ", RiskPercent, " Lots : ", LotsOptimized()); if (writelog == 1) Write("Modifying Orders, OrdersCondition=" + li_16 + " SecOfDay=" + li_20); HandleOpenPositions(); if (li_16 != 11) gd_240 = NormalizeDouble(MathAbs(Ask - Bid), gd_276); if (li_16 % 10 == 0) { g_price_192 = Bid + Pipsaway * gd_268; g_price_208 = ValidStopLoss(1, g_price_192, g_price_192 + SL * gd_268); g_price_224 = g_price_192 - TPFake * gd_268; } if (li_16 < 2) { g_price_200 = Ask - Pipsaway * gd_268; g_price_216 = ValidStopLoss(0, g_price_200, g_price_200 - SL * gd_268); g_price_232 = g_price_200 + TPFake * gd_268; } if (li_16 == 0) { if (writelog == 1) Write("Opening BuyLimit & SellLimit, OrdersCondition=" + li_16); OpenBuyLimit(LotsOptimized(), g_price_200, g_price_216, g_price_232, g_magic_248); OpenSellLimit(LotsOptimized(), g_price_192, g_price_208, g_price_224, g_magic_248); } if (li_16 == 10) { if (writelog == 1) Write("Opening SellLimit, OrdersCondition=" + li_16); OpenSellLimit(LotsOptimized(), g_price_192, g_price_208, g_price_224, g_magic_248); } if (li_16 == 1) { if (writelog == 1) Write("Opening BuyLimit , OrdersCondition=" + li_16); OpenBuyLimit(LotsOptimized(), g_price_200, g_price_216, g_price_232, g_magic_248); } DoModifyPendings(); return (0); } double ValidStopLoss(int ai_0, double ad_4, double ad_12) { double l_point_28 = MarketInfo(Symbol(), MODE_POINT); double ld_20 = MarketInfo(Symbol(), MODE_STOPLEVEL); if (ai_0 == 0) if (ad_4 - ad_12 < ld_20 * l_point_28) ad_12 = ad_4 - ld_20 * l_point_28; if (ai_0 == 1) if (ad_12 - ad_4 < ld_20 * l_point_28) ad_12 = ad_4 + ld_20 * l_point_28; return (ad_12); } string ErrorDescription(int ai_0) { string ls_ret_4; switch (ai_0) { case 0: case 1: ls_ret_4 = "no error"; break; case 2: ls_ret_4 = "common error"; break; case 3: ls_ret_4 = "invalid trade parameters"; break; case 4: ls_ret_4 = "trade server is busy"; break; case 5: ls_ret_4 = "old version of the client terminal"; break; case 6: ls_ret_4 = "no connection with trade server"; break; case 7: ls_ret_4 = "not enough rights"; break; case 8: ls_ret_4 = "too frequent requests"; break; case 9: ls_ret_4 = "malfunctional trade operation"; break; case 64: ls_ret_4 = "account disabled"; break; case 65: ls_ret_4 = "invalid account"; break; case 128: ls_ret_4 = "trade timeout"; break; case 129: ls_ret_4 = "invalid price"; break; case 130: ls_ret_4 = "invalid stops"; break; case 131: ls_ret_4 = "invalid trade volume"; break; case 132: ls_ret_4 = "market is closed"; break; case 133: ls_ret_4 = "trade is disabled"; break; case 134: ls_ret_4 = "not enough money"; break; case 135: ls_ret_4 = "price changed"; break; case 136: ls_ret_4 = "off quotes"; break; case 137: ls_ret_4 = "broker is busy"; break; case 138: ls_ret_4 = "requote"; break; case 139: ls_ret_4 = "order is locked"; break; case 140: ls_ret_4 = "long positions only allowed"; break; case 141: ls_ret_4 = "too many requests"; break; case 145: ls_ret_4 = "modification denied because order too close to market"; break; case 146: ls_ret_4 = "trade context is busy"; break; case 4000: ls_ret_4 = "no error"; break; case 4001: ls_ret_4 = "wrong function pointer"; break; case 4002: ls_ret_4 = "array index is out of range"; break; case 4003: ls_ret_4 = "no memory for function call stack"; break; case 4004: ls_ret_4 = "recursive stack overflow"; break; case 4005: ls_ret_4 = "not enough stack for parameter"; break; case 4006: ls_ret_4 = "no memory for parameter string"; break; case 4007: ls_ret_4 = "no memory for temp string"; break; case 4008: ls_ret_4 = "not initialized string"; break; case 4009: ls_ret_4 = "not initialized string in array"; break; case 4010: ls_ret_4 = "no memory for array\' string"; break; case 4011: ls_ret_4 = "too long string"; break; case 4012: ls_ret_4 = "remainder from zero divide"; break; case 4013: ls_ret_4 = "zero divide"; break; case 4014: ls_ret_4 = "unknown command"; break; case 4015: ls_ret_4 = "wrong jump (never generated error)"; break; case 4016: ls_ret_4 = "not initialized array"; break; case 4017: ls_ret_4 = "dll calls are not allowed"; break; case 4018: ls_ret_4 = "cannot load library"; break; case 4019: ls_ret_4 = "cannot call function"; break; case 4020: ls_ret_4 = "expert function calls are not allowed"; break; case 4021: ls_ret_4 = "not enough memory for temp string returned from function"; break; case 4022: ls_ret_4 = "system is busy (never generated error)"; break; case 4050: ls_ret_4 = "invalid function parameters count"; break; case 4051: ls_ret_4 = "invalid function parameter value"; break; case 4052: ls_ret_4 = "string function internal error"; break; case 4053: ls_ret_4 = "some array error"; break; case 4054: ls_ret_4 = "incorrect series array using"; break; case 4055: ls_ret_4 = "custom indicator error"; break; case 4056: ls_ret_4 = "arrays are incompatible"; break; case 4057: ls_ret_4 = "global variables processing error"; break; case 4058: ls_ret_4 = "global variable not found"; break; case 4059: ls_ret_4 = "function is not allowed in testing mode"; break; case 4060: ls_ret_4 = "function is not confirmed"; break; case 4061: ls_ret_4 = "send mail error"; break; case 4062: ls_ret_4 = "string parameter expected"; break; case 4063: ls_ret_4 = "integer parameter expected"; break; case 4064: ls_ret_4 = "double parameter expected"; break; case 4065: ls_ret_4 = "array as parameter expected"; break; case 4066: ls_ret_4 = "requested history data in update state"; break; case 4099: ls_ret_4 = "end of file"; break; case 4100: ls_ret_4 = "some file error"; break; case 4101: ls_ret_4 = "wrong file name"; break; case 4102: ls_ret_4 = "too many opened files"; break; case 4103: ls_ret_4 = "cannot open file"; break; case 4104: ls_ret_4 = "incompatible access to a file"; break; case 4105: ls_ret_4 = "no order selected"; break; case 4106: ls_ret_4 = "unknown symbol"; break; case 4107: ls_ret_4 = "invalid price parameter for trade function"; break; case 4108: ls_ret_4 = "invalid ticket"; break; case 4109: ls_ret_4 = "trade is not allowed"; break; case 4110: ls_ret_4 = "longs are not allowed"; break; case 4111: ls_ret_4 = "shorts are not allowed"; break; case 4200: ls_ret_4 = "object is already exist"; break; case 4201: ls_ret_4 = "unknown object property"; break; case 4202: ls_ret_4 = "object is not exist"; break; case 4203: ls_ret_4 = "unknown object type"; break; case 4204: ls_ret_4 = "no object name"; break; case 4205: ls_ret_4 = "object coordinates error"; break; case 4206: ls_ret_4 = "no specified subwindow"; break; default: ls_ret_4 = "unknown error"; } return (ls_ret_4); } Quote Link to comment Share on other sites More sharing options...
Iceman777 Posted February 8, 2010 Author Report Share Posted February 8, 2010 Re: can someone please add hidden SL and TP to these two EA's? And here is the Slave part of the Genius EA - Needs TP and SL hidden #include <stdlib.mqh> //string gs_76 = ""; string g_comment_84 = ""; //string gs_228 = ""; extern int Satefy_Margin = 0.2; extern double Order_Size = 1.0; extern int Order_Count = 1; extern double Risk_Management = 10.0; extern bool Use_ECN = true; extern int Extra_StopLoss = 0; string gs_268 = "Slave"; int gi_276 = 2; double g_pips_280 = 4.0; double gd_288 = 1.0; bool gi_296 = FALSE; extern bool Debug_Mode = FALSE; double gd_304 = 10.0; double gd_312 = 0.0; bool gi_320 = FALSE; int gi_324 = 1; string g_symbol_328 = ""; string gs_336 = ""; double gd_344 = -1.0; int gi_352 = 110; int gi_356 = 0; int gi_360 = -1; double gd_364; double gd_372; double gd_380 = 1.0; string gs_388 = "MetaTrader (MASTER)\\experts\\files"; int init() { double ld_8; int l_file_60; double ld_64; int lia_112[20]; int lia_116[20]; int li_unused_124; int li_unused_128; double ld_132; int li_140; string ls_144; string ls_152; double l_str2dbl_160; double ld_168; double ld_176; int li_184; int li_188; int li_192; /* if (StringLen(gs_228) != 0 && StringFind(AccountCompany(), gs_228) == -1) { Print("Invalid Account Company"); return (0); } if (StringLen(gs_76) != 0 && StringFind(AccountName(), gs_76) == -1) { Print("Invalid Account Name"); return (0); } */ gd_304 = (1 - Risk_Management / 100.0) * AccountBalance(); gi_352 = 0; for (int l_str_len_0 = StringLen(gs_268); l_str_len_0 > 0; l_str_len_0--) gi_352 += StringGetChar(gs_268, l_str_len_0); g_symbol_328 = Symbol(); Print("started: currencyPair=" + g_symbol_328); int li_4 = TimeLocal(); li_4 -= 18000; double l_stoplevel_16 = MarketInfo(g_symbol_328, MODE_STOPLEVEL); gd_344 = l_stoplevel_16 + Extra_StopLoss; double l_point_24 = MarketInfo(g_symbol_328, MODE_POINT); double ld_32 = (Satefy_Margin + 2.0 * ld_8) * l_point_24; string ls_40 = ""; ls_40 = ""; ls_40 = "" + TimeYear(li_4); ls_40 = ls_40 + "-" + TimeMonth(li_4); ls_40 = ls_40 + "-" + TimeDay(li_4); string l_name_48 = gs_388 + "\\" + "log__" + StringSubstr(g_symbol_328, 0, 6) + "_" + ls_40 + ".csv"; int li_56 = -1; gd_364 = MarketInfo(Symbol(), MODE_ASK); gd_372 = MarketInfo(Symbol(), MODE_BID); double ld_72 = gd_372 + (gd_364 - gd_372) / 2.0; double ld_80 = -1; int li_88 = -1; double ld_92 = -1; int li_100 = 0; string ls_unused_104 = ""; bool li_120 = FALSE; if (MarketInfo("GBPUSD", MODE_POINT) < 0.00009) li_120 = TRUE; while (true) { if (gd_364 != MarketInfo(Symbol(), MODE_ASK) + gd_312 * l_point_24) { gd_364 = MarketInfo(Symbol(), MODE_ASK) + gd_312 * l_point_24; gd_372 = MarketInfo(Symbol(), MODE_BID) + gd_312 * l_point_24; gi_356++; } li_4 = TimeLocal(); li_4 -= 18000; ls_40 = ""; ls_40 = "" + TimeYear(li_4); ls_40 = ls_40 + "-" + TimeMonth(li_4); ls_40 = ls_40 + "-" + TimeDay(li_4); l_name_48 = gs_388 + "\\" + "log__" + StringSubstr(g_symbol_328, 0, 6) + "_" + ls_40 + ".csv"; ld_8 = MathRound((MarketInfo(g_symbol_328, MODE_ASK) - MarketInfo(g_symbol_328, MODE_BID)) / l_point_24); li_unused_124 = MathRound((MarketInfo(g_symbol_328, MODE_ASK) - MarketInfo(g_symbol_328, MODE_BID)) / l_point_24); li_unused_128 = MarketInfo(g_symbol_328, MODE_SPREAD); ld_32 = (Satefy_Margin + 2.0 * ld_8) * l_point_24; ld_132 = gi_324 * l_point_24; l_file_60 = FileOpen(l_name_48, FILE_CSV|FILE_READ); if (l_file_60 == -1) { Sleep(10); continue; } if (li_56 != FileSize(l_file_60) || gi_356 != gi_360) { if (li_56 != FileSize(l_file_60)) { li_140 = FileSize(l_file_60); if (li_56 != -1) { gi_360 = gi_356; ld_64 = gd_372 + (gd_364 - gd_372) / 2.0; if (li_120) ld_64 = 10.0 * MathRound(ld_64 / l_point_24 / 10.0) * l_point_24; FileSeek(l_file_60, li_56, SEEK_SET); ls_144 = FileReadString(l_file_60, li_140 - li_56); ls_152 = FileReadString(l_file_60, li_140 - li_56); l_str2dbl_160 = StrToDouble(ls_152); if (l_str2dbl_160 == 0.0) { Print("no price"); FileClose(l_file_60); continue; } } ld_168 = MathAbs(ld_64 - l_str2dbl_160); ld_176 = MathAbs(ld_72 - ld_64); li_184 = (ld_64 - l_str2dbl_160) / l_point_24; if (li_120) li_184 = MathRound(li_184 / 10); li_184 += 10; li_188 = ld_8; lia_116[li_188]++; if (li_184 < ArraySize(lia_112) && li_184 >= 0) lia_112[li_184]++; li_192 = 0; for (int l_index_196 = 0; l_index_196 < ArraySize(lia_112); l_index_196++) if (lia_112[l_index_196] > lia_112[li_192]) li_192 = l_index_196; Print("Market Analysis in Progress"); if (Debug_Mode == TRUE) { Print("l=" + ((l_str2dbl_160 - ld_64)) + ", m=" + l_str2dbl_160 + ", s=" + ld_64 + ", mil=" + ld_32 + ", mol=" + ((li_192 - 10)) + ", cml=" + lia_112[li_192] + ", lp=" + ((li_184 - 10)) + ", ed=" + li_120 + ",cl:," + gd_312); } if (ld_168 > ld_132 || gd_380 > ld_132) { log(",masterPrice:," + l_str2dbl_160 + ",slaveMarketPrice:," + ld_64 + ",lag:," + ((ld_64 - l_str2dbl_160)) + ",slaveJump:," + ld_176 + ",comment:," + g_comment_84 + ",cl:," + gd_312); } gd_380 = ld_168; if (li_184 - ArraySize(lia_112) / 2 > 9 || li_184 - ArraySize(lia_112) / 2 < -9) { gi_320 = FALSE; gd_312 = 0; for (int l_index_200 = 0; l_index_200 < ArraySize(lia_112); l_index_200++) lia_112[l_index_200] = 0; } if ((lia_112[li_192] > 10 && gi_320 == FALSE) || lia_112[li_192] > 20) { gd_312 -= li_192 - 10; gi_320 = TRUE; for (int l_index_204 = 0; l_index_204 < ArraySize(lia_112); l_index_204++) lia_112[l_index_204] = 0; } if (ld_168 >= ld_32 && ld_176 == 0.0 && ld_80 == -1.0 && gi_320) { log(",PlaceOrder:," + l_str2dbl_160 + ",slaveMarketPrice:," + ld_64 + ",lag:," + ((ld_64 - l_str2dbl_160)) + ",O" + ",comment:," + g_comment_84); if (Debug_Mode == TRUE) Print(",PlaceOrder:," + l_str2dbl_160 + ",slaveMarketPrice:," + ld_64 + ",lag:," + ((ld_64 - l_str2dbl_160)) + ",O" + ",comment:," + g_comment_84); ld_92 = gd_364; ld_64 = gd_372 + (gd_364 - gd_372) / 2.0; li_100 = 0; while (l_str2dbl_160 > ld_64 && ld_168 > ld_32 && li_100 < 1) { log(",,,,,,spreadNow=" + MarketInfo(g_symbol_328, MODE_SPREAD) + "spreadWas=" + ld_8); if (gi_296) Order_Size = getMaxOrder_Size(0); li_100 = sendOrder(g_symbol_328, OP_BUY, Order_Size, ld_92 - gd_312 * l_point_24, ld_92 - gd_312 * l_point_24 - (gd_344 + ld_8) * l_point_24, li_100); if (li_100 == 0) { for (int li_208 = 1; li_208 < Order_Count; li_208++) sendOrder(g_symbol_328, OP_BUY, Order_Size, ld_92, ld_92 - (gd_344 + ld_8) * l_point_24, li_100); ld_80 = ld_92; li_88 = 0; break; } ld_64 = gd_372 + (gd_364 - gd_372) / 2.0; ld_168 = MathAbs(ld_64 - l_str2dbl_160); } ld_92 = gd_372; ld_64 = gd_372 + (gd_364 - gd_372) / 2.0; li_100 = 0; while (l_str2dbl_160 < ld_64 && ld_168 > ld_32 && li_100 < 1) { log(",,,,,,,spreadNow=" + MarketInfo(g_symbol_328, MODE_SPREAD) + "spreadWas=" + ld_8); if (gi_296) Order_Size = getMaxOrder_Size(1); li_100 = sendOrder(g_symbol_328, OP_SELL, Order_Size, ld_92 - gd_312 * l_point_24, ld_92 - gd_312 * l_point_24 + (gd_344 + ld_8) * l_point_24, li_100); if (li_100 == 0) { for (int li_212 = 1; li_212 < Order_Count; li_212++) sendOrder(g_symbol_328, OP_SELL, Order_Size, ld_92, ld_92 + (gd_344 + ld_8) * l_point_24, li_100); ld_80 = ld_92; li_88 = 1; break; } ld_64 = gd_372 + (gd_364 - gd_372) / 2.0; ld_168 = MathAbs(ld_64 - l_str2dbl_160); } if (ld_80 != -1.0) Print("Placed: orderOpenPrice=" + ld_80); } if (ld_80 != -1.0) { if ((l_str2dbl_160 - ld_64 <= l_point_24 * gi_276 && li_88 == 0) || (ld_64 - l_str2dbl_160 <= l_point_24 * gi_276 && li_88 == 1) || (ld_80 - ld_64 > l_point_24 * g_pips_280 && li_88 == 0) || (ld_64 - ld_80 > l_point_24 * g_pips_280 && li_88 == 1)) { log(",CloseOrder:," + l_str2dbl_160 + ",slaveMarketPrice:," + ld_64 + ",lag:," + ((ld_64 - l_str2dbl_160)) + ",C" + ",comment:," + g_comment_84); for (int li_216 = 600; li_216 != 0; li_216--) { if (closeOpenOrders(g_symbol_328, encript(gi_352)) == 1) break; Sleep(100); } ld_80 = -1; } } if (ld_64 != ld_72) ld_72 = ld_64; } li_56 = li_140; } FileClose(l_file_60); Sleep(100); } return /*(WARN)*/; } int deinit() { return (0); } int start() { return (0); } int encript(int ai_0) { for (int l_str_len_4 = StringLen(gs_268); l_str_len_4 > 0; l_str_len_4--) ai_0 += StringGetChar(gs_268, l_str_len_4); return (ai_0); } int closeOpenOrders(string as_0, int a_magic_8) { int l_ord_close_12; int l_cmd_20; double l_price_32; int l_error_40; bool li_ret_16 = TRUE; int l_ord_total_24 = OrdersTotal(); for (int l_pos_28 = l_ord_total_24 - 1; l_pos_28 >= 0; l_pos_28--) { if (OrderSelect(l_pos_28, SELECT_BY_POS, MODE_TRADES)) { l_cmd_20 = OrderType(); if (!(l_cmd_20 == OP_BUY || l_cmd_20 == OP_SELL)) continue; OrderPrint(); if (!(OrderMagicNumber() == a_magic_8 && StringFind(OrderSymbol(), as_0, 0) != -1)) continue; while (true) { if (OrderType() == OP_BUY) l_price_32 = MarketInfo(as_0, MODE_BID); else l_price_32 = MarketInfo(as_0, MODE_ASK); l_ord_close_12 = OrderClose(OrderTicket(), OrderLots(), l_price_32, 3, CLR_NONE); if (l_ord_close_12 != 1) { l_error_40 = GetLastError(); Print("Error = ", ErrorDescription(l_error_40), " code=", l_error_40); log("Close error," + l_error_40 + ",price=," + l_price_32 + ",currencyPair=," + as_0); li_ret_16 = FALSE; } else l_error_40 = 0; if (l_error_40 != 135/* PRICE_CHANGED */) break; RefreshRates(); } } Print("Error when order select ", GetLastError()); break; } return (li_ret_16); } int sendOrder(string a_symbol_0, int a_cmd_8, double a_lots_12, double a_price_20, double a_price_28, int ai_36) { int l_error_52; if (AccountBalance() < gd_304) return (ai_36 + 10); double l_point_40 = MarketInfo(a_symbol_0, MODE_POINT); int l_slippage_56 = 0; log("send order" + ",currencyPair=" + a_symbol_0 + ",command=" + a_cmd_8 + ",Order_Size=" + a_lots_12 + ",currencyPrice=" + a_price_20 + ",stopLoss=" + a_price_28 + ",takeProfit=" + 0 + ",magicNumber=" + gi_352 + ",comment:," + g_comment_84); double l_price_60 = a_price_28; if (Use_ECN) a_price_28 = 0; int l_ticket_48 = OrderSend(a_symbol_0, a_cmd_8, a_lots_12, a_price_20, l_slippage_56, a_price_28, 0, g_comment_84, encript(gi_352), 0, Green); if (l_ticket_48 <= 0) { l_error_52 = GetLastError(); log("Error:send order" + ",error code=" + l_error_52); Print("send order error :", ErrorDescription(l_error_52), " code=", l_error_52); return (ai_36 + 1); } if (Use_ECN) addStopLoss(l_ticket_48, l_price_60); return (0); } void addStopLoss(int a_ticket_0, double a_price_4) { OrderSelect(a_ticket_0, SELECT_BY_TICKET); bool l_bool_12 = FALSE; for (int l_count_16 = 0; l_count_16 < 5 && l_bool_12 == FALSE; l_count_16++) { l_bool_12 = OrderModify(OrderTicket(), OrderOpenPrice(), a_price_4, OrderTakeProfit(), 0, Blue); if (l_bool_12 == FALSE) Sleep(300); } } double getFreeMarginInBaseCurrency() { double l_free_magrin_0 = AccountFreeMargin(); return (convertToBaseCurrency(l_free_magrin_0)); } double convertToBaseCurrency(double ad_0) { string ls_8 = StringSubstr(g_symbol_328, 3, 3); if (StringFind(AccountCurrency(), ls_8, 0) == -1) { if (MarketInfo(ls_8 + AccountCurrency() + gs_336, MODE_ASK) != 0.0) ad_0 /= MarketInfo(ls_8 + AccountCurrency() + gs_336, MODE_ASK); else ad_0 /= 1 / MarketInfo(AccountCurrency() + ls_8 + gs_336, MODE_ASK); } return (ad_0); } bool isFixedMaxOrder_Size() { if (MarketInfo("AUDUSD" + gs_336, MODE_MARGINREQUIRED) == MarketInfo("USDJPY" + gs_336, MODE_MARGINREQUIRED) && MarketInfo("AUDUSD" + gs_336, MODE_MARGINREQUIRED) == MarketInfo("EURUSD" + gs_336, MODE_MARGINREQUIRED)) return (TRUE); return (FALSE); } double getMaxOrder_Size(int ai_0) { double ld_16; if (StringLen(g_symbol_328) == 7) gs_336 = "."; int l_stoplevel_4 = MarketInfo(g_symbol_328, MODE_STOPLEVEL); double l_point_8 = MarketInfo(g_symbol_328, MODE_POINT); if (ai_0 == 4) ld_16 = MarketInfo(g_symbol_328, MODE_ASK) + l_stoplevel_4 * l_point_8; if (ai_0 == 5) ld_16 = MarketInfo(g_symbol_328, MODE_BID) - l_stoplevel_4 * l_point_8; if (ai_0 == 0) ld_16 = MarketInfo(g_symbol_328, MODE_ASK); if (ai_0 == 1) ld_16 = MarketInfo(g_symbol_328, MODE_BID); double ld_24 = getFreeMarginInBaseCurrency(); int l_leverage_32 = AccountLeverage(); int li_36 = 1 / MarketInfo(g_symbol_328, MODE_LOTSTEP); int li_40 = 100000; if (isFixedMaxOrder_Size()) { ld_16 = convertToBaseCurrency(MarketInfo(g_symbol_328, MODE_MARGINREQUIRED)); l_leverage_32 = 100; li_40 = 100; } double ld_ret_44 = MathFloor(gd_288 * li_36 * (ld_24 / ld_16 / (li_40 / 100) * (l_leverage_32 / 100))) / li_36; return (ld_ret_44); } void log(string as_unused_0) { } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.