#property copyright "Copyright © 2009, FXPROMaker Trading Solutions, http://www.fxpromaker.com" #property link "http://www.fxpromaker.com" extern double Lots = 0.01; extern bool Compouding = FALSE; extern int CompoundEach = 40000; double g_lots_92 = 0.0; extern int TakeProfit = 30; extern int StopLoss = 400; bool gi_108 = FALSE; int gi_112 = 120; int gi_116 = 90; int gi_120 = 60; int gi_124 = 30; int gi_128 = 50; int gi_132 = 50; int gi_136 = 50; int gi_140 = 50; int gi_144 = 50; int gi_148 = 48; int gi_152 = 48; int gi_156 = 48; int gi_160 = 48; int gi_164 = 55; int gi_168 = 68; int gi_172 = 81; int gi_176 = 100; int gi_180 = 115; int gi_184 = 130; int gi_188 = 145; int gi_192 = 160; int gi_196 = 150; int gi_200 = 165; int gi_204 = 165; int gi_208 = 165; int gi_212 = 165; int gi_216 = 165; int gi_220 = 165; int gi_224 = 165; int g_slippage_228 = 3; int gi_232 = 2; extern int StartHour = 0; extern int EndHour = 24; extern int Magic = 111; extern bool CloseAllNow = FALSE; extern int BrokerMode = 1; extern int FridayCloseTime = 24; int g_digits_260 = 0; int gi_264 = 928195200; int gi_268 = D'28.07.2009 04:30'; string gs_272 = "This version is expired. Visit www.fxpromaker.com"; string gs_280 = "This EA does not trade from December, 20 till January, 7"; string gs_288 = "Invalid Account. Visit www.fxpromaker.com"; string gs_296 = "We recommend you to trade on USDJPY only"; string gs_304 = ""; int g_datetime_312 = 0; double g_ask_316 = 0.0; double g_bid_324 = 0.0; int gi_332 = 0; int gi_336 = 67; double gd_340 = 0.0; double gd_348 = 0.0; int g_count_356 = 0; int g_count_360 = 0; string g_comment_364 = ""; string g_comment_372 = ""; int init() { if (!IsDemo() && !IsTesting()) { Alert(gs_288); return (-1); } if (StringSubstr(Symbol(), 0, 6) != "USDJPY") { Alert(gs_296); return (-1); } if (Digits == 3 && StringSubstr(Symbol(), 0, 6) == "USDJPY") { if (g_digits_260 != Digits) ChangeParameters(); if (TakeProfit == 30) TakeProfit = 10 * TakeProfit; if (StopLoss == 400) StopLoss = 10 * StopLoss; } g_digits_260 = Digits; g_ask_316 = Ask; g_bid_324 = Bid; gi_332 = 0; g_datetime_312 = 0; g_lots_92 = Lots; return (1); } int start() { int li_28; int l_ticket_32; double l_price_68; double l_price_76; double l_price_84; double l_lots_92; double l_pips_156; double l_pips_164; double l_price_188; double l_price_196; double l_price_204; bool l_bool_300; double ld_unused_304; double ld_unused_312; double l_lotstep_340; if (!IsDemo() && !IsTesting()) { Comment(gs_288); return (-1); } if (StringSubstr(Symbol(), 0, 6) != "USDJPY") { Comment(gs_296); return (-1); } if (CloseAllNow == TRUE) { for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); if (StringSubstr(OrderSymbol(), 0, 6) == StringSubstr(Symbol(), 0, 6) || BrokerMode == 3 && OrderMagicNumber() == Magic) { if (OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 5, CLR_NONE); if (OrderType() != OP_BUY && OrderType() != OP_SELL) OrderDelete(OrderTicket()); } } return (0); } if (g_digits_260 != Digits) { Alert("Attention! Your quotes were changed by your broker!"); if (Digits == 3 && StringSubstr(Symbol(), 0, 6) == "USDJPY") { ChangeParameters(); TakeProfit = 10 * TakeProfit; StopLoss = 10 * StopLoss; } g_digits_260 = Digits; } if (g_ask_316 < Ask) g_ask_316 = Ask; if (g_bid_324 > Bid) g_bid_324 = Bid; if (Ask < g_ask_316 - gi_336 * Point && gi_332 >= 0) { g_bid_324 = Bid; gi_332 = -1; } if (Bid > g_bid_324 + gi_336 * Point && gi_332 <= 0) { g_ask_316 = Ask; gi_332 = 1; } if (TimeCurrent() - g_datetime_312 >= 3600) { g_ask_316 = Ask; g_bid_324 = Bid; gi_332 = 0; gs_304 = ""; } g_datetime_312 = TimeCurrent(); int l_ticket_4 = 0; int l_ticket_8 = 0; int l_ticket_12 = 0; int l_ticket_16 = 0; int l_ticket_20 = 0; int l_ticket_24 = 0; double l_ord_lots_36 = 0; double l_ord_lots_44 = 0; double l_ord_open_price_52 = 0; double l_ord_open_price_60 = 0; double l_ord_takeprofit_100 = 0; double l_ord_takeprofit_108 = 0; double l_ord_lots_116 = 0; double l_ord_lots_124 = 0; double l_ord_lots_132 = 0; double l_ord_lots_140 = 0; double ld_172 = 0; double ld_180 = 0; string ls_212 = ""; string ls_220 = ""; string ls_228 = ""; string ls_236 = ""; string ls_244 = ""; string ls_252 = ""; string ls_260 = ""; string ls_268 = ""; string ls_276 = ""; string ls_284 = ""; string ls_292 = ""; int li_unused_320 = 0; int li_unused_324 = 0; if (iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 0) > iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1)) li_28 = 2; if (iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 0) < iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1)) li_28 = 1; gd_340 = 0; gd_348 = 0; g_count_356 = 0; g_count_360 = 0; g_comment_364 = ""; g_comment_372 = ""; for (int l_pos_328 = 0; l_pos_328 < OrdersTotal(); l_pos_328++) { OrderSelect(l_pos_328, SELECT_BY_POS, MODE_TRADES); if (StringSubstr(OrderSymbol(), 0, 6) == StringSubstr(Symbol(), 0, 6) || BrokerMode == 3 && OrderMagicNumber() == Magic) { if (OrderType() == OP_BUY && OrderLots() > l_ord_lots_36) { l_ord_lots_36 = OrderLots(); l_ord_open_price_52 = OrderOpenPrice(); l_ticket_4 = OrderTicket(); l_ord_takeprofit_108 = OrderTakeProfit(); g_comment_364 = OrderComment(); GetCommentBuy(); } if (OrderType() == OP_SELL && OrderLots() > l_ord_lots_44) { l_ord_lots_44 = OrderLots(); l_ord_open_price_60 = OrderOpenPrice(); l_ticket_8 = OrderTicket(); l_ord_takeprofit_100 = OrderTakeProfit(); g_comment_372 = OrderComment(); GetCommentSell(); } if (OrderType() == OP_BUYLIMIT) { l_ticket_12 = OrderTicket(); l_ord_lots_132 = OrderLots(); } if (OrderType() == OP_SELLLIMIT) { l_ticket_16 = OrderTicket(); l_ord_lots_140 = OrderLots(); } if (OrderType() == OP_BUYSTOP) { l_ticket_20 = OrderTicket(); l_ord_lots_116 = OrderLots(); } if (OrderType() == OP_SELLSTOP) { l_ticket_24 = OrderTicket(); l_ord_lots_124 = OrderLots(); } } } double l_minlot_332 = MarketInfo(Symbol(), MODE_MINLOT); if (Compouding == TRUE) { l_lotstep_340 = MarketInfo(Symbol(), MODE_LOTSTEP); Lots = NormalizeDouble(l_lotstep_340 * MathFloor(AccountBalance() * g_lots_92 / (CompoundEach * l_lotstep_340)), gi_232); if (Lots < l_minlot_332 && l_minlot_332 == 0.01 && AccountBalance() * g_lots_92 / CompoundEach > 0.0095) Lots = 0.01; if (Lots < l_minlot_332 && l_minlot_332 == 0.1 && AccountBalance() * g_lots_92 / CompoundEach > 0.095) Lots = 0.1; } if (Lots < l_minlot_332) Alert("Minimal lotsize you can open with this broker is " + l_minlot_332); if (l_ticket_4 == 0 && l_ticket_12 != 0) return (OrderDelete(l_ticket_12)); if (l_ticket_4 == 0 && l_ticket_20 != 0) return (OrderDelete(l_ticket_20)); if (l_ticket_8 == 0 && l_ticket_16 != 0) return (OrderDelete(l_ticket_16)); if (l_ticket_8 == 0 && l_ticket_24 != 0) return (OrderDelete(l_ticket_24)); if (l_ticket_4 > 0 && l_ord_lots_36 == gd_340) { OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES); if (Ask < l_ord_open_price_52 - 30.0 * Point && NormalizeDouble(l_ord_takeprofit_108, Digits) > NormalizeDouble(l_ord_open_price_52 + (gi_128 - 30) * Point, Digits) && g_count_356 <= 2) OrderModify(l_ticket_4, OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(l_ord_open_price_52 + (gi_128 - 30) * Point, Digits), 0, CLR_NONE); if (Ask < l_ord_open_price_52 - 60.0 * Point && NormalizeDouble(l_ord_takeprofit_108, Digits) > NormalizeDouble(l_ord_open_price_52 + (gi_128 - 60) * Point, Digits) && g_count_356 <= 1) OrderModify(l_ticket_4, OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(l_ord_open_price_52 + (gi_128 - 60) * Point, Digits), 0, CLR_NONE); if (Ask < l_ord_open_price_52 - 90.0 * Point && NormalizeDouble(l_ord_takeprofit_108, Digits) > NormalizeDouble(l_ord_open_price_52 + (gi_128 - 90) * Point, Digits) && g_count_356 == 0) OrderModify(l_ticket_4, OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(l_ord_open_price_52 + (gi_128 - 90) * Point, Digits), 0, CLR_NONE); } if (l_ticket_4 == 0 && l_ticket_12 == 0) { if (TimeCurrent() >= gi_264 && TimeCurrent() <= gi_268) { if ((Month() > 1 && Month() < 12) || (Month() == 1 && Day() >= 7) || (Month() == 12 && Day() < 20)) { l_price_76 = Ask - StopLoss * Point; if (StopLoss <= 0) l_price_76 = 0; l_price_84 = Ask + TakeProfit * Point; if ((StartHour < EndHour && TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) || (StartHour > EndHour && TimeHour(TimeCurrent()) >= StartHour || TimeHour(TimeCurrent()) < EndHour)) { if (DayOfWeek() != 5 || Hour() < FridayCloseTime) { if (l_ticket_8 == 0 && gs_304 == "Sell" || (gs_304 == "" && li_28 == 2)) { if (gs_304 == "") g_count_356 = 0; else { g_count_356 = MathFloor((g_ask_316 - Ask) / (gi_124 * Point)); if (g_count_356 < 0 || g_count_356 > 9) g_count_356 = 0; } gd_340 = Lots; g_comment_364 = g_count_356 + "," + gd_340; if (g_count_356 <= 3) l_lots_92 = Lots; else l_lots_92 = NormalizeDouble(Lots * MathPow(2, g_count_356 - 3), gi_232); if (AccountFreeMarginCheck(Symbol(), OP_BUY, l_lots_92) >= 0.0) { if (BrokerMode != 2 && BrokerMode != 3) OrderSend(Symbol(), OP_BUY, l_lots_92, Ask, g_slippage_228, l_price_76, l_price_84, g_comment_364, Magic, 0, CLR_NONE); else { l_ticket_32 = OrderSend(Symbol(), OP_BUY, l_lots_92, Ask, g_slippage_228, 0, 0, g_comment_364, Magic, 0, CLR_NONE); if (l_ticket_32 > 0) { l_bool_300 = OrderModify(l_ticket_32, OrderOpenPrice(), l_price_76, l_price_84, 0, CLR_NONE); if (l_bool_300 == FALSE) Print("Error modifying BUY order : ", GetLastError()); } } } else ls_228 = "BUY, " + DoubleToStr(l_lots_92, 2) + " lots. "; gs_304 = "Buy"; return (0); } } } } ls_220 = gs_280; } else ls_220 = gs_272; } if (l_ticket_8 > 0 && l_ord_lots_44 == gd_348) { OrderSelect(l_ticket_8, SELECT_BY_TICKET, MODE_TRADES); if (Bid > l_ord_open_price_60 + 30.0 * Point && NormalizeDouble(l_ord_takeprofit_100, Digits) < NormalizeDouble(l_ord_open_price_60 - (gi_128 - 30) * Point, Digits) && g_count_360 <= 2) OrderModify(l_ticket_8, OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(l_ord_open_price_60 - (gi_128 - 30) * Point, Digits), 0, CLR_NONE); if (Bid > l_ord_open_price_60 + 60.0 * Point && NormalizeDouble(l_ord_takeprofit_100, Digits) < NormalizeDouble(l_ord_open_price_60 - (gi_128 - 60) * Point, Digits) && g_count_360 <= 1) OrderModify(l_ticket_8, OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(l_ord_open_price_60 - (gi_128 - 60) * Point, Digits), 0, CLR_NONE); if (Bid > l_ord_open_price_60 + 90.0 * Point && NormalizeDouble(l_ord_takeprofit_100, Digits) < NormalizeDouble(l_ord_open_price_60 - (gi_128 - 90) * Point, Digits) && g_count_360 == 0) OrderModify(l_ticket_8, OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(l_ord_open_price_60 - (gi_128 - 90) * Point, Digits), 0, CLR_NONE); } if (l_ticket_8 == 0 && l_ticket_16 == 0) { if (TimeCurrent() >= gi_264 && TimeCurrent() <= gi_268) { if ((Month() > 1 && Month() < 12) || (Month() == 1 && Day() >= 7) || (Month() == 12 && Day() < 20)) { l_price_76 = Bid + StopLoss * Point; if (StopLoss <= 0) l_price_76 = 0; l_price_84 = Bid - TakeProfit * Point; if ((StartHour < EndHour && TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) || (StartHour > EndHour && TimeHour(TimeCurrent()) >= StartHour || TimeHour(TimeCurrent()) < EndHour)) { if (DayOfWeek() != 5 || Hour() < FridayCloseTime) { if (l_ticket_4 == 0 && gs_304 == "Buy" || (gs_304 == "" && li_28 == 1)) { if (gs_304 == "") g_count_360 = 0; else { g_count_360 = MathFloor((Bid - g_bid_324) / (gi_124 * Point)); if (g_count_360 < 0 || g_count_360 > 9) g_count_360 = 0; } gd_348 = Lots; g_comment_372 = g_count_360 + "," + gd_348; if (g_count_360 <= 3) l_lots_92 = Lots; else l_lots_92 = NormalizeDouble(Lots * MathPow(2, g_count_360 - 3), gi_232); if (AccountFreeMarginCheck(Symbol(), OP_SELL, l_lots_92) >= 0.0) { if (BrokerMode != 2 && BrokerMode != 3) OrderSend(Symbol(), OP_SELL, l_lots_92, Bid, g_slippage_228, l_price_76, l_price_84, g_comment_372, Magic, 0, CLR_NONE); else { l_ticket_32 = OrderSend(Symbol(), OP_SELL, l_lots_92, Bid, g_slippage_228, 0, 0, g_comment_372, Magic, 0, CLR_NONE); if (l_ticket_32 > 0) { l_bool_300 = OrderModify(l_ticket_32, OrderOpenPrice(), l_price_76, l_price_84, 0, CLR_NONE); if (l_bool_300 == FALSE) Print("Error modifying SELL order : ", GetLastError()); } } } else ls_236 = "SELL, " + DoubleToStr(l_lots_92, 2) + " lots. "; gs_304 = "Sell"; return (0); } } } } ls_220 = gs_280; } else ls_220 = gs_272; } if (l_ticket_4 != 0 && l_ticket_12 == 0) { l_pips_164 = FinalStep(g_count_356); l_pips_156 = FinalTP(g_count_356); l_price_68 = l_ord_open_price_52 - l_pips_164 * Point; if (gi_108 == FALSE) l_price_76 = l_price_68 - StopLoss * Point; else l_price_76 = ld_172; if (StopLoss <= 0) l_price_76 = 0; l_price_84 = l_price_68 + l_pips_156 * Point; if (g_count_356 <= 3) g_comment_364 = "4," + gd_340; else g_comment_364 = (g_count_356 + 1) + "," + gd_340; if (g_count_356 < 9) l_lots_92 = NormalizeDouble(2.0 * l_ord_lots_36, gi_232); else l_lots_92 = NormalizeDouble(l_ord_lots_36 + gd_340, gi_232); l_ticket_12 = OrderSend(Symbol(), OP_BUYLIMIT, l_lots_92, l_price_68, g_slippage_228, l_price_76, l_price_84, g_comment_364, Magic, 0, CLR_NONE); } if (l_ticket_8 != 0 && l_ticket_16 == 0) { l_pips_164 = FinalStep(g_count_360); l_pips_156 = FinalTP(g_count_360); l_price_68 = l_ord_open_price_60 + l_pips_164 * Point; if (gi_108 == FALSE) l_price_76 = l_price_68 + StopLoss * Point; else l_price_76 = ld_180; if (StopLoss <= 0) l_price_76 = 0; l_price_84 = l_price_68 - l_pips_156 * Point; if (g_count_360 <= 3) g_comment_372 = "4," + gd_348; else g_comment_372 = (g_count_360 + 1) + "," + gd_348; if (g_count_360 < 9) l_lots_92 = NormalizeDouble(2.0 * l_ord_lots_44, gi_232); else l_lots_92 = NormalizeDouble(l_ord_lots_44 + gd_348, gi_232); l_ticket_16 = OrderSend(Symbol(), OP_SELLLIMIT, l_lots_92, l_price_68, g_slippage_228, l_price_76, l_price_84, g_comment_372, Magic, 0, CLR_NONE); } if (l_ticket_20 != 0 && l_ord_lots_116 <= l_ord_lots_36 || l_ord_lots_116 == l_ord_lots_132) OrderDelete(l_ticket_20); if (gd_340 != 0.0) l_pips_164 = FinalStep(g_count_356); if (l_ticket_4 != 0 && l_ord_open_price_52 - Ask > l_pips_164 * Point && l_ticket_12 <= 0 || l_ticket_20 == 0) { l_price_68 = l_ord_open_price_52 - l_pips_164 * Point; l_price_204 = Ask; while (l_price_68 >= l_price_204) { if (g_count_356 <= 3) g_count_356 = 4; else g_count_356++; ld_unused_304 = l_ord_lots_36; if (l_ord_lots_36 < 64.0 * gd_340) l_ord_lots_36 = NormalizeDouble(2.0 * l_ord_lots_36, gi_232); else l_ord_lots_36 = NormalizeDouble(l_ord_lots_36 + gd_340, gi_232); l_pips_164 = FinalStep(g_count_356); l_price_68 -= l_pips_164 * Point; if (l_price_68 < l_price_204) { if (l_ticket_12 <= 0) { l_ticket_12 = -2; l_pips_156 = FinalTP(g_count_356); if (gi_108 == FALSE) l_price_76 = l_price_68 - StopLoss * Point; else l_price_76 = ld_172; if (StopLoss <= 0) l_price_76 = 0; l_price_84 = l_price_68 + l_pips_156 * Point; if (l_ord_lots_36 < 64.0 * gd_340) l_lots_92 = NormalizeDouble(2.0 * l_ord_lots_36, gi_232); else l_lots_92 = NormalizeDouble(l_ord_lots_36 + gd_340, gi_232); g_comment_364 = (g_count_356 + 1) + "," + gd_340; if (AccountFreeMarginCheck(Symbol(), OP_BUY, l_lots_92) >= 0.0) l_ticket_12 = OrderSend(Symbol(), OP_BUYLIMIT, l_lots_92, l_price_68, g_slippage_228, l_price_76, l_price_84, g_comment_364, Magic, 0, CLR_NONE); else ls_284 = "BUYLIMIT, " + DoubleToStr(l_lots_92, 2) + " lots. "; } if (l_ticket_20 == 0 && l_ord_lots_36 != l_ord_lots_132 && l_ticket_12 != -2) { l_price_188 = l_price_68 + l_pips_164 * Point; l_pips_156 = FinalTP(g_count_356); l_price_84 = l_price_188 + l_pips_156 * Point; l_lots_92 = NormalizeDouble(l_ord_lots_36, gi_232); if (gi_108 == FALSE) l_price_76 = l_price_188 - StopLoss * Point; else l_price_76 = ld_172; if (StopLoss <= 0) l_price_76 = 0; g_comment_364 = g_count_356 + "," + gd_340; l_ticket_32 = OrderSend(Symbol(), OP_BUYSTOP, l_lots_92, l_price_188, g_slippage_228, l_price_76, l_price_84, g_comment_364, Magic, 0, CLR_NONE); } } } } if (l_ticket_24 != 0 && l_ord_lots_124 <= l_ord_lots_44 || l_ord_lots_124 == l_ord_lots_140) OrderDelete(l_ticket_24); if (gd_348 != 0.0) l_pips_164 = FinalStep(g_count_360); if (l_ticket_8 != 0 && Bid - l_ord_open_price_60 > l_pips_164 * Point && l_ticket_16 <= 0 || l_ticket_24 == 0) { l_price_68 = l_ord_open_price_60 + l_pips_164 * Point; l_price_204 = Bid; while (l_price_68 <= l_price_204) { if (g_count_360 <= 3) g_count_360 = 4; else g_count_360++; ld_unused_312 = l_ord_lots_44; if (l_ord_lots_44 < 64.0 * gd_348) l_ord_lots_44 = NormalizeDouble(2.0 * l_ord_lots_44, gi_232); else l_ord_lots_44 = NormalizeDouble(l_ord_lots_44 + gd_348, gi_232); l_pips_164 = FinalStep(g_count_360); l_price_68 += l_pips_164 * Point; if (l_price_68 > l_price_204) { if (l_ticket_16 <= 0) { l_ticket_16 = -2; l_pips_156 = FinalTP(g_count_360); if (gi_108 == FALSE) l_price_76 = l_price_68 + StopLoss * Point; else l_price_76 = ld_180; if (StopLoss <= 0) l_price_76 = 0; l_price_84 = l_price_68 - l_pips_156 * Point; if (l_ord_lots_44 < 64.0 * gd_348) l_lots_92 = NormalizeDouble(2.0 * l_ord_lots_44, gi_232); else l_lots_92 = NormalizeDouble(l_ord_lots_44 + gd_348, gi_232); g_comment_372 = (g_count_360 + 1) + "," + gd_348; if (AccountFreeMarginCheck(Symbol(), OP_SELL, l_lots_92) >= 0.0) l_ticket_16 = OrderSend(Symbol(), OP_SELLLIMIT, l_lots_92, l_price_68, g_slippage_228, l_price_76, l_price_84, g_comment_372, Magic, 0, CLR_NONE); else ls_292 = "SELLLIMIT, " + DoubleToStr(l_lots_92, 2) + " lots. "; } if (l_ticket_24 == 0 && l_ord_lots_44 != l_ord_lots_140 && l_ticket_16 != -2) { l_price_196 = l_price_68 - l_pips_164 * Point; l_pips_156 = FinalTP(g_count_360); l_price_84 = l_price_196 - l_pips_156 * Point; l_lots_92 = NormalizeDouble(l_ord_lots_44, gi_232); if (gi_108 == FALSE) l_price_76 = l_price_196 + StopLoss * Point; else l_price_76 = ld_180; if (StopLoss <= 0) l_price_76 = 0; g_comment_372 = g_count_360 + "," + gd_348; l_ticket_32 = OrderSend(Symbol(), OP_SELLSTOP, l_lots_92, l_price_196, g_slippage_228, l_price_76, l_price_84, g_comment_372, Magic, 0, CLR_NONE); } } } } for (l_pos_328 = 0; l_pos_328 < OrdersTotal(); l_pos_328++) { OrderSelect(l_pos_328, SELECT_BY_POS, MODE_TRADES); if (StringSubstr(OrderSymbol(), 0, 6) == StringSubstr(Symbol(), 0, 6) || BrokerMode == 3 && OrderType() == OP_BUY && l_ticket_4 != 0 && OrderMagicNumber() == Magic) { if (gi_108 == FALSE) l_price_76 = l_ord_open_price_52 - StopLoss * Point; else l_price_76 = ld_172; if (StopLoss <= 0) l_price_76 = 0; if (OrderLots() < l_ord_lots_36) l_price_84 = l_ord_takeprofit_108; else l_price_84 = OrderTakeProfit(); if (NormalizeDouble(l_price_84, Digits) != NormalizeDouble(OrderTakeProfit(), Digits) || NormalizeDouble(l_price_76, Digits) != NormalizeDouble(OrderStopLoss(), Digits)) OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(l_price_76, Digits), NormalizeDouble(l_price_84, Digits), 0, CLR_NONE); } if (StringSubstr(OrderSymbol(), 0, 6) == StringSubstr(Symbol(), 0, 6) || BrokerMode == 3 && OrderType() == OP_SELL && l_ticket_8 != 0 && OrderMagicNumber() == Magic) { if (gi_108 == FALSE) l_price_76 = l_ord_open_price_60 + StopLoss * Point; else l_price_76 = ld_180; if (StopLoss <= 0) l_price_76 = 0; if (OrderLots() < l_ord_lots_44) l_price_84 = l_ord_takeprofit_100; else l_price_84 = OrderTakeProfit(); if (NormalizeDouble(l_price_84, Digits) != NormalizeDouble(OrderTakeProfit(), Digits) || NormalizeDouble(l_price_76, Digits) != NormalizeDouble(OrderStopLoss(), Digits)) OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(l_price_76, Digits), NormalizeDouble(l_price_84, Digits), 0, CLR_NONE); } } if (ls_228 != "" || ls_236 != "" || ls_244 != "" || ls_252 != "" || ls_260 != "" || ls_268 != "" || ls_284 != "" || ls_292 != "") ls_212 = "Not enough margin for opening orders: "; Comment(ls_220, "\n", ls_212, ls_228, ls_236, ls_244, ls_252, ls_260, ls_268, ls_284, ls_292, "\n", ls_276); return (0); } int FinalStep(double ad_0) { switch (ad_0) { case 0.0: return (gi_112); case 1.0: return (gi_116); case 2.0: return (gi_120); case 3.0: return (gi_124); } return (gi_124); } int FinalTP(double ad_0) { switch (ad_0) { case 0.0: return (gi_128); case 1.0: return (gi_132); case 2.0: return (gi_136); case 3.0: return (gi_140); case 4.0: return (gi_144); case 5.0: return (gi_148); case 6.0: return (gi_152); case 7.0: return (gi_156); case 8.0: return (gi_160); case 9.0: return (gi_164); case 10.0: return (gi_168); case 11.0: return (gi_172); case 12.0: return (gi_176); case 13.0: return (gi_180); case 14.0: return (gi_184); case 15.0: return (gi_188); case 16.0: return (gi_192); case 17.0: return (gi_196); case 18.0: return (gi_200); case 19.0: return (gi_204); case 20.0: return (gi_208); case 21.0: return (gi_212); case 22.0: return (gi_216); case 23.0: return (gi_220); case 24.0: return (gi_224); } return (gi_224); } void ChangeParameters() { gi_112 = 10 * gi_112; gi_116 = 10 * gi_116; gi_120 = 10 * gi_120; gi_124 = 10 * gi_124; gi_128 = 10 * gi_128; gi_132 = 10 * gi_132; gi_136 = 10 * gi_136; gi_140 = 10 * gi_140; gi_144 = 10 * gi_144; gi_148 = 10 * gi_148; gi_152 = 10 * gi_152; gi_156 = 10 * gi_156; gi_160 = 10 * gi_160; gi_164 = 10 * gi_164; gi_168 = 10 * gi_168; gi_172 = 10 * gi_172; gi_176 = 10 * gi_176; gi_180 = 10 * gi_180; gi_184 = 10 * gi_184; gi_188 = 10 * gi_188; gi_192 = 10 * gi_192; gi_196 = 10 * gi_196; gi_200 = 10 * gi_200; gi_204 = 10 * gi_204; gi_208 = 10 * gi_208; gi_212 = 10 * gi_212; gi_216 = 10 * gi_216; gi_220 = 10 * gi_220; gi_224 = 10 * gi_224; g_slippage_228 = 10 * g_slippage_228; gi_336 = 10 * gi_336; } void GetCommentBuy() { string ls_0 = ""; int li_8 = 0; int li_12 = 0; li_12 = StringFind(g_comment_364, ",", li_8); ls_0 = StringSubstr(g_comment_364, li_8, li_12 - li_8); g_count_356 = StrToDouble(ls_0); li_8 = li_12 + 1; li_12 = StringFind(g_comment_364, ",", li_8); ls_0 = StringSubstr(g_comment_364, li_8, li_12 - li_8); gd_340 = StrToDouble(ls_0); } void GetCommentSell() { string ls_0 = ""; int li_8 = 0; int li_12 = 0; li_12 = StringFind(g_comment_372, ",", li_8); ls_0 = StringSubstr(g_comment_372, li_8, li_12 - li_8); g_count_360 = StrToDouble(ls_0); li_8 = li_12 + 1; li_12 = StringFind(g_comment_372, ",", li_8); ls_0 = StringSubstr(g_comment_372, li_8, li_12 - li_8); gd_348 = StrToDouble(ls_0); }