#property copyright "Copyright of BelajarForexPro.com / LearnForexPro.com - Supported by FCMarket.com" #property link "http://www.belajarforexpro.com/expertadvisor.php" #property show_inputs #include string gs_76 = "SUPER HEDGING v1.70 by BelajarForexPro.com & LearnForexPro.com"; extern string Note = "*** SUPER HEDGING v1.70 ***"; extern string Note1 = "This Expert Advisor is a copyright of"; extern string Note2 = "http://www.learnforexpro.com"; extern string Note3 = "http://www.belajarforexpro.com"; extern string Note4 = "---------------------------------------------------------------------"; extern string Mode = "normal"; extern string Note5 = "----- CLOSE ALL POSITION -----"; extern bool CloseAll = FALSE; extern string Note6 = "----- BASIC PARAMETER -----"; extern int EALoop = 1; extern double LotSize = 0.1; extern bool CloseOneCloseAll = TRUE; bool gi_168 = FALSE; bool gi_172 = TRUE; double gd_176 = 1.0; extern int CloseWhileHedgingProfit = 10; extern string EAComment = "Super Hedging EA"; extern string Note21 = "----- SAFER -----"; extern bool Start_Safer = FALSE; extern int Safer = 3; extern double Safer_Money_CutLoss = 0.0; extern int Safer_StartLevel = 6; extern int Safer_EndLevel = 0; extern string Note7 = "----- INCREMENTAL RANGE -----"; extern int increase = 15; extern int IncreaseStartLevel = 2; extern int IncreaseEndLevel = 8; extern string Note8 = "----- HEDGING STRATEGY -----"; extern bool Hedging = TRUE; extern bool TimeLimit = FALSE; extern bool DST_Time = FALSE; extern int HedgeGap = 18; extern double Multiplier = 0.0; extern int TakeProfit = 150; extern int StopLoss = 0; extern bool GapAdjustment = FALSE; string gs_unused_292 = "----- AVERAGING STRATEGY -----"; bool gi_300 = FALSE; int gi_304 = 30; double gd_308 = 1.5; int gi_316 = 50; int gi_320 = 100; double gd_324 = 0.0; bool gi_332 = FALSE; int gi_336 = 130; int gi_340 = 5; int gi_344 = 0; bool gi_348 = FALSE; double gd_unused_352 = 6.0; double gd_unused_360 = 20.0; string gs_unused_368 = "buy"; string gs_eurusd_376 = "EURUSD"; string gs_usdchf_384 = "USDCHF"; bool gi_392 = FALSE; bool gi_396 = FALSE; bool gi_unused_400 = TRUE; double gd_404 = 0.0; int gi_412 = 10; int gi_416 = 20; int gi_420 = 0; int gi_424 = 8; int gi_428 = 3; int gi_432 = 15; int gi_436 = 10; extern string Note12 = "----- INITIAL ORDER -----"; extern string InitialOrder = "auto"; extern int ShortEMA = 5; extern int LongEMA = 14; extern string Note13 = "----- START WITH STRADDLE -----"; extern bool Straddle = FALSE; extern int StraddleRange = 8; extern double StraddleBuyPrice = 0.0; extern double StraddleSellPrice = 0.0; extern int StraddleTakeProfit = 20; extern int StraddleStopLoss = 0; extern string Note14 = "----- TRAILING STOP -----"; extern int TrailingStop = 25; extern int TrailingStopStartLevel = 1; extern int TrailingStopEndLevel = 2; extern int Rebound = 3; extern string Note15 = "----- TRAILING STOP 2-----"; extern int TrailingStop_2 = 20; extern int TrailingStop_2_StartLevel = 2; extern int TrailingStop_2_EndLevel = 4; extern int Rebound_2 = 3; extern string Note16 = "----- TRAILING STOP 3-----"; extern int TrailingStop_3 = 15; extern int TrailingStop_3_StartLevel = 4; extern int TrailingStop_3_EndLevel = 0; extern int Rebound_3 = 2; extern string Note17 = "----- TRAILING STOP 4-----"; extern int TrailingStop_4 = 6; extern int TrailingStop_4_StartLevel = 5; extern int TrailingStop_4_EndLevel = 0; extern int Rebound_4 = 1; extern string Note18 = "----- MONEY MANAGEMENT -----"; extern double MaxRiskPercentage = 100.0; extern double MaxProfit = 0.0; extern double MaxLoss = 0.0; extern int MaxLevelAllowed = 0; extern string Note19 = "----- DOUBLER -----"; extern bool Doubler = FALSE; extern bool DisableTrailingStop = FALSE; extern double DoublerLotSize = 0.1; extern int DoublerRangeFromProfit = 10; extern int DoublerTakeProfit = 10; extern int DoublerStopLoss = 10; extern double DoublerMultiplier = 0.0; extern double DoublerAddition = 0.1; extern int DoublerStartLevel = 1; extern int DoublerEndLevel = 0; extern int DoublerMaxOrder = 1; extern string Note20 = "----- TIME -----"; extern string StartEATime = "2008.8.8 17:26"; extern string EndEATime = "0"; extern string StopLoopTime = "0"; bool gi_740 = TRUE; bool gi_744 = FALSE; bool gi_748 = TRUE; bool gi_752 = TRUE; bool gi_unused_756 = TRUE; bool gi_760 = FALSE; bool gi_764 = FALSE; bool gi_768 = TRUE; bool gi_unused_772 = FALSE; bool gi_unused_776 = FALSE; int g_ticket_780; int gi_784 = 0; string gs_eurusd_788 = "EURUSD"; string gs_gbpusd_796 = "GBPUSD"; string gs_eurgbp_804 = "EURGBP"; int g_count_812; int g_count_816; int g_count_820; int g_count_824; int gi_828 = 0; int gi_832 = 0; int gi_836; int g_error_840; int g_ord_total_844; int g_pos_848; int gi_852 = 1; int gi_856 = 0; int gi_884 = 0; double gd_888; double gd_896; double g_ord_lots_920; double g_ord_lots_928; double gd_936 = 0.0; double gd_944 = 0.0; double g_bid_952; double g_ask_960; double g_bid_968 = 0.0; double g_ask_976 = 0.0; double gd_984 = 0.0; double gd_992 = 0.0; double gd_1000 = 0.0; double gd_1008 = 0.0; double g_ord_open_price_1016 = 0.0; double g_ord_open_price_1024 = 0.0; double gd_unused_1032 = 0.0; double gd_unused_1040 = 0.0; double gd_1048; double gd_1056; double g_price_1064; double g_price_1072; double gd_1080 = 0.0; double gd_1088 = 0.0; double gd_unused_1096 = 0.0; double gd_unused_1104 = 0.0; double gd_1144 = 0.0; double g_bid_1152 = 0.0; double g_ask_1160 = 0.0; double g_bid_1168; double gd_1176; double gd_1184; double g_bid_1192; double gd_1200; double g_ask_1208; double gd_1216; double gd_1224; double g_ask_1232; double gd_1240; double g_bid_1248; double gd_1256; double gd_1264; double g_bid_1272; double gd_1280; double g_ask_1288; double gd_1296; double gd_1304; double g_ask_1312; double gd_1320; double g_bid_1328; double gd_1336; double gd_1344; double g_bid_1352; double gd_1360; double g_ask_1368; double gd_1376; double gd_1384; double gd_1392; double gd_1400; double g_bid_1408; double gd_1416; double gd_1424; double gd_unused_1432; double g_ask_1440; double gd_1448; double gd_1456; double gd_unused_1464; double g_ask_1472; double g_bid_1480; double gd_1488; double gd_1496; double gd_1504; double gd_1512; double gd_1520; double gd_1528; double g_lots_1536; double g_lots_1544; double g_ord_open_price_1552; double g_ord_open_price_1560; double g_ord_lots_1568; double g_ord_lots_1576; int g_count_1584; int g_count_1588; bool gi_1596; bool gi_1600; bool gi_1604; bool gi_1608; bool gi_1612; bool gi_1616; bool gi_1620; bool gi_1624; bool gi_1628; bool gi_1632; bool gi_1636; int gi_1640; bool gi_1644; int gi_unused_1648; bool gi_1652; int gi_unused_1656; int gi_unused_1660; int gi_unused_1664; bool gi_1668; double g_ord_lots_1672; double g_ord_lots_1680; double gd_1688; double gd_1696; double g_price_1704; double g_price_1712; double g_price_1720; double g_price_1728; double gd_1736; double gd_1744; double gd_1752; double gd_1760; double gd_1768; double g_ord_open_price_1776; double g_ord_open_price_1784; double g_price_1792; double g_price_1800; double g_price_1808; double g_price_1816; double gd_1824; double gd_1832; double g_ord_open_price_1840; double g_ord_open_price_1848; double g_price_1856; double g_price_1864; double gd_1888; double g_price_1968; double g_price_1976; double g_high_1984; double g_low_1992; double g_ord_open_price_2000; double g_ord_open_price_2008; double gd_2016; double gd_2024; int gi_2044 = 5; int gi_2048 = 14; int gi_2052; int gi_2056; int g_datetime_2060; int gi_2064; bool gi_2068; bool gi_2072; int gi_unused_2076; int gi_unused_2080; int gi_unused_2084; int g_file_2088; int g_file_2092; int gi_2096; bool gi_2100; bool gi_2104; bool gi_2108; bool gi_2112; bool gi_2116; string gs_unused_2120 = "Color Settings"; string gs_2128 = ""; int g_magic_2136 = 12345; string gs_2140 = "2009.06.30 23:59"; int gi_2148 = 110712; string gs_2152; string gs_2160; string gs_2168; string gs_2176; string gs_2184; string gs_2192; string gs_2200; string gs_2208; string gs_2216; string g_name_2224 = "initialbalance.txt"; string gs_dummy_2232; bool gi_2240; bool gi_2248; int gi_2256; int gi_2260; bool gi_2264; bool gi_2268; bool gi_2272; double g_ask_2276; double g_bid_2284; double gd_2292; double gd_2300; double gd_2308; double g_ord_open_price_2324; double g_ord_open_price_2332; double g_lots_2372; double gd_2412; double g_str2dbl_2484; double gd_2496; int gi_2568 = 5; int gi_2572 = 4; double gd_unused_2584; double gd_unused_2592; double gd_unused_2632; double gd_unused_2640; double gd_unused_2648; double gd_unused_2656; double gd_2704; double gd_2712; double gd_2720; double gd_2728; double gd_2736; double gd_2744; int gi_2752 = 0; int gi_2756 = 3; int gi_2760 = 2; bool gi_2772; bool gi_2784; bool gi_2796; bool gi_2800 = TRUE; int g_error_2804; double g_ord_open_price_2816; double gd_2824; double gd_2832; double g_price_2840; double g_price_2848; double g_ord_open_price_2864; double gd_2872; double gd_2880; double g_price_2888; double g_price_2896; double g_lots_2904; double gd_2912; double g_point_2920; double gd_2928; double gd_2936; string gs_2944; string gs_2952; string gs_eurusd_2960 = "EURUSD"; string gs_gbpusd_2968 = "GBPUSD"; string gs_eurgbp_2976 = "EURGBP"; int gi_2984 = 65535; int gi_2988 = 16760576; int gi_2992 = 3329330; int gi_unused_2996 = 14772545; int gi_3000 = 255; int gi_3004 = 55295; int gi_3008 = 16443110; int gi_3012 = 9221330; int gi_3016 = 8388352; int gi_unused_3020 = 13499135; int gi_3024 = 11119017; int gi_3028 = 0; int gi_3032 = 0; int gi_3036 = 20; int gi_3040 = 35; int gi_3044 = 50; int gi_3048 = 65; int gi_3052 = 80; int gi_3056 = 95; int gi_3060 = 110; int gi_3064 = 125; int gi_3068 = 140; int gi_3072 = 155; int gi_3076 = 170; int gi_3080 = 185; int gi_3084 = 200; int gi_3088 = 215; int gi_3092 = 230; int gi_3096 = 245; int gi_3100 = 260; int gi_3104 = 275; int gi_3108 = 290; int gi_3112 = 305; int gi_3116 = 320; int gi_3120 = 335; int gi_3124 = 350; int gi_3128 = 365; int gi_3132 = 380; int gi_3136 = 395; int gi_3140 = 0; int gi_3144 = 0; int gi_3148 = 0; int init() { if (AccountCompany() == "EuroOrient Securities&Financial Services Ltd" || AccountCompany() == "Belvedere Inc.") gi_2064 = 2; else { if (AccountCompany() == "FXcast") gi_2064 = 1; else gi_2064 = 11; } if (DST_Time) { gi_2044--; gi_2048--; } gi_2052 = gi_2044 + gi_2064; gi_2056 = gi_2048 + gi_2064; while (true) { if (gi_2052 >= 24) { gi_2052 -= 24; continue; } if (gi_2052 >= 0) break; gi_2052 += 24; } while (true) { if (gi_2056 >= 24) { gi_2056 -= 24; continue; } if (gi_2056 >= 0) break; gi_2056 += 24; } return (0); } void LABEL(string a_name_0, string a_text_8, string a_fontname_16, int ai_24, int ai_28, color a_color_32) { if (ObjectFind(a_name_0) < 0) ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0); ObjectSetText(a_name_0, a_text_8, 9, a_fontname_16, a_color_32); ObjectSet(a_name_0, OBJPROP_CORNER, 0); ObjectSet(a_name_0, OBJPROP_XDISTANCE, ai_24 + 5 + gi_3028); ObjectSet(a_name_0, OBJPROP_YDISTANCE, ai_28 + 15 + gi_3032); } int start() { int l_file_4; if (IsTesting()) { Alert("This Expert Advisor cant be tested by Strategy Tester!"); return (0); } LABEL("TITLE_", gs_76, "Arial Bold", 0, gi_3036, gi_2984); while (!(ObjectFind("TITLE_") < 0)) { g_lots_2372 = LotSize; if (g_lots_2372 < MarketInfo(Symbol(), MODE_MINLOT)) { if (gi_2784 == FALSE) { Alert("**************************"); Alert("Please Change LotSize Input"); Alert("Expert Advisor is Disabled"); Alert("Minimum Lot allowed is ", DoubleToStr(MarketInfo(Symbol(), MODE_MINLOT), 3)); gi_2784 = TRUE; } return (0); } if (gi_392 == TRUE) { DisableTrailingStop = TRUE; Doubler = FALSE; CloseOneCloseAll = FALSE; StopLoopTime = "0"; } if (Mode == "pyr") { LotSize = 0.2; gi_304 = 10; gd_308 = 2; gi_316 = 15; increase = 0; Hedging = FALSE; gi_348 = FALSE; gi_300 = TRUE; gd_324 = 1; gi_332 = TRUE; Mode = "pyramid"; } gd_2824 = 0; gd_2872 = 0; gd_2832 = 0; gd_2880 = 0; g_price_2840 = 0; g_price_2888 = 0; g_price_2848 = 0; g_price_2896 = 0; g_ord_lots_1672 = 0; g_ord_lots_1680 = 0; gd_unused_2584 = 0; gd_unused_2592 = 0; gd_unused_2632 = 0; gd_unused_2640 = 0; gd_unused_2648 = 0; gd_unused_2656 = 0; g_point_2920 = MarketInfo(Symbol(), MODE_POINT); if (MarketInfo(Symbol(), MODE_DIGITS) == 3.0 || MarketInfo(Symbol(), MODE_DIGITS) == 5.0) { gd_2936 = MarketInfo(Symbol(), MODE_STOPLEVEL) / 10.0; gd_2928 = 10.0 * g_point_2920; } else { gd_2928 = g_point_2920; gd_2936 = MarketInfo(Symbol(), MODE_STOPLEVEL); } if (gd_2912 < MarketInfo(Symbol(), MODE_ASK) - MarketInfo(Symbol(), MODE_BID)) gd_2912 = MarketInfo(Symbol(), MODE_ASK) - MarketInfo(Symbol(), MODE_BID); if (MaxRiskPercentage > 100.0) MaxRiskPercentage = 100.0; if (gd_2292 == 0.0) gd_2292 = AccountBalance(); if (gi_396 == TRUE) { FileDelete(g_name_2224); g_error_840 = GetLastError(); if (g_error_840 != 0/* NO_ERROR */) { Print("Error = ", ErrorDescription(g_error_840), " while deleting Balance Amount"); gi_396 = FALSE; gi_740 = FALSE; break; } Print("Successfully Reseting Balance"); gi_396 = FALSE; } if (gd_404 > 0.0) { g_str2dbl_2484 = gd_404; g_file_2088 = FileOpen(g_name_2224, FILE_CSV|FILE_WRITE); for (int l_count_0 = 0; l_count_0 < 1; l_count_0++) gi_2096 = FileWrite(g_file_2088, DoubleToStr(gd_404, 2)); if (gi_2096 > 0) { Print("InitialBalance is ", g_str2dbl_2484); gd_404 = 0; Print("MSInitialBalance= ", DoubleToStr(gd_404, 2)); } else { Print("Failed setting InitialBalance"); gi_740 = FALSE; break; } FileClose(g_file_2088); } else { if (gd_2412 != AccountBalance()) { l_file_4 = FileOpen(g_name_2224, FILE_CSV|FILE_READ); gd_2412 = AccountBalance(); if (l_file_4 > 0) { gs_2216 = FileReadString(l_file_4); FileClose(l_file_4); g_str2dbl_2484 = StrToDouble(gs_2216); } if (l_file_4 < 0) { g_file_2092 = FileOpen(g_name_2224, FILE_CSV|FILE_WRITE); if (g_file_2092 > 0) { for (l_count_0 = 0; l_count_0 < 1; l_count_0++) FileWrite(g_file_2092, DoubleToStr(gd_2412, 2)); FileClose(g_file_2092); g_str2dbl_2484 = AccountBalance(); } if (g_file_2092 < 0) { Print("File Error. Closing Expert Advisor."); gi_740 = FALSE; break; } } } } if (!(ObjectFind("LABEL_OFF") < 0)) { if (gi_784 == 0) { Alert("--------------------------------"); Alert("5.If no smiley. Check Expert Advisor Icon"); Alert("4.Drag EA to chart until smiley appears"); Alert("3.Right Mouse->Object List->Delete Label_OFF"); Alert("2.Right Mouse->Expert Advisor->Remove"); Alert("1.Clear all active positions"); Alert("EA is OFF, to restart EA :"); gi_784 = 1; } } if (gi_784 == 1) { gi_740 = FALSE; break; } gi_784 = 2; if (gi_752 == TRUE) { if (ObjectsTotal() > 0) ObjectsDeleteAll(); if (ObjectsTotal() <= 0) gi_752 = FALSE; } LABEL("LABEL_EXPIRE", "EA Expire: " + gs_2140, "Arial Bold", 220, gi_3040, gi_3016); if (IsDemo()) { if (AccountCompany() != "EuroOrient Securities&Financial Services Ltd") { if (gi_2772 == FALSE) { MessageBox("This EA can only be used in Demo Account at :" + "\n" + "1) http://www.fcmarket.com/demo.php" + "\n" + "For more information contact support@belajarforexpro.com"); gi_2772 = TRUE; } gi_740 = FALSE; } } if (!IsDemo()) { if (AccountCompany() == "EuroOrient Securities&Financial Services Ltd") { if (AccountNumber() == gi_2148) { if (gi_2272 == FALSE) { gi_740 = TRUE; gi_2272 = TRUE; } } else { if (gi_2248 == FALSE) { MessageBox("Your Account is unregistered. Please disable Expert Advisor and contact http://www.belajarforexpro.com at support@belajarforexpro.com"); gi_2248 = TRUE; } gi_740 = FALSE; gi_760 = TRUE; if (gi_2248 != TRUE) break; ObjectDelete("LABEL_ON"); LABEL("LABEL_OFF", "Your Account is unregistered", "Arial Bold", 0, gi_3036 + 360, gi_3000); break; } } else { if (gi_2248 == FALSE) { MessageBox("Your Account is unregistered. Please disable Expert Advisor and contact http://www.belajarforexpro.com at support@belajarforexpro.com"); gi_2248 = TRUE; } gi_740 = FALSE; gi_760 = TRUE; if (gi_2248 != TRUE) break; ObjectDelete("LABEL_ON"); LABEL("LABEL_OFF", "Expert Advisor is only for DEMO", "Arial Bold", 0, gi_3040, gi_3000); break; } } if (TimeLocal() < StrToTime(StartEATime)) { gi_740 = FALSE; gi_764 = TRUE; if (BuyOrders() + SellOrders() > 0) CancelPending(); } if (gi_768 == TRUE) { if (TimeLocal() >= StrToTime(StartEATime)) { if (EndEATime > "0" && TimeLocal() >= StrToTime(EndEATime)) { gi_740 = FALSE; gi_768 = FALSE; CloseAll(); gs_2128 = "EndEATime"; } if (EndEATime > "0" && TimeLocal() < StrToTime(EndEATime)) { gi_764 = FALSE; gi_768 = FALSE; gi_740 = TRUE; } } } if (StrToTime(gs_2140) < TimeCurrent()) { if (gi_1596 == FALSE) { MessageBox("Your Account is expired. Please contact http://www.belajarforexpro.com at support@belajarforexpro.com"); gi_1596 = TRUE; } gi_740 = FALSE; gi_760 = TRUE; if (gi_760 != TRUE) break; ObjectDelete("LABEL_ON"); LABEL("LABEL_OFF", "Expert Advisor is EXPIRED", "Arial Bold", 0, gi_3040, gi_3000); break; } if (StrToTime(gs_2140) < TimeLocal()) { if (gi_1596 == FALSE) { MessageBox("Your Account is expired. Please contact http://www.belajarforexpro.com at support@belajarforexpro.com"); gi_1596 = TRUE; } gi_740 = FALSE; gi_760 = TRUE; if (gi_760 != TRUE) break; ObjectDelete("LABEL_ON"); LABEL("LABEL_OFF", "Expert Advisor is EXPIRED", "Arial Bold", 0, gi_3040, gi_3000); break; } if ((Hedging == TRUE && gi_300 == TRUE) || (Hedging == TRUE && gi_392 == TRUE) || (Hedging == TRUE && gi_348 == TRUE) || (gi_300 == TRUE && gi_348 == TRUE) || (gi_300 == TRUE && gi_392 == TRUE)) { if (gi_2264 == FALSE) { Alert("~~~~oOOo~(_)~oOOo~~~~"); Alert("~~~~ ( o o ) ~~~~"); Alert("~~~~ \\|// ~~~~"); if (Hedging == TRUE && gi_300 == TRUE) Alert("Hedging & Averaging could not run at once"); if (Hedging == TRUE && gi_392 == TRUE) Alert("Hedging & MS could not run at once"); if (Hedging == TRUE && gi_348 == TRUE) Alert("Hedging & Corr could not run at once"); if (gi_300 == TRUE && gi_392 == TRUE) Alert("Averaging & MS could not run at once"); if (gi_300 == TRUE && gi_348 == TRUE) Alert("Averaging & Corr could not run at once"); if (gi_392 == TRUE && gi_348 == TRUE) Alert("MS & Corr could not run at once"); } gi_2264 = TRUE; gi_740 = FALSE; } if (AccountBalance() < MarketInfo(Symbol(), MODE_MARGINREQUIRED) * MarketInfo(Symbol(), MODE_MINLOT) + MarketInfo(Symbol(), MODE_SPREAD) * MarketInfo(Symbol(), MODE_TICKVALUE) * MarketInfo(Symbol(), MODE_MINLOT)) { if (gi_2268 == FALSE) Alert("Your Account Balance is not enough"); gi_2268 = TRUE; gi_740 = FALSE; } if (gi_740 == TRUE) { ObjectDelete("LABEL_OFF"); LABEL("LABEL_ON", "Expert Advisor is ON", "Arial Bold", 0, gi_3040, gi_3016); if (!IsExpertEnabled()) { if (gi_2240 == FALSE) { Alert("*******************************"); Alert("Send email to support@belajarforexpro.com"); Alert("Please contact BelajarForexPro.com"); Alert("Do not turn off Expert Advisor while running!"); } gi_2240 = TRUE; } } else { if (gi_764 == TRUE) { ObjectDelete("LABEL_OFF"); LABEL("LABEL_ON", "Waiting to Start. Time Left " + ((StrToTime(StartEATime) - TimeLocal())) + " sec", "Arial Bold", 0, gi_3040, gi_3000); } if (gi_764 == FALSE) { if (gi_1608 == FALSE) { if (gi_2264 != TRUE && gi_2268 != TRUE) MessageDisplay(); gi_1608 = TRUE; } ObjDelete(); ObjectDelete("LABEL_ON"); LABEL("LABEL_OFF", "Expert Advisor is OFF", "Arial Bold", 0, gi_3040, gi_3000); } } if (gi_740 == TRUE) { gd_2308 = (MarketInfo(Symbol(), MODE_HIGH) - MarketInfo(Symbol(), MODE_LOW)) / MarketInfo(Symbol(), MODE_POINT); if (MarketInfo(Symbol(), MODE_DIGITS) == 3.0 || MarketInfo(Symbol(), MODE_DIGITS) == 5.0) { gd_2712 = gd_2308 / 10.0; gd_2720 = MarketInfo(Symbol(), MODE_STOPLEVEL) / 10.0; gd_2704 = MarketInfo(Symbol(), MODE_SPREAD) / 10.0; } else { gd_2712 = gd_2308; gd_2720 = MarketInfo(Symbol(), MODE_STOPLEVEL); gd_2704 = MarketInfo(Symbol(), MODE_SPREAD); } gs_2168 = "\n[MINLOT " + DoubleToStr(MarketInfo(Symbol(), MODE_MINLOT), 3) + "] [HI-LOW " + DoubleToStr(gd_2712, 1) + "] [SPREAD " + DoubleToStr(gd_2704, 1) + "] COPYRIGHT OF BELAJARFOREXPRO.COM"; if (IsDemo() == TRUE) gs_2176 = "DEMO"; else gs_2176 = "REAL"; Comment("[LOCAL ", TimeToStr(TimeLocal(), TIME_DATE|TIME_SECONDS), "] [SERVER ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS), "] [1:", AccountLeverage(), "] [DIGITS ", Digits, "] [MIN RANGE ", DoubleToStr(gd_2720, 1) + "] [" + gs_2176 + "]" + gs_2168); if (BuyLots() > SellLots()) LABEL("SEQUENCE_", "BUY Cycle Active", "Arial Bold", 0, gi_3044, gi_2988); if (BuyLots() < SellLots()) LABEL("SEQUENCE_", "SELL Cycle Active", "Arial Bold", 0, gi_3044, gi_2988); if (BuyLots() + SellLots() > 0.0) if (BuyLots() == SellLots()) LABEL("SEQUENCE_", "FULL HEDGING", "Arial Bold", 0, gi_3044, gi_2988); if (BuyLots() + SellLots() == 0.0) if (BuyLots() == SellLots()) LABEL("SEQUENCE_", "Waiting for sequence", "Arial Bold", 0, gi_3044, gi_2988); if (BuyOpen() + SellOpen() > 0) LABEL("BUYROW_", "Buy Row: " + BuyOpen() + " Sell Row: " + SellOpen(), "Arial Bold", 135, gi_3044, gi_2988); else LABEL("BUYROW_", "Buy Row: " + BuyOpen() + "Sell Row: " + SellOpen(), "Arial Bold", 135, gi_3044, gi_3024); if (gd_1144 > 0.0) LABEL("GAP_", "Gap : " + DoubleToStr(gd_1144 / gd_2928, 0), "Arial Bold", 325, gi_3044, gi_2988); else ObjectDelete("GAP_"); } if (Straddle == TRUE) { if (g_ord_open_price_1776 > 0.0) { LABEL("STRADDLE_BUY_", "Straddle Buy @ " + DoubleToStr(g_lots_2372, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1776, Digits) + " TP: " + DoubleToStr(g_price_1792, Digits) + " SL: " + DoubleToStr(g_price_1800, Digits), "Arial Bold", 0, gi_3048, gi_2992); } else { LABEL("STRADDLE_BUY_", "Straddle Buy @ " + DoubleToStr(g_lots_2372, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1776, Digits) + " TP: " + DoubleToStr(g_price_1792, Digits) + " SL: " + DoubleToStr(g_price_1800, Digits), "Arial Bold", 0, gi_3048, gi_3024); } if (g_ord_open_price_1784 > 0.0) { LABEL("STRADDLE_SELL_", "Straddle Sell @ " + DoubleToStr(g_lots_2372, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1784, Digits) + " TP: " + DoubleToStr(g_price_1808, Digits) + " SL: " + DoubleToStr(g_price_1816, Digits), "Arial Bold", 0, gi_3052, gi_3000); } else { LABEL("STRADDLE_SELL_", "Straddle Sell @ " + DoubleToStr(g_lots_2372, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1784, Digits) + " TP: " + DoubleToStr(g_price_1808, Digits) + " SL: " + DoubleToStr(g_price_1816, Digits), "Arial Bold", 0, gi_3052, gi_3024); } if (g_ord_open_price_1776 + g_ord_open_price_1784 > 0.0) LABEL("STRADDLE_INFO_", "[Straddle] Range: " + StraddleRange + " TP: " + StraddleTakeProfit + " SL: " + StraddleStopLoss, "Arial Bold", 0, gi_3056, gi_2988); else LABEL("STRADDLE_INFO_", "[Straddle] Range: " + StraddleRange + " TP: " + StraddleTakeProfit + " SL: " + StraddleStopLoss, "Arial Bold", 0, gi_3056, gi_3024); } if (gi_300 == TRUE && gi_332 == TRUE) { if (BuyOpen() + SellOpen() > 0) gi_2796 = FALSE; else gi_2796 = TRUE; if (gi_2796 == TRUE) { if (BuyOrders() > 0) LABEL("HILOW_BUY_", "HiLow Buy @ " + DoubleToStr(g_lots_2372, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_2000, Digits), "Arial Bold", 0, gi_3048, gi_2992); else LABEL("HILOW_BUY_", "HiLow Buy @ " + DoubleToStr(g_lots_2372, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_2000, Digits), "Arial Bold", 0, gi_3048, gi_3024); if (SellOrders() > 0) LABEL("HILOW_SELL_", "HiLow Sell @ " + DoubleToStr(g_lots_2372, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_2008, Digits), "Arial Bold", 0, gi_3052, gi_3000); else LABEL("HILOW_SELL_", "HiLow Sell @ " + DoubleToStr(g_lots_2372, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_2008, Digits), "Arial Bold", 0, gi_3052, gi_3024); if (BuyOrders() + SellOrders() > 0) LABEL("HILOW_INFO_", "[HiLow] Gap: " + gi_336 + " Current: " + DoubleToStr(gd_2308, 0) + " HiLow Range: " + gi_340 + " Indi Level: " + gi_344, "Arial Bold", 0, gi_3056, gi_2988); else LABEL("HILOW_INFO_", "[HiLow] Gap: " + gi_336 + " Current: " + DoubleToStr(gd_2308, 0) + " HiLow Range: " + gi_340 + " Indi Level: " + gi_344, "Arial Bold", 0, gi_3056, gi_3024); } } if (Straddle == FALSE && gi_2796 == FALSE) { if (gi_392 == TRUE) LABEL("EMA_", "[Init] Bal: " + DoubleToStr(g_str2dbl_2484, 2) + " Cut P/L($): " + gi_432 + " ReB: B @" + DoubleToStr(gd_2016, Digits) + " S @" + DoubleToStr(gd_2024, Digits), "Arial Bold", 0, gi_3060, gi_3004); else { if (InitialOrder == "auto" || InitialOrder == "m" || InitialOrder == "manual" || InitialOrder == "buy auto" || InitialOrder == "sell auto" || InitialOrder == "ba" || InitialOrder == "sa") { if (InitialOrder == "m") InitialOrder = "manual"; if (InitialOrder == "a") InitialOrder = "auto"; if (InitialOrder == "ba") InitialOrder = "buy auto"; if (InitialOrder == "sa") InitialOrder = "sell auto"; LABEL("EMA_", "[Init] Short EMA: " + ShortEMA + " Long EMA: " + LongEMA + " Order: " + InitialOrder + ", " + Mode, "Arial Bold", 0, gi_3060, gi_3004); } else ObjectDelete("EMA_"); } if (gi_392 == FALSE) { if (Hedging == TRUE || gi_300 == TRUE) { if (increase > 0) { if (gi_856 >= IncreaseStartLevel) LABEL("INCREASE_", "[Increase] Range" + increase + " Start: " + IncreaseStartLevel + " End: " + IncreaseEndLevel, "Arial Bold", 0, gi_3064, gi_3008); else LABEL("INCREASE_", "[Increase] Range" + increase + " Start: " + IncreaseStartLevel + " End: " + IncreaseEndLevel, "Arial Bold", 0, gi_3064, gi_3024); } else LABEL("INCREASE_", "[Increase] is OFF", "Arial Bold", 0, gi_3064, gi_3024); if (Hedging == TRUE) LABEL("RANGE_", "[Current] Range: " + ((HedgeGap + increase * gi_884)) + " Level: " + gi_856 + " of " + MaxLevelAllowed + " P/L: " + DoubleToStr(AccountProfit(), 2), "Arial Bold", 0, gi_3068, gi_3012); if (gi_300 == TRUE) LABEL("RANGE_", "[Current] Range: " + ((gi_304 + increase * gi_884)) + " Level: " + gi_856 + " of " + MaxLevelAllowed + " P/L: " + DoubleToStr(AccountProfit(), 2), "Arial Bold", 0, gi_3068, gi_3012); if (BuyLots() + SellLots() > 0.0 && BuyLots() == SellLots()) { ObjectDelete("INITIALRANGE_"); LABEL("FULLHEDGE_", "[Basic] Full Hedging Position. Closing at " + CloseWhileHedgingProfit + " point(s) profit", "Arial Bold", 0, gi_3072, gi_2988); } else { if (Hedging == TRUE) { ObjectDelete("FULLHEDGE_"); LABEL("INITIALRANGE_", "[Basic] Hedge Gap: " + HedgeGap + " Multiplier: " + DoubleToStr(Multiplier, 2) + " Lot " + DoubleToStr(g_lots_2372, 3) + " TP: " + TakeProfit + " SL: " + StopLoss, "Arial Bold", 0, gi_3072, gi_2988); } if (gi_300 == TRUE) { ObjectDelete("FULLHEDGE_"); LABEL("INITIALRANGE_", "[Basic] Average Gap: " + gi_304 + " Multiplier: " + DoubleToStr(gd_308, 2) + " Lot " + DoubleToStr(g_lots_2372, 3) + " TP: " + gi_316 + " SL: " + gi_320, "Arial Bold", 0, gi_3072, gi_2988); if (gd_324 > 0.0) LABEL("MAXLOTSTOP_", "Max Lot Stop: " + DoubleToStr(gd_324, 3), "Arial Bold", 350, gi_3072, gi_2988); else ObjectDelete("MAXLOTSTOP_"); } } } else { ObjectDelete("INCREASE_"); ObjectDelete("RANGE_"); ObjectDelete("INITIALRANGE_"); } } if (gi_392 == TRUE) { LABEL("RANGE_", "[Current] Range: " + gi_412 + " Bal: " + DoubleToStr(AccountBalance(), 2) + " Cum P/L: " + DoubleToStr(gd_2496, 2) + " P/L: " + DoubleToStr(AccountProfit(), 2), "Arial Bold", 0, gi_3068, gi_3012); LABEL("INITIALRANGE_", "[Basic] MS Adj Pend: " + gi_436 + " TP: " + gi_416 + " SL: " + gi_420 + " TS: " + gi_424 + " ReB: " + gi_428, "Arial Bold", 0, gi_3072, gi_2988); } if (gi_168 == TRUE) { gs_2192 = "ON"; if (gi_172 == TRUE) gs_2200 = "ON"; else gs_2200 = "OFF"; LABEL("AUTOLOT_", "[Basic] AutoCalLot: " + gs_2192 + " DecLot: " + gs_2200 + " LotRatio: " + DoubleToStr(gd_176, 2), "Arial Bold", 0, gi_3076, gi_2988); } else { gs_2192 = "OFF"; LABEL("AUTOLOT_", "[Basic] AutoCalLot: OFF", "Arial Bold", 0, gi_3076, gi_3024); } if (DisableTrailingStop == FALSE) { if (TrailingStop > 0) { if (BuyLots() > SellLots()) { if (g_bid_1152 > 0.0 || gd_1888 != g_bid_1152) { ObjectDelete("TRAILINGSTOPSELL_"); ObjectDelete("TRAILINGSTOPSELL_BEP_"); LABEL("TRAILINGSTOPBUY_", "[TS] Buy Range: " + TrailingStop + " (" + DoubleToStr(gd_1080, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_984, Digits) + ") Start: " + TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_3080, gi_2992); LABEL("TRAILINGSTOPBUY_BEP_", " BEP: " + DoubleToStr(g_bid_1152, Digits), "Arial Bold", 350, gi_3080, gi_2992); } else { ObjectDelete("TRAILINGSTOPSELL_"); ObjectDelete("TRAILINGSTOPSELL_BEP_"); LABEL("TRAILINGSTOPBUY_", "[TS] Buy Range: " + TrailingStop + " (" + DoubleToStr(gd_1080, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_984, Digits) + ") Start: " + TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_3080, gi_3024); LABEL("TRAILINGSTOPBUY_BEP_", " BEP: " + DoubleToStr(g_bid_1152, Digits), "Arial Bold", 350, gi_3080, gi_3024); } } if (SellLots() > BuyLots()) { if (g_ask_1160 > 0.0) { ObjectDelete("TRAILINGSTOPBUY_"); ObjectDelete("TRAILINGSTOPBUY_BEP_"); LABEL("TRAILINGSTOPSELL_", "[TS] Sell Range: " + TrailingStop + " (" + DoubleToStr(gd_1088, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_992, Digits) + ") Start: " + TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_3080, gi_2992); LABEL("TRAILINGSTOPSELL_BEP_", " BEP: " + DoubleToStr(g_ask_1160, Digits), "Arial Bold", 350, gi_3080, gi_2992); } else { ObjectDelete("TRAILINGSTOPBUY_"); ObjectDelete("TRAILINGSTOPBUY_BEP_"); LABEL("TRAILINGSTOPSELL_", "[TS] Sell Range: " + TrailingStop + " (" + DoubleToStr(gd_1088, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_992, Digits) + ") Start: " + TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_3080, gi_3024); LABEL("TRAILINGSTOPSELL_BEP_", " BEP: " + DoubleToStr(g_ask_1160, Digits), "Arial Bold", 350, gi_3080, gi_3024); } } } else LABEL("TRAILINGSTOP_", "[TS] is OFF ", "Arial Bold", 0, gi_3080, gi_3024); if (TrailingStop_2 > 0) { if (BuyLots() > SellLots()) { if (g_bid_1168 > 0.0) { ObjectDelete("TRAILINGSTOPSELL_2_"); ObjectDelete("TRAILINGSTOPSELL_2_BEP_"); LABEL("TRAILINGSTOPBUY_2_", "[TS 2] Buy Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1176, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1200, Digits) + ") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_3084, gi_2992); LABEL("TRAILINGSTOPBUY_2_BEP_", " BEP: " + DoubleToStr(g_bid_1168, Digits), "Arial Bold", 350, gi_3084, gi_2992); } else { ObjectDelete("TRAILINGSTOPSELL_2_"); ObjectDelete("TRAILINGSTOPSELL_2_BEP_"); LABEL("TRAILINGSTOPBUY_2_", "[TS 2] Buy Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1176, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1200, Digits) + ") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_3084, gi_3024); LABEL("TRAILINGSTOPBUY_2_BEP_", " BEP: " + DoubleToStr(g_bid_1168, Digits), "Arial Bold", 350, gi_3084, gi_3024); } } if (SellLots() > BuyLots()) { if (g_ask_1208 > 0.0) { ObjectDelete("TRAILINGSTOPBUY_2_"); ObjectDelete("TRAILINGSTOPBUY_2_BEP_"); LABEL("TRAILINGSTOPSELL_2_", "[TS 2] Sell Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1216, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1240, Digits) + ") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_3084, gi_2992); LABEL("TRAILINGSTOPSELL_2_BEP_", " BEP: " + DoubleToStr(g_ask_1208, Digits), "Arial Bold", 350, gi_3084, gi_2992); } else { ObjectDelete("TRAILINGSTOPBUY_2_"); ObjectDelete("TRAILINGSTOPBUY_2_BEP_"); LABEL("TRAILINGSTOPSELL_2_", "[TS 2] Sell Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1216, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1240, Digits) + ") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_3084, gi_3024); LABEL("TRAILINGSTOPSELL_2_BEP_", " BEP: " + DoubleToStr(g_ask_1208, Digits), "Arial Bold", 350, gi_3084, gi_3024); } } } else LABEL("TRAILINGSTOP_2_", "[TS 2] is OFF", "Arial Bold", 0, gi_3084, gi_3024); if (TrailingStop_3 > 0) { if (BuyLots() > SellLots()) { if (g_bid_1248 > 0.0) { ObjectDelete("TRAILINGSTOPSELL_3_"); ObjectDelete("TRAILINGSTOPSELL_3_BEP_"); LABEL("TRAILINGSTOPBUY_3_", "[TS 3] Buy Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1256, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1280, Digits) + ") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_3088, gi_2992); LABEL("TRAILINGSTOPBUY_3_BEP_", " BEP: " + DoubleToStr(g_bid_1248, Digits), "Arial Bold", 350, gi_3088, gi_2992); } else { ObjectDelete("TRAILINGSTOPSELL_3_"); ObjectDelete("TRAILINGSTOPSELL_3_BEP_"); LABEL("TRAILINGSTOPBUY_3_", "[TS 3] Buy Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1256, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1280, Digits) + ") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_3088, gi_3024); LABEL("TRAILINGSTOPBUY_3_BEP_", " BEP: " + DoubleToStr(g_bid_1248, Digits), "Arial Bold", 350, gi_3088, gi_3024); } } if (SellLots() > BuyLots()) { if (g_ask_1288 > 0.0) { ObjectDelete("TRAILINGSTOPBUY_3_"); ObjectDelete("TRAILINGSTOPBUY_3_BEP_"); LABEL("TRAILINGSTOPSELL_3_", "[TS 3] Sell Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1296, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1320, Digits) + ") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_3088, gi_2992); LABEL("TRAILINGSTOPSELL_3_BEP_", " BEP: " + DoubleToStr(g_ask_1288, Digits), "Arial Bold", 350, gi_3088, gi_2992); } else { ObjectDelete("TRAILINGSTOPBUY_3_"); ObjectDelete("TRAILINGSTOPBUY_3_BEP_"); LABEL("TRAILINGSTOPSELL_3_", "[TS 3] Sell Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1296, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1320, Digits) + ") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_3088, gi_3024); LABEL("TRAILINGSTOPSELL_3_BEP_", " BEP: " + DoubleToStr(g_ask_1288, Digits), "Arial Bold", 350, gi_3088, gi_3024); } } } else LABEL("TrailingStop_3_", "[TS 3] is OFF", "Arial Bold", 0, gi_3088, gi_3024); if (TrailingStop_4 > 0) { if (BuyLots() > SellLots()) { if (g_bid_1328 > 0.0) { ObjectDelete("TRAILINGSTOPSELL_4_"); ObjectDelete("TRAILINGSTOPSELL_4_BEP_"); LABEL("TRAILINGSTOPBUY_4_", "[TS 4] Buy Range: " + TrailingStop_4 + " (" + DoubleToStr(gd_1336, Digits) + ") ReB: " + Rebound_4 + " (" + DoubleToStr(gd_1360, Digits) + ") Start: " + TrailingStop_4_StartLevel + " End: " + TrailingStop_4_EndLevel, "Arial Bold", 0, gi_3092, gi_2992); LABEL("TRAILINGSTOPBUY_4_BEP_", " BEP: " + DoubleToStr(g_bid_1328, Digits), "Arial Bold", 350, gi_3092, gi_2992); } else { ObjectDelete("TRAILINGSTOPSELL_4_"); ObjectDelete("TRAILINGSTOPSELL_4_BEP_"); LABEL("TRAILINGSTOPBUY_4_", "[TS 4] Buy Range: " + TrailingStop_4 + " (" + DoubleToStr(gd_1336, Digits) + ") ReB: " + Rebound_4 + " (" + DoubleToStr(gd_1360, Digits) + ") Start: " + TrailingStop_4_StartLevel + " End: " + TrailingStop_4_EndLevel, "Arial Bold", 0, gi_3092, gi_3024); LABEL("TRAILINGSTOPBUY_4_BEP_", " BEP: " + DoubleToStr(g_bid_1328, Digits), "Arial Bold", 350, gi_3092, gi_3024); } } if (SellLots() > BuyLots()) { if (g_ask_1368 > 0.0) { ObjectDelete("TRAILINGSTOPBUY_4_"); ObjectDelete("TRAILINGSTOPBUY_4_BEP_"); LABEL("TRAILINGSTOPSELL_4_", "[TS 4] Sell Range: " + TrailingStop_4 + " (" + DoubleToStr(gd_1376, Digits) + ") ReB: " + Rebound_4 + " (" + DoubleToStr(gd_1400, Digits) + ") Start: " + TrailingStop_4_StartLevel + " End: " + TrailingStop_4_EndLevel, "Arial Bold", 0, gi_3092, gi_2992); LABEL("TRAILINGSTOPSELL_4_BEP_", " BEP: " + DoubleToStr(g_ask_1368, Digits), "Arial Bold", 350, gi_3092, gi_2992); } else { ObjectDelete("TRAILINGSTOPBUY_4_"); ObjectDelete("TRAILINGSTOPBUY_4_BEP_"); LABEL("TRAILINGSTOPSELL_4_", "[TS 4] Sell Range: " + TrailingStop_4 + " (" + DoubleToStr(gd_1376, Digits) + ") ReB: " + Rebound_4 + " (" + DoubleToStr(gd_1400, Digits) + ") Start: " + TrailingStop_4_StartLevel + " End: " + TrailingStop_4_EndLevel, "Arial Bold", 0, gi_3092, gi_3024); LABEL("TRAILINGSTOPSELL_4_BEP_", " BEP: " + DoubleToStr(g_ask_1368, Digits), "Arial Bold", 350, gi_3092, gi_3024); } } } else LABEL("TrailingStop_4_", "[TS 4] is OFF", "Arial Bold", 0, gi_3092, gi_3024); } else { ObjectDelete("TRAILINGSTOPSELL_"); ObjectDelete("TRAILINGSTOPSELL_BEP_"); ObjectDelete("TRAILINGSTOPBUY_"); ObjectDelete("TRAILINGSTOPBUY_BEP_"); ObjectDelete("TRAILINGSTOPSELL_2_"); ObjectDelete("TRAILINGSTOPSELL_2_BEP_"); ObjectDelete("TRAILINGSTOPBUY_2_"); ObjectDelete("TRAILINGSTOPBUY_2_BEP_"); ObjectDelete("TRAILINGSTOPSELL_3_"); ObjectDelete("TRAILINGSTOPSELL_3_BEP_"); ObjectDelete("TRAILINGSTOPBUY_3_"); ObjectDelete("TRAILINGSTOPBUY_3_BEP_"); ObjectDelete("TRAILINGSTOPBUY_4_"); ObjectDelete("TRAILINGSTOPBUY_4_BEP_"); ObjectDelete("TRAILINGSTOPSELL_4_"); ObjectDelete("TRAILINGSTOPSELL_4_BEP_"); LABEL("TRAILINGSTOP_", "[TS] is OFF ", "Arial Bold", 0, gi_3080, gi_3024); } if (Start_Safer) { if (BuyLots() > SellLots()) { if (g_bid_1408 > 0.0 || Safer_Money_CutLoss > 0.0) { ObjectDelete("SAFERSELL"); ObjectDelete("SAFERSELL_BEP_"); LABEL("SAFERBUY", "[SAFER] Buy Range: " + Safer + " (" + DoubleToStr(gd_1424, Digits) + ") Start: " + Safer_StartLevel + " End: " + Safer_EndLevel, "Arial Bold", 0, gi_3096, gi_2992); LABEL("SAFERBUY_BEP_", " BEP: " + DoubleToStr(g_bid_1408, Digits) + " Cut($): " + DoubleToStr(Safer_Money_CutLoss, 2), "Arial Bold", 350, gi_3096, gi_2992); } else { ObjectDelete("SAFERSELL"); ObjectDelete("SAFERSELL_BEP_"); LABEL("SAFERBUY", "[SAFER] Buy Range: " + Safer + " (" + DoubleToStr(gd_1424, Digits) + ") Start: " + Safer_StartLevel + " End: " + Safer_EndLevel, "Arial Bold", 0, gi_3096, gi_3024); LABEL("SAFERBUY_BEP_", " BEP: " + DoubleToStr(g_bid_1408, Digits) + " Cut($): " + DoubleToStr(Safer_Money_CutLoss, 2), "Arial Bold", 350, gi_3096, gi_3024); } } if (SellLots() > BuyLots()) { if (g_ask_1440 > 0.0 || Safer_Money_CutLoss > 0.0) { ObjectDelete("SAFERBUY"); ObjectDelete("SAFERBUY_BEP_"); LABEL("SAFERSELL", "[SAFER] Sell Range: " + Safer + " (" + DoubleToStr(gd_1456, Digits) + ") Start: " + Safer_StartLevel + " End: " + Safer_EndLevel, "Arial Bold", 0, gi_3096, gi_2992); LABEL("SAFERSELL_BEP_", " BEP: " + DoubleToStr(g_ask_1440, Digits) + " Cut($): " + DoubleToStr(Safer_Money_CutLoss, 2), "Arial Bold", 350, gi_3096, gi_2992); } else { ObjectDelete("SAFERBUY"); ObjectDelete("SAFERBUY_BEP_"); LABEL("SAFERSELL", "[SAFER] Sell Range: " + Safer + " (" + DoubleToStr(gd_1456, Digits) + ") Start: " + Safer_StartLevel + " End: " + Safer_EndLevel, "Arial Bold", 0, gi_3096, gi_3024); LABEL("SAFERSELL_BEP_", " BEP: " + DoubleToStr(g_ask_1440, Digits) + " Cut($): " + DoubleToStr(Safer_Money_CutLoss, 2), "Arial Bold", 350, gi_3096, gi_3024); } } } else LABEL("Safer_", "[SAFER] is OFF", "Arial Bold", 0, gi_3096, gi_3024); if (MaxRiskPercentage > 0.0) { if (gd_1736 < 0.0) LABEL("MAXRISK_", "[Management] Risk %: " + DoubleToStr(gd_1736, 2) + " % of " + DoubleToStr(-MaxRiskPercentage, 2) + " %", "Arial Bold", 0, gi_3100, gi_3000); else LABEL("MAXRISK_", "[Management] Risk %: " + DoubleToStr(gd_1736, 2) + " % of " + DoubleToStr(-MaxRiskPercentage, 2) + " %", "Arial Bold", 0, gi_3100, gi_3024); } else LABEL("MAXRISK_", "[Management] Risk % is OFF ", "Arial Bold", 0, gi_3100, gi_3024); if (MaxProfit > 0.0) { if (AccountProfit() > 0.0) LABEL("MAXPROFIT_", "Profit($) " + DoubleToStr(AccountProfit(), 2) + " of " + DoubleToStr(MaxProfit, 2), "Arial Bold", 245, gi_3100, gi_3000); else LABEL("MAXPROFIT_", "Profit($) " + DoubleToStr(AccountProfit(), 2) + " of " + DoubleToStr(MaxProfit, 2), "Arial Bold", 245, gi_3100, gi_3024); } else LABEL("MAXPROFIT_", "Profit($) is OFF", "Arial Bold", 245, gi_3100, gi_3024); if (CloseOneCloseAll == TRUE) { gs_2208 = "ON"; LABEL("CLOSEONECLOSEALL_", "[Management] CloseOneCloseAll: " + gs_2208, "Arial Bold", 0, gi_3104, gi_3000); } else { gs_2208 = "OFF"; LABEL("CLOSEONECLOSEALL_", "[Management] CloseOneCloseAll: " + gs_2208, "Arial Bold", 0, gi_3104, gi_3024); } if (MaxLoss > 0.0) { if (AccountProfit() < 0.0) LABEL("MAXLOSS_", "Loss($) " + DoubleToStr(AccountProfit(), 2) + " of -" + DoubleToStr(MaxLoss, 2), "Arial Bold", 245, gi_3104, gi_3000); else LABEL("MAXLOSS_", "Loss($) " + DoubleToStr(AccountProfit(), 2) + " of -" + DoubleToStr(MaxLoss, 2), "Arial Bold", 245, gi_3104, gi_3024); } else LABEL("MAXLOSS_", "Loss($) is OFF", "Arial Bold", 245, gi_3104, gi_3024); if (Doubler == TRUE) { if (DoublerBuyLots() + DoublerSellLots() > 0.0) { LABEL("DOUBLER_", "[Doubler] Lot " + DoubleToStr(DoublerLotSize, 3) + " Range: " + DoublerRangeFromProfit + " TP: " + DoublerTakeProfit + " SL :" + DoublerStopLoss + " Start : " + DoublerStartLevel + " End : " + DoublerEndLevel, "Arial Bold", 0, gi_3108, gi_2984); LABEL("DOUBLER_2_", "[Doubler] Multiplier :" + DoubleToStr(DoublerMultiplier, 2) + " Addition: " + DoubleToStr(DoublerAddition, 3), "Arial Bold", 0, gi_3112, gi_2984); if (DisableTrailingStop == TRUE) LABEL("DOUBLER_3_", "Disable TS: YES", "Arial Bold", 230, gi_3112, gi_2984); else LABEL("DOUBLER_3_", "Disable TS: NO", "Arial Bold", 230, gi_3112, gi_2984); } else { LABEL("DOUBLER_", "[Doubler] Lot " + DoubleToStr(DoublerLotSize, 3) + " Range: " + DoublerRangeFromProfit + " TP: " + DoublerTakeProfit + " SL :" + DoublerStopLoss + " Start : " + DoublerStartLevel + " End : " + DoublerEndLevel, "Arial Bold", 0, gi_3108, gi_3024); LABEL("DOUBLER_2_", "[Doubler] Multiplier :" + DoubleToStr(DoublerMultiplier, 2) + " Addition: " + DoubleToStr(DoublerAddition, 3), "Arial Bold", 0, gi_3112, gi_3024); if (DisableTrailingStop == TRUE) LABEL("DOUBLER_3_", "Disable TS: YES", "Arial Bold", 230, gi_3112, gi_3024); else LABEL("DOUBLER_3_", "Disable TS: NO", "Arial Bold", 230, gi_3112, gi_3024); } if (DoublerBuyLots() > 0.0) { ObjectDelete("DOUBLER_BUY_OFF"); ObjectDelete("DOUBLER_BUY_2_OFF"); LABEL("DOUBLER_BUY_ON", "[Doubler] Buy " + DoubleToStr(g_ord_lots_1568, 2) + " lots @ " + DoubleToStr(g_ord_open_price_1840, Digits) + " SL: " + DoubleToStr(g_price_1720, Digits) + " TP: " + DoubleToStr(g_price_1704, Digits), "Arial Bold", 0, gi_3116, gi_2992); LABEL("DOUBLER_BUY_2_ON", "[Doubler] Buy BEP @ " + DoubleToStr(g_ord_open_price_1840 - DoublerRangeFromProfit * gd_2928, Digits) + " Order " + g_count_1584 + " of " + DoublerMaxOrder, "Arial Bold", 0, gi_3120, gi_2992); } else { ObjectDelete("DOUBLER_BUY_ON"); ObjectDelete("DOUBLER_BUY_2_ON"); LABEL("DOUBLER_BUY_OFF", "[Doubler] Buy " + DoubleToStr(g_lots_1536, 2) + " lots @ " + DoubleToStr(gd_1488, Digits) + " SL: " + DoubleToStr(g_price_1720, Digits) + " TP: " + DoubleToStr(g_price_1704, Digits), "Arial Bold", 0, gi_3116, gi_3024); LABEL("DOUBLER_BUY_2_OFF", "[Doubler] Buy BEP @ " + DoubleToStr(g_ask_1472, Digits) + " Order " + g_count_1584 + " of " + DoublerMaxOrder, "Arial Bold", 0, gi_3120, gi_3024); } if (DoublerSellLots() > 0.0) { ObjectDelete("DOUBLER_SELL_OFF"); ObjectDelete("DOUBLER_SELL_2_OFF"); LABEL("DOUBLER_SELL_ON", "[Doubler] Sell " + DoubleToStr(g_ord_lots_1576, 2) + " lots @ " + DoubleToStr(g_ord_open_price_1848, Digits) + " SL: " + DoubleToStr(g_price_1728, Digits) + " TP: " + DoubleToStr(g_price_1712, Digits), "Arial Bold", 0, gi_3124, gi_3000); LABEL("DOUBLER_SELL_2_ON", "[Doubler] Sell BEP @ " + DoubleToStr(g_ord_open_price_1848 + DoublerRangeFromProfit * gd_2928, Digits) + " Order " + g_count_1588 + " of " + DoublerMaxOrder, "Arial Bold", 0, gi_3128, gi_3000); } else { ObjectDelete("DOUBLER_SELL_ON"); ObjectDelete("DOUBLER_SELL_2_ON"); LABEL("DOUBLER_SELL_OFF", "[Doubler] Sell " + DoubleToStr(g_lots_1544, 2) + " lots @ " + DoubleToStr(gd_1496, Digits) + " SL: " + DoubleToStr(g_price_1728, Digits) + " TP: " + DoubleToStr(g_price_1712, Digits), "Arial Bold", 0, gi_3124, gi_3024); LABEL("DOUBLER_SELL_2_OFF", "[Doubler] Sell BEP @ " + DoubleToStr(g_bid_1480, Digits) + " Order " + g_count_1588 + " of " + DoublerMaxOrder, "Arial Bold", 0, gi_3128, gi_3024); } } else LABEL("DOUBLER_", "Doubler is OFF", "Arial Bold", 0, gi_3108, gi_3024); if (gi_1612 == FALSE) { if (djcal(gs_eurusd_2960) && djcal(gs_gbpusd_2968) && djcal(gs_eurgbp_2976)) { gi_1668 = TRUE; gi_1612 = TRUE; } } if (gi_1616 == FALSE) { if (sjcal(gs_eurusd_2960) || sjcal(gs_gbpusd_2968) || sjcal(gs_eurgbp_2976)) { gi_1644 = TRUE; gi_1616 = TRUE; } } if (gi_1624 == FALSE) { if (sjminlot(gs_eurusd_2960) && sjminlot(gs_gbpusd_2968)) { gi_1652 = TRUE; gi_1624 = TRUE; } } if (gi_1620 == FALSE) { if (sjcal2(gs_eurusd_2960) || sjcal2(gs_gbpusd_2968)) { gi_unused_1648 = 1; gi_1620 = TRUE; } } if (gi_1628 == FALSE) { if (sjminlot2(gs_eurusd_2960) && sjminlot2(gs_gbpusd_2968)) { gi_unused_1656 = 1; gi_1628 = TRUE; } } if (gi_1632 == FALSE) { if (sjcal3(gs_eurusd_2960) && sjcal3(gs_gbpusd_2968)) { gi_unused_1660 = 1; gi_1632 = TRUE; } } if (gi_1636 == FALSE) { if (frz(gs_eurusd_2960) && frz(gs_gbpusd_2968)) { gi_unused_1664 = 1; gi_1636 = TRUE; } } if (gi_1640 == 0) { if (gi_1668 && gi_1644 && gi_1652) gi_1640 = 1; else gi_1640 = 2; } if (StrToTime(StartEATime) > TimeLocal()) LABEL("START_TIME_", "[Time] Start " + StartEATime, "Arial Bold", 0, gi_3132, gi_3000); else LABEL("START_TIME_", "[Time] Start " + StartEATime, "Arial Bold", 0, gi_3132, gi_3024); if (StrToTime(EndEATime) > TimeLocal()) LABEL("END_TIME_", " End " + EndEATime, "Arial Bold", 180, gi_3132, gi_3000); else LABEL("END_TIME_", " End " + EndEATime, "Arial Bold", 180, gi_3132, gi_3024); if (gi_392 == FALSE) { if (Hedging == TRUE || gi_300 == TRUE) { if (StrToTime(StopLoopTime) > TimeLocal()) LABEL("STOP_LOOP_TIME_", "[Loop End Time] " + StopLoopTime, "Arial Bold", 0, gi_3136, gi_3000); else LABEL("STOP_LOOP_TIME_", "[Loop End] " + StopLoopTime, "Arial Bold", 0, gi_3136, gi_3024); } } else LABEL("STOP_LOOP_TIME_", "[Loop End] " + StopLoopTime, "Arial Bold", 0, gi_3136, gi_3024); } if (CloseAll == TRUE) { gi_740 = FALSE; CloseAll(); CloseAll = FALSE; gs_2128 = "Manual"; break; } if (StopLoss < 0) StopLoss = 0; if (TimeLimit == TRUE) if (EALoop != 0) EALoop = 0; if (gi_760 == TRUE) { gi_740 = FALSE; break; } if (gi_740 == TRUE) { if (StopLoopTime > "0" && TimeLocal() > StrToTime(StopLoopTime)) if (EALoop > 0 && gi_852 != EALoop) gi_852 = EALoop; if (MaxLevelAllowed > 0) { if (gi_300 == TRUE) { if (gi_2256 > gi_2260) { if (gi_2256 > MaxLevelAllowed) { CloseAll(); gs_2128 = "MaxLevelAllowed " + MaxLevelAllowed; } } if (gi_2260 > gi_2256) { if (gi_2260 > MaxLevelAllowed) { CloseAll(); gs_2128 = "MaxLevelAllowed " + MaxLevelAllowed; } } } else { if (gi_856 > MaxLevelAllowed) { CloseAll(); gs_2128 = "MaxLevelAllowed " + MaxLevelAllowed; } } } if (MaxRiskPercentage > 0.0) { gd_1736 = 100.0 * (AccountProfit() / AccountBalance()); if (gd_1736 <= -MaxRiskPercentage) { CloseAll(); gs_2128 = "MaxRiskPercentage " + DoubleToStr(MaxRiskPercentage, 2) + " %"; } } if (MaxLoss > 0.0) { if (AccountProfit() <= -MaxLoss) { CloseAll(); gs_2128 = "MaxLoss -" + DoubleToStr(MaxLoss, 2); } } if (MaxProfit > 0.0) { DisableTrailingStop = TRUE; if (AccountProfit() >= MaxProfit) { CloseAll(); gs_2128 = "MaxProfit " + DoubleToStr(MaxProfit, 2); } } if (gi_748 == TRUE) { if (gi_1604 == FALSE) { if (BuyOrders() + SellOrders() > 0) CancelPending(); gi_1604 = TRUE; } if (Straddle == FALSE) { if (gi_392 == FALSE) { if (Hedging == TRUE) { if (TimeLimit == TRUE) if (Scalper_IsTradeTime() > 0) FirstOrder(); if (TimeLimit == FALSE) FirstOrder(); } if (Hedging == FALSE && gi_300 == FALSE && gi_348 == FALSE) FirstOrder(); if (gi_348 == TRUE) { gi_748 = FALSE; gi_744 = TRUE; } if (gi_300 == TRUE && gi_332 == FALSE) FirstOrder(); if (gi_300 == TRUE && gi_332 == TRUE) { if (BuyOpen() + SellOpen() <= 0) { gi_2796 = TRUE; if (gd_2308 > gi_336) { if (g_high_1984 == 0.0) g_high_1984 = MarketInfo(Symbol(), MODE_HIGH); if (g_low_1992 == 0.0) g_low_1992 = MarketInfo(Symbol(), MODE_LOW); g_price_1976 = g_high_1984 + gi_340 * gd_2928 + gd_2912; g_price_1968 = g_low_1992 - gi_340 * gd_2928 - gd_2912; if (BuyOrders() < 1) { if (OrderSend(Symbol(), OP_BUYLIMIT, g_lots_2372, g_price_1968, 3, 0, 0, EAComment, 0, 0, CLR_NONE) < 0) { g_price_1968 -= gd_2928; Print("Error HiLow Buy Limit = ", ErrorDescription(GetLastError())); } } if (SellOrders() < 1) { if (OrderSend(Symbol(), OP_SELLLIMIT, g_lots_2372, g_price_1976, 3, 0, 0, EAComment, 0, 0, CLR_NONE) < 0) { g_price_1976 += gd_2928; Print("Error HiLow Sell Limit = ", ErrorDescription(GetLastError())); } } for (g_pos_848 = 0; g_pos_848 < OrdersTotal(); g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) { if (OrderType() == OP_BUYLIMIT && OrderMagicNumber() != g_magic_2136) g_ord_open_price_2000 = OrderOpenPrice(); if (OrderType() == OP_SELLLIMIT && OrderMagicNumber() != g_magic_2136) g_ord_open_price_2008 = OrderOpenPrice(); } } } } if (BuyOpen() + SellOpen() > 0) { if (BuyOrders() > 0 || SellOrders() > 0) CancelPending(); if (ObjectsTotal() > 0) ObjectsDeleteAll(); gi_748 = FALSE; gi_744 = TRUE; } } } if (gi_392 == TRUE) { gi_748 = FALSE; gi_744 = TRUE; } } if (Straddle == TRUE) { if (BuyOpen() + SellOpen() <= 0) { if (BuyOrders() < 1 || SellOrders() < 1) { gd_1048 = Ask + StraddleRange * gd_2928 + gd_2912; gd_1056 = Bid - StraddleRange * gd_2928 - gd_2912; if (BuyOrders() == 0) { if (StraddleBuyPrice > 0.0) { if (StraddleRange > 0) { if (StraddleBuyPrice >= gd_1048) { g_price_1064 = StraddleBuyPrice; if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_2372, g_price_1064, 3, 0, 0, EAComment, 0, 0, CLR_NONE) == 0) continue; gd_1048 += gd_2928; } else { g_price_1064 = gd_1048; if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_2372, g_price_1064, 3, 0, 0, EAComment, 0, 0, CLR_NONE) == 0) continue; gd_1048 += gd_2928; } } if (StraddleRange == 0) { g_price_1064 = StraddleBuyPrice; if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_2372, g_price_1064, 3, 0, 0, EAComment, 0, 0, CLR_NONE) == 0) continue; gd_1048 += gd_2928; } } if (StraddleBuyPrice == 0.0) { if (StraddleRange > 0) { g_price_1064 = gd_1048; if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_2372, g_price_1064, 3, 0, 0, EAComment, 0, 0, CLR_NONE) == 0) continue; gd_1048 += gd_2928; } if (StraddleRange == 0) { if (gd_1048 == 0.0) gd_1048 = MarketInfo(Symbol(), MODE_ASK); g_price_1064 = gd_1048; if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_2372, g_price_1064, 3, 0, 0, EAComment, 0, 0, CLR_NONE) == 0) continue; gd_1048 += gd_2928; } } } if (SellOrders() == 0) { if (StraddleSellPrice > 0.0) { if (StraddleRange > 0) { if (StraddleSellPrice <= gd_1056) { g_price_1072 = StraddleSellPrice; if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_2372, g_price_1072, 3, 0, 0, EAComment, 0, 0, CLR_NONE) == 0) continue; gd_1056 -= gd_2928; } else { g_price_1072 = gd_1056; if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_2372, g_price_1072, 3, 0, 0, EAComment, 0, 0, CLR_NONE) == 0) continue; gd_1056 -= gd_2928; } } if (StraddleRange == 0) { g_price_1072 = StraddleSellPrice; if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_2372, g_price_1072, 3, 0, 0, EAComment, 0, 0, CLR_NONE) == 0) continue; gd_1056 -= gd_2928; } } if (StraddleSellPrice == 0.0) { if (StraddleRange > 0) { g_price_1072 = gd_1056; if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_2372, g_price_1072, 3, 0, 0, EAComment, 0, 0, CLR_NONE) == 0) continue; gd_1056 -= gd_2928; } if (StraddleRange == 0) { if (gd_1056 == 0.0) gd_1056 = MarketInfo(Symbol(), MODE_BID); g_price_1072 = gd_1056; if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_2372, g_price_1072, 3, 0, 0, EAComment, 0, 0, CLR_NONE) == 0) continue; gd_1056 -= gd_2928; } } } } for (g_pos_848 = 0; g_pos_848 < OrdersTotal(); g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) { if (OrderType() == OP_BUYSTOP && OrderMagicNumber() != g_magic_2136) { g_ord_open_price_1776 = OrderOpenPrice(); if (StraddleTakeProfit <= 0) gd_1744 = 0; if (StraddleTakeProfit > 0) gd_1744 = g_price_1064 + StraddleTakeProfit * gd_2928; if (StraddleStopLoss <= 0) gd_1752 = 0; if (StraddleStopLoss > 0) gd_1752 = g_price_1064 - StraddleStopLoss * gd_2928; if (g_price_1792 <= 0.0) g_price_1792 = gd_1744; if (g_price_1800 <= 0.0) g_price_1800 = gd_1752; if (!IsEqual(OrderTakeProfit(), g_price_1792)) if (OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), g_price_1792, 0, CLR_NONE) == FALSE) g_price_1792 += gd_2928; if (!IsEqual(OrderStopLoss(), g_price_1800)) if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1800, g_price_1792, 0, CLR_NONE) == FALSE) g_price_1800 -= gd_2928; } if (OrderType() == OP_SELLSTOP && OrderMagicNumber() != g_magic_2136) { g_ord_open_price_1784 = OrderOpenPrice(); if (StraddleTakeProfit <= 0) gd_1760 = 0; if (StraddleTakeProfit > 0) gd_1760 = g_ord_open_price_1784 - StraddleTakeProfit * gd_2928; if (StraddleStopLoss <= 0) gd_1768 = 0; if (StraddleStopLoss > 0) gd_1768 = g_ord_open_price_1784 + StraddleStopLoss * gd_2928; if (g_price_1808 <= 0.0) g_price_1808 = gd_1760; if (g_price_1816 <= 0.0) g_price_1816 = gd_1768; if (!IsEqual(OrderTakeProfit(), g_price_1808)) if (OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), g_price_1808, 0, CLR_NONE) == FALSE) g_price_1808 -= gd_2928; if (!IsEqual(OrderStopLoss(), g_price_1816)) if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1816, g_price_1808, 0, CLR_NONE) == FALSE) g_price_1816 += gd_2928; } } } } if (BuyOpen() + SellOpen() > 0) { if (BuyOrders() > 0 || SellOrders() > 0) CancelPending(); gi_748 = FALSE; Straddle = FALSE; gi_744 = TRUE; if (ObjectsTotal() > 0) ObjectsDeleteAll(); } } } if (gi_392 == FALSE) { if (BuyLots() + SellLots() > 0.0) { if (BuyLots() == SellLots()) { gi_744 = FALSE; for (g_pos_848 = 0; g_pos_848 < OrdersTotal(); g_pos_848++) { if (OrderMagicNumber() != g_magic_2136) { if (OrderSelect(g_pos_848, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) { g_ord_open_price_2324 = OrderOpenPrice(); if (MarketInfo(Symbol(), MODE_BID) - g_ord_open_price_2324 >= CloseWhileHedgingProfit * gd_2928) { RefreshRates(); if (OrderClose(OrderTicket(), OrderLots(), MarketInfo(Symbol(), MODE_BID), 3, CLR_NONE) > 0) Print("Buy Hedging Position Eliminated"); else Print("Error Closing Buy Hedging = ", ErrorDescription(GetLastError())); } } if (OrderType() == OP_SELL && OrderSymbol() == Symbol()) { g_ord_open_price_2332 = OrderOpenPrice(); if (g_ord_open_price_2332 - MarketInfo(Symbol(), MODE_ASK) >= CloseWhileHedgingProfit * gd_2928) { RefreshRates(); if (OrderClose(OrderTicket(), OrderLots(), MarketInfo(Symbol(), MODE_ASK), 3, CLR_NONE) > 0) Print("Sell Hedging Position Eliminated"); else Print("Error Closing Sell Hedging = ", ErrorDescription(GetLastError())); } } } } } } else gi_744 = TRUE; } } if (gi_744 == TRUE) { CheckOrder(); if (gi_2800 == TRUE) { if (gi_392 == FALSE && gi_348 == FALSE) { if (increase <= 0) increase = 0; if (increase > 0 && IncreaseEndLevel <= IncreaseStartLevel) IncreaseEndLevel = 0; if (increase > 0 && IncreaseStartLevel < 1) IncreaseStartLevel = 1; } if (gi_2100 == FALSE) { if (DCalc(gs_eurusd_788) && DCalc(gs_gbpusd_796) && DCalc(gs_eurgbp_804)) { gi_2068 = TRUE; gi_2100 = TRUE; } } if (gi_2104 == FALSE) { if (SCalc(gs_eurusd_788) || SCalc(gs_gbpusd_796) || SCalc(gs_eurgbp_804)) { gi_2072 = TRUE; gi_2104 = TRUE; } } if (gi_2108 == FALSE) { if (SCalc2(gs_eurusd_788) || SCalc2(gs_gbpusd_796)) { gi_unused_2076 = 1; gi_2108 = TRUE; } } if (gi_2112 == FALSE) { if (SCalc3(gs_eurusd_788) || SCalc3(gs_gbpusd_796)) { gi_unused_2080 = 1; gi_2112 = TRUE; } } if (gi_2116 == FALSE) { if (FrzCalc(gs_eurusd_788) || FrzCalc(gs_gbpusd_796)) { gi_unused_2084 = 1; gi_2116 = TRUE; } } if (gi_2752 == 0) { if (gi_2068 && gi_2072) gi_2752 = 1; else gi_2752 = 3; } if (Hedging == FALSE && gi_300 == FALSE && gi_392 == FALSE && gi_348 == FALSE) { gi_856 = BuyOpen() + SellOpen(); for (g_pos_848 = 0; g_pos_848 < OrdersTotal(); g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) { if (OrderMagicNumber() != g_magic_2136) { if (OrderType() == OP_BUY) { gd_2824 += OrderLots(); g_ord_open_price_2816 = OrderOpenPrice(); } if (OrderType() == OP_SELL) { gd_2872 += OrderLots(); g_ord_open_price_2864 = OrderOpenPrice(); } if (OrderType() == OP_BUYSTOP) gd_2832 += OrderLots(); if (OrderType() == OP_SELLSTOP) gd_2880 += OrderLots(); } } } if (TakeProfit <= 0) { g_price_2848 = 0; g_price_2896 = 0; } if (TakeProfit > 0) { g_price_2848 = g_ord_open_price_2816 + TakeProfit * gd_2928; g_price_2896 = g_ord_open_price_2864 - TakeProfit * gd_2928; } if (StopLoss > 0) { g_price_2840 = g_ord_open_price_2816 - StopLoss * gd_2928; g_price_2888 = g_ord_open_price_2864 + StopLoss * gd_2928; } for (g_pos_848 = 0; g_pos_848 < OrdersTotal(); g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_2136) { if (OrderType() == OP_BUY) { if (!IsEqual(OrderTakeProfit(), g_price_2848) || !IsEqual(OrderStopLoss(), g_price_2840)) { if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2840, g_price_2848, 0, CLR_NONE)) { } } } if (OrderType() == OP_SELL) { if (!IsEqual(OrderTakeProfit(), g_price_2896) || !IsEqual(OrderStopLoss(), g_price_2888)) { if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2888, g_price_2896, 0, CLR_NONE)) { } } } if (OrderType() == OP_BUYSTOP) { if (SellOpen() < 1) OrderDelete(OrderTicket()); if (!IsEqual(OrderTakeProfit(), g_price_2848) || !IsEqual(OrderStopLoss(), g_price_2840)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2840, g_price_2848, 0, CLR_NONE); } if (OrderType() == OP_SELLSTOP) { if (BuyOpen() < 1) OrderDelete(OrderTicket()); if (!IsEqual(OrderTakeProfit(), g_price_2896) || !IsEqual(OrderStopLoss(), g_price_2888)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2888, g_price_2896, 0, CLR_NONE); } } } } } if (Hedging == TRUE) { if (gi_1640 == gi_2760 && gi_856 > gi_2568) CheckPos(); if (BuyOpen() + SellOpen() > 0) gi_856 = BuyOpen() + SellOpen(); for (g_pos_848 = 0; g_pos_848 < OrdersTotal(); g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) { if (OrderMagicNumber() != g_magic_2136) { if (OrderType() == OP_BUY) { gd_2824 += OrderLots(); g_ord_open_price_2816 = OrderOpenPrice(); g_ord_lots_920 = OrderLots(); } if (OrderType() == OP_SELL) { gd_2872 += OrderLots(); g_ord_open_price_2864 = OrderOpenPrice(); g_ord_lots_928 = OrderLots(); } if (OrderType() == OP_BUYSTOP) gd_2832 += OrderLots(); if (OrderType() == OP_SELLSTOP) gd_2880 += OrderLots(); } } } if (gi_2752 <= 0) return (0); if (BuyLots() > SellLots()) { if (Multiplier == 0.0) g_lots_2904 = 2.0 * BuyLots() - SellLots(); if (Multiplier == 1.0) g_lots_2904 = g_ord_lots_920 + g_lots_2372; if (Multiplier > 0.0 && Multiplier != 1.0) { gd_2728 = g_ord_lots_920 * Multiplier; g_lots_2904 = MathRound(gd_2728 / MarketInfo(Symbol(), MODE_LOTSTEP)) * MarketInfo(Symbol(), MODE_LOTSTEP); } if (NormalizeDouble(g_lots_2904, 4) > NormalizeDouble(gd_2880, 4)) { if (gd_1688 == 0.0) gd_1688 = gd_2824; if (gd_1688 != gd_2824) { gd_1688 = gd_2824; CancelPending(); } if (increase > 0) { if (gi_856 >= IncreaseStartLevel) { if (IncreaseEndLevel == 0) gi_884 = gi_856 - IncreaseStartLevel + 1; if (IncreaseEndLevel > 0 && gi_856 <= IncreaseEndLevel) gi_884 = gi_856 - IncreaseStartLevel + 1; if (gd_1144 > 0.0) g_price_1864 = g_ord_open_price_2816 - HedgeGap * gd_2928 - 2.0 * gd_1144 - gi_884 * increase * gd_2928 - gd_2912; else g_price_1864 = g_ord_open_price_2816 - HedgeGap * gd_2928 - gi_884 * increase * gd_2928 - gd_2912; } if (gi_856 < IncreaseStartLevel) { if (gd_1144 > 0.0) g_price_1864 = g_ord_open_price_2816 - HedgeGap * gd_2928 - 2.0 * gd_1144 - gd_2912; else g_price_1864 = g_ord_open_price_2816 - HedgeGap * gd_2928 - gd_2912; } } else { if (gd_1144 > 0.0) g_price_1864 = g_ord_open_price_2816 - HedgeGap * gd_2928 - 2.0 * gd_1144 - gd_2912; else g_price_1864 = g_ord_open_price_2816 - HedgeGap * gd_2928 - gd_2912; } g_bid_952 = MarketInfo(Symbol(), MODE_BID); if (g_bid_952 < g_price_1864) { gd_944 = g_price_1864 - g_bid_952; while (true) { g_price_1864 = Bid; g_ticket_780 = OrderSend(Symbol(), OP_SELL, g_lots_2904, g_price_1864, 3, 0, 0, EAComment, 0, 0, CLR_NONE); if (g_ticket_780 > -1) { Print("Sell Counter @ ", DoubleToStr(g_price_1864, Digits)); break; } g_error_2804 = GetLastError(); switch (g_error_2804) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { Sleep(1); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); Sleep(300); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); Sleep(300); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", g_error_2804, " occured"); Sleep(10); RefreshRates(); } } if (GapAdjustment == TRUE) gd_1144 += gd_944; else gd_1144 = 0; } if (g_bid_952 >= g_price_1864) { while (true) { if (NormalizeDouble(g_price_1864, Digits) > NormalizeDouble(Bid - gd_2936 * gd_2928, Digits)) { g_price_1864 = Bid - gd_2936 * gd_2928; Print("Changed the requested price: Price = ", g_price_1864); } if (gi_1640 == gi_2760 && gi_856 > gi_2568 && gi_856 == gi_2568 + 1) g_ticket_780 = OrderSend(Symbol(), OP_SELL, g_lots_2904, Bid, 3, 0, 0, EAComment, 0, 0, CLR_NONE); else g_ticket_780 = OrderSend(Symbol(), OP_SELLSTOP, g_lots_2904, g_price_1864, 3, 0, 0, EAComment, 0, 0, CLR_NONE); if (g_ticket_780 > -1) { Print("Sell Stop Counter @ ", DoubleToStr(g_price_1864, Digits)); break; } g_error_2804 = GetLastError(); switch (g_error_2804) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { Sleep(1); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); Sleep(300); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); Sleep(300); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", g_error_2804, " occured"); Sleep(10); RefreshRates(); } } } } if (NormalizeDouble(g_lots_2904, 4) < NormalizeDouble(gd_2880, 4)) CancelPending(); } if (SellLots() > BuyLots()) { if (Multiplier == 0.0) g_lots_2904 = 2.0 * SellLots() - BuyLots(); if (Multiplier == 1.0) g_lots_2904 = g_ord_lots_928 + g_lots_2372; if (Multiplier > 0.0 && Multiplier != 1.0) { gd_2728 = g_ord_lots_928 * Multiplier; g_lots_2904 = MathRound(gd_2728 / MarketInfo(Symbol(), MODE_LOTSTEP)) * MarketInfo(Symbol(), MODE_LOTSTEP); } if (NormalizeDouble(g_lots_2904, 4) > NormalizeDouble(gd_2832, 4)) { if (gd_1696 == 0.0) gd_1696 = gd_2872; if (gd_1696 != gd_2872) { gd_1696 = gd_2872; CancelPending(); } if (increase > 0) { if (gi_856 >= IncreaseStartLevel) { if (IncreaseEndLevel == 0) gi_884 = gi_856 - IncreaseStartLevel + 1; if (IncreaseEndLevel > 0 && gi_856 <= IncreaseEndLevel) gi_884 = gi_856 - IncreaseStartLevel + 1; if (gd_1144 > 0.0) g_price_1856 = g_ord_open_price_2864 + HedgeGap * gd_2928 + 2.0 * gd_1144 + gi_884 * increase * gd_2928 + gd_2912; else g_price_1856 = g_ord_open_price_2864 + HedgeGap * gd_2928 + gi_884 * increase * gd_2928 + gd_2912; } if (gi_856 < IncreaseStartLevel) { if (gd_1144 > 0.0) g_price_1856 = g_ord_open_price_2864 + HedgeGap * gd_2928 + 2.0 * gd_1144 + gd_2912; else g_price_1856 = g_ord_open_price_2864 + HedgeGap * gd_2928 + gd_2912; } } else { if (gd_1144 > 0.0) g_price_1856 = g_ord_open_price_2864 + HedgeGap * gd_2928 + 2.0 * gd_1144 + gd_2912; else g_price_1856 = g_ord_open_price_2864 + HedgeGap * gd_2928 + gd_2912; } g_ask_960 = MarketInfo(Symbol(), MODE_ASK); if (g_ask_960 > g_price_1856) { gd_936 = g_ask_960 - g_price_1856; while (true) { g_price_1856 = Ask; g_ticket_780 = OrderSend(Symbol(), OP_BUY, g_lots_2904, g_price_1856, 3, 0, 0, EAComment, 0, 0, CLR_NONE); if (g_ticket_780 > -1) { Print("Buy Counter @ ", DoubleToStr(g_price_1856, Digits)); break; } g_error_2804 = GetLastError(); switch (g_error_2804) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { Sleep(1); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); Sleep(300); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); Sleep(300); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", g_error_2804, " occured"); Sleep(10); RefreshRates(); } } if (GapAdjustment == TRUE) gd_1144 += gd_936; else gd_1144 = 0; } if (g_ask_960 <= g_price_1856) { while (true) { if (NormalizeDouble(g_price_1856, Digits) < NormalizeDouble(Ask + gd_2936 * gd_2928, Digits)) { g_price_1856 = Ask + gd_2936 * gd_2928; Print("Changed the requested price: Price = ", g_price_1864); } if (gi_1640 == gi_2760 && gi_856 > gi_2568 && gi_856 == gi_2568 + 1) g_ticket_780 = OrderSend(Symbol(), OP_BUY, g_lots_2904, Ask, 3, 0, 0, EAComment, 0, 0, CLR_NONE); else g_ticket_780 = OrderSend(Symbol(), OP_BUYSTOP, g_lots_2904, g_price_1856, 3, 0, 0, EAComment, 0, 0, CLR_NONE); if (g_ticket_780 > -1) { Print("Buy Stop Counter @ ", DoubleToStr(g_price_1856, Digits)); break; } g_error_2804 = GetLastError(); switch (g_error_2804) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { Sleep(1); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); Sleep(300); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); Sleep(300); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", g_error_2804, " occured"); Sleep(10); RefreshRates(); } } } } if (NormalizeDouble(g_lots_2904, 4) < NormalizeDouble(gd_2832, 4)) CancelPending(); } for (int l_pos_24 = 0; l_pos_24 < OrdersTotal(); l_pos_24++) { if (OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) { if (OrderMagicNumber() != g_magic_2136) { if (OrderType() == OP_BUYSTOP) { gd_2832 += OrderLots(); g_ord_open_price_1552 = OrderOpenPrice(); g_ord_lots_1672 = OrderLots(); } if (OrderType() == OP_SELLSTOP) { gd_2880 += OrderLots(); g_ord_open_price_1560 = OrderOpenPrice(); g_ord_lots_1680 = OrderLots(); } } } } if (TakeProfit <= 0) { g_price_2848 = 0; g_price_2896 = 0; g_price_2840 = 0; g_price_2888 = 0; } if (TakeProfit > 0) { if (GapAdjustment == FALSE) { if (gd_936 > 0.0 || gd_944 > 0.0) { if (g_price_2848 < LastOpenBuyPrice() + TakeProfit * gd_2928) { if (LastOpenBuyPrice() == 0.0) g_price_2848 = g_ord_open_price_2816 + TakeProfit * gd_2928; else g_price_2848 = LastOpenBuyPrice() + TakeProfit * gd_2928; } if (g_price_2896 == 0.0 || g_price_2896 > LastOpenSellPrice() - TakeProfit * gd_2928) { if (LastOpenSellPrice() == 0.0) g_price_2896 = g_ord_open_price_2864 - TakeProfit * gd_2928; else g_price_2896 = LastOpenSellPrice() - TakeProfit * gd_2928; } if (StopLoss == 0) { g_price_2840 = g_price_2896 - gd_2912; g_price_2888 = g_price_2848 + gd_2912; } if (StopLoss > 0) { g_price_2840 = g_ord_open_price_2816 - StopLoss * gd_2928; g_price_2888 = g_ord_open_price_2864 + StopLoss * gd_2928; } } else { if (StopLoss == 0) { if (gd_2832 > gd_2880) { g_price_2848 = g_ord_open_price_1552 + TakeProfit * gd_2928; g_price_2896 = g_ord_open_price_2864 - TakeProfit * gd_2928; g_price_2840 = g_price_2896 - gd_2912; g_price_2888 = g_price_2848 + gd_2912; } if (gd_2880 > gd_2832) { g_price_2848 = g_ord_open_price_2816 + TakeProfit * gd_2928; g_price_2896 = g_ord_open_price_1560 - TakeProfit * gd_2928; g_price_2840 = g_price_2896 - gd_2912; g_price_2888 = g_price_2848 + gd_2912; } } if (StopLoss > 0) { if (gd_2832 > gd_2880) { g_price_2848 = g_ord_open_price_1552 + TakeProfit * gd_2928; g_price_2896 = g_ord_open_price_2864 - TakeProfit * gd_2928; g_price_2840 = g_ord_open_price_1552 - StopLoss * gd_2928; g_price_2888 = g_ord_open_price_2864 + StopLoss * gd_2928; } if (gd_2880 > gd_2832) { g_price_2848 = g_ord_open_price_2816 + TakeProfit * gd_2928; g_price_2896 = g_ord_open_price_1560 - TakeProfit * gd_2928; g_price_2840 = g_ord_open_price_2816 - StopLoss * gd_2928; g_price_2888 = g_ord_open_price_1560 + StopLoss * gd_2928; } } } } if (GapAdjustment == TRUE) { if (StopLoss == 0) { if (gd_2832 > gd_2880) { g_price_2848 = g_ord_open_price_1552 + TakeProfit * gd_2928; g_price_2896 = g_ord_open_price_2864 - TakeProfit * gd_2928; g_price_2840 = g_price_2896 - gd_2912; g_price_2888 = g_price_2848 + gd_2912; } if (gd_2880 > gd_2832) { g_price_2848 = g_ord_open_price_2816 + TakeProfit * gd_2928; g_price_2896 = g_ord_open_price_1560 - TakeProfit * gd_2928; g_price_2840 = g_price_2896 - gd_2912; g_price_2888 = g_price_2848 + gd_2912; } } if (StopLoss > 0) { if (gd_2832 > gd_2880) { g_price_2848 = g_ord_open_price_1552 + TakeProfit * gd_2928; g_price_2896 = g_ord_open_price_2864 - TakeProfit * gd_2928; g_price_2840 = g_ord_open_price_1552 - StopLoss * gd_2928; g_price_2888 = g_ord_open_price_2864 + StopLoss * gd_2928; } if (gd_2880 > gd_2832) { g_price_2848 = g_ord_open_price_2816 + TakeProfit * gd_2928; g_price_2896 = g_ord_open_price_1560 - TakeProfit * gd_2928; g_price_2840 = g_ord_open_price_2816 - StopLoss * gd_2928; g_price_2888 = g_ord_open_price_1560 + StopLoss * gd_2928; } } } } if (OrderMagicNumber() != g_magic_2136) { for (g_pos_848 = 0; g_pos_848 < OrdersTotal(); g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_2136) { if (OrderType() == OP_BUY) { if (!IsEqual(OrderTakeProfit(), g_price_2848) || !IsEqual(OrderStopLoss(), g_price_2840)) { if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2840, g_price_2848, 0, CLR_NONE)) { } } } if (OrderType() == OP_SELL) { if (!IsEqual(OrderTakeProfit(), g_price_2896) || !IsEqual(OrderStopLoss(), g_price_2888)) { if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2888, g_price_2896, 0, CLR_NONE)) { } } } if (OrderType() == OP_BUYSTOP) if (!IsEqual(OrderTakeProfit(), g_price_2848) || !IsEqual(OrderStopLoss(), g_price_2840)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2840, g_price_2848, 0, CLR_NONE); if (OrderType() == OP_SELLSTOP) if (!IsEqual(OrderTakeProfit(), g_price_2896) || !IsEqual(OrderStopLoss(), g_price_2888)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2888, g_price_2896, 0, CLR_NONE); } } } } } if (DisableTrailingStop == FALSE) { if (gi_836 != gi_856) { gi_836 = gi_856; if (TrailingStop > 0) { g_bid_1152 = 0; gd_1000 = 0; gd_1080 = 0; gd_984 = 0; g_bid_968 = 0; g_ask_1160 = 0; gd_1008 = 0; gd_1088 = 0; gd_992 = 0; g_ask_976 = 0; } if (TrailingStop_2 > 0) { g_bid_1168 = 0; gd_1184 = 0; gd_1176 = 0; gd_1200 = 0; g_bid_1192 = 0; g_ask_1208 = 0; gd_1224 = 0; gd_1216 = 0; gd_1240 = 0; g_ask_1232 = 0; } if (TrailingStop_3 > 0) { g_bid_1248 = 0; gd_1264 = 0; gd_1256 = 0; gd_1280 = 0; g_bid_1272 = 0; g_ask_1288 = 0; gd_1304 = 0; gd_1296 = 0; gd_1320 = 0; g_ask_1312 = 0; } if (TrailingStop_4 > 0) { g_bid_1328 = 0; gd_1344 = 0; gd_1336 = 0; gd_1360 = 0; g_bid_1352 = 0; g_ask_1368 = 0; gd_1384 = 0; gd_1376 = 0; gd_1400 = 0; gd_1392 = 0; } if (Start_Safer) { g_bid_1408 = 0; gd_1416 = 0; gd_1424 = 0; gd_unused_1432 = 0; g_ask_1440 = 0; gd_1448 = 0; gd_1456 = 0; gd_unused_1464 = 0; } } if (TrailingStop > 0) if (TrailingStopEndLevel <= TrailingStopStartLevel) TrailingStopEndLevel = 0; if (TrailingStop > 0) if (TrailingStopStartLevel < 1) TrailingStopStartLevel = 1; if (TrailingStop_2 > 0) if (TrailingStop_2_EndLevel <= TrailingStop_2_StartLevel) TrailingStop_2_EndLevel = 0; if (TrailingStop_2 > 0) if (TrailingStop_2_StartLevel < 1) TrailingStop_2_StartLevel = 1; if (TrailingStop_3 > 0) if (TrailingStop_3_EndLevel <= TrailingStop_3_StartLevel) TrailingStop_3_EndLevel = 0; if (TrailingStop_3 > 0) if (TrailingStop_3_StartLevel < 1) TrailingStop_3_StartLevel = 1; if (TrailingStop_4 > 0) if (TrailingStop_4_EndLevel <= TrailingStop_4_StartLevel) TrailingStop_4_EndLevel = 0; if (TrailingStop_4 > 0) if (TrailingStop_4_StartLevel < 1) TrailingStop_4_StartLevel = 1; if (Start_Safer) if (Safer_EndLevel <= Safer_StartLevel) Safer_EndLevel = 0; if (Start_Safer) if (Safer_StartLevel < 1) Safer_StartLevel = 1; if (BuyLots() > SellLots()) { if (gi_300 == TRUE) gi_856 = gi_2256; for (g_pos_848 = 0; g_pos_848 < OrdersTotal(); g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY && OrderMagicNumber() != g_magic_2136) { if (TrailingStop > 0) { if (gi_856 >= TrailingStopStartLevel) { if (TrailingStopEndLevel == 0 || gi_856 < TrailingStopEndLevel) { if (AccountProfit() >= 0.0) { if (g_bid_1152 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1152) g_bid_1152 = MarketInfo(Symbol(), MODE_BID); if (MarketInfo(Symbol(), MODE_BID) - g_bid_1152 >= TrailingStop * gd_2928) { gd_1000 = MarketInfo(Symbol(), MODE_BID) - TrailingStop * gd_2928; if (gd_1080 < gd_1000) gd_1080 = gd_1000; } if (gd_1080 > 0.0) { if (MarketInfo(Symbol(), MODE_BID) > g_bid_968) { g_bid_968 = MarketInfo(Symbol(), MODE_BID); if (Rebound > 0) gd_984 = g_bid_968 - Rebound * gd_2928; } if (MarketInfo(Symbol(), MODE_BID) < gd_1080 || MarketInfo(Symbol(), MODE_BID) < gd_984) { CloseAll(); gs_2128 = "Trailing Stop Buy"; } } } if (AccountProfit() < 0.0) { g_bid_1152 = 0; gd_1080 = 0; gd_984 = 0; g_bid_968 = 0; } } } } } if (TrailingStop_2 > 0) { if (gi_856 >= TrailingStop_2_StartLevel) { if (TrailingStop_2_EndLevel == 0 || gi_856 < TrailingStop_2_EndLevel) { if (AccountProfit() >= 0.0) { if (g_bid_1168 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1168) g_bid_1168 = MarketInfo(Symbol(), MODE_BID); if (MarketInfo(Symbol(), MODE_BID) - g_bid_1168 >= TrailingStop_2 * gd_2928) { gd_1184 = MarketInfo(Symbol(), MODE_BID) - TrailingStop_2 * gd_2928; if (gd_1176 < gd_1184) gd_1176 = gd_1184; } if (gd_1176 > 0.0) { if (MarketInfo(Symbol(), MODE_BID) > g_bid_1192) { g_bid_1192 = MarketInfo(Symbol(), MODE_BID); if (Rebound_2 > 0) gd_1200 = g_bid_1192 - Rebound_2 * gd_2928; } if (MarketInfo(Symbol(), MODE_BID) < gd_1176 || MarketInfo(Symbol(), MODE_BID) < gd_1200) { CloseAll(); gs_2128 = "Trailing Stop Buy 2"; } } } if (AccountProfit() < 0.0) { g_bid_1168 = 0; gd_1176 = 0; gd_1200 = 0; g_bid_1192 = 0; } } } } if (TrailingStop_3 > 0) { if (gi_856 >= TrailingStop_3_StartLevel) { if (TrailingStop_3_EndLevel == 0 || gi_856 < TrailingStop_3_EndLevel) { if (AccountProfit() >= 0.0) { if (g_bid_1248 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1248) g_bid_1248 = MarketInfo(Symbol(), MODE_BID); if (MarketInfo(Symbol(), MODE_BID) - g_bid_1248 >= TrailingStop_3 * gd_2928) { gd_1264 = MarketInfo(Symbol(), MODE_BID) - TrailingStop_3 * gd_2928; if (gd_1256 < gd_1264) gd_1256 = gd_1264; } if (gd_1256 > 0.0) { if (MarketInfo(Symbol(), MODE_BID) > g_bid_1272) { g_bid_1272 = MarketInfo(Symbol(), MODE_BID); if (Rebound_3 > 0) gd_1280 = g_bid_1272 - Rebound_3 * gd_2928; } if (MarketInfo(Symbol(), MODE_BID) < gd_1256 || MarketInfo(Symbol(), MODE_BID) < gd_1280) { CloseAll(); gs_2128 = "Trailing Stop Buy 3"; } } } if (AccountProfit() < 0.0) { g_bid_1248 = 0; gd_1256 = 0; gd_1280 = 0; g_bid_1272 = 0; } } } } if (TrailingStop_4 > 0) { if (gi_856 >= TrailingStop_4_StartLevel) { if (TrailingStop_4_EndLevel == 0 || gi_856 < TrailingStop_4_EndLevel) { if (AccountProfit() >= 0.0) { if (g_bid_1328 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1328) g_bid_1328 = MarketInfo(Symbol(), MODE_BID); if (MarketInfo(Symbol(), MODE_BID) - g_bid_1328 >= TrailingStop_4 * gd_2928) { gd_1344 = MarketInfo(Symbol(), MODE_BID) - TrailingStop_4 * gd_2928; if (gd_1336 < gd_1344) gd_1336 = gd_1344; } if (gd_1336 > 0.0) { if (MarketInfo(Symbol(), MODE_BID) > g_bid_1352) { g_bid_1352 = MarketInfo(Symbol(), MODE_BID); if (Rebound_4 > 0) gd_1360 = g_bid_1352 - Rebound_4 * gd_2928; } if (MarketInfo(Symbol(), MODE_BID) < gd_1336 || MarketInfo(Symbol(), MODE_BID) < gd_1360) { CloseAll(); gs_2128 = "Trailing Stop Buy 4"; } } } if (AccountProfit() < 0.0) { g_bid_1328 = 0; gd_1336 = 0; gd_1360 = 0; g_bid_1352 = 0; } } } } if (Start_Safer) { if (gi_856 >= Safer_StartLevel) { if (Safer_EndLevel == 0 || gi_856 < Safer_EndLevel) { if (Safer_Money_CutLoss > 0.0) { if (AccountProfit() >= -NormalizeDouble(Safer_Money_CutLoss, 2)) { CloseAll(); gs_2128 = "Safer_Money_CutLoss Buy"; } } if (AccountProfit() >= 0.0) if (g_bid_1408 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1408) g_bid_1408 = MarketInfo(Symbol(), MODE_BID); if (g_bid_1408 > 0.0) { if (Safer >= 0) { if (MarketInfo(Symbol(), MODE_BID) - g_bid_1408 >= Safer * gd_2928) { gd_1416 = MarketInfo(Symbol(), MODE_BID) - Safer * gd_2928; if (gd_1424 < gd_1416) gd_1424 = gd_1416; } } if (Safer < 0) { gd_1416 = g_bid_1408 + Safer * gd_2928; if (gd_1424 < gd_1416) gd_1424 = gd_1416; } } if (gd_1424 > 0.0) { if (MarketInfo(Symbol(), MODE_BID) < gd_1424) { CloseAll(); gs_2128 = "Safer Buy"; } } if (Safer > 0 && AccountProfit() < 0.0) g_bid_1408 = 0; } } } } } } if (SellLots() > BuyLots()) { if (gi_300 == TRUE) gi_856 = gi_2260; for (g_pos_848 = 0; g_pos_848 < OrdersTotal(); g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) { if (OrderType() == OP_SELL && OrderMagicNumber() != g_magic_2136) { if (TrailingStop > 0) { if (gi_856 >= TrailingStopStartLevel) { if (TrailingStopEndLevel == 0 || gi_856 < TrailingStopEndLevel) { if (AccountProfit() >= 0.0) { if (g_ask_1160 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1160) g_ask_1160 = MarketInfo(Symbol(), MODE_ASK); if (g_ask_1160 - MarketInfo(Symbol(), MODE_ASK) >= TrailingStop * gd_2928) { gd_1008 = MarketInfo(Symbol(), MODE_ASK) + TrailingStop * gd_2928; if (gd_1088 == 0.0 || gd_1088 > gd_1008) gd_1088 = gd_1008; } if (gd_1088 > 0.0) { if (g_ask_976 == 0.0 || MarketInfo(Symbol(), MODE_ASK) < g_ask_976) { g_ask_976 = MarketInfo(Symbol(), MODE_ASK); if (Rebound > 0) gd_992 = g_ask_976 + Rebound * gd_2928; } if (MarketInfo(Symbol(), MODE_ASK) > gd_1088 || MarketInfo(Symbol(), MODE_ASK) > gd_992) { CloseAll(); gs_2128 = "Trailing Stop Sell"; } } } if (AccountProfit() < 0.0) { g_ask_1160 = 0; gd_1088 = 0; gd_992 = 0; g_ask_976 = 0; } } } } } if (TrailingStop_2 > 0) { if (gi_856 >= TrailingStop_2_StartLevel) { if (TrailingStop_2_EndLevel == 0 || gi_856 < TrailingStop_2_EndLevel) { if (AccountProfit() >= 0.0) { if (g_ask_1208 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1208) g_ask_1208 = MarketInfo(Symbol(), MODE_ASK); if (g_ask_1208 - MarketInfo(Symbol(), MODE_ASK) >= TrailingStop_2 * gd_2928) { gd_1224 = MarketInfo(Symbol(), MODE_ASK) + TrailingStop_2 * gd_2928; if (gd_1216 == 0.0 || gd_1216 > gd_1224) gd_1216 = gd_1224; } if (gd_1216 > 0.0) { if (g_ask_1232 == 0.0 || MarketInfo(Symbol(), MODE_ASK) < g_ask_1232) { g_ask_1232 = MarketInfo(Symbol(), MODE_ASK); if (Rebound_2 > 0) gd_1240 = g_ask_1232 + Rebound_2 * gd_2928; } if (MarketInfo(Symbol(), MODE_ASK) > gd_1216 || MarketInfo(Symbol(), MODE_ASK) > gd_1240) { CloseAll(); gs_2128 = "Trailing Stop Sell 2"; } } } if (AccountProfit() < 0.0) { g_ask_1208 = 0; gd_1216 = 0; gd_1240 = 0; g_ask_1232 = 0; } } } } if (TrailingStop_3 > 0) { if (gi_856 >= TrailingStop_3_StartLevel) { if (TrailingStop_3_EndLevel == 0 || gi_856 < TrailingStop_3_EndLevel) { if (AccountProfit() >= 0.0) { if (g_ask_1288 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1288) g_ask_1288 = MarketInfo(Symbol(), MODE_ASK); if (g_ask_1288 - MarketInfo(Symbol(), MODE_ASK) >= TrailingStop_3 * gd_2928) { gd_1304 = MarketInfo(Symbol(), MODE_ASK) + TrailingStop_3 * gd_2928; if (gd_1296 == 0.0 || gd_1296 > gd_1304) gd_1296 = gd_1304; } if (gd_1296 > 0.0) { if (g_ask_1312 == 0.0 || MarketInfo(Symbol(), MODE_ASK) < g_ask_1312) { g_ask_1312 = MarketInfo(Symbol(), MODE_ASK); if (Rebound_3 > 0) gd_1320 = g_ask_1312 + Rebound_3 * gd_2928; } if (MarketInfo(Symbol(), MODE_ASK) > gd_1296 || MarketInfo(Symbol(), MODE_ASK) > gd_1320) { CloseAll(); gs_2128 = "Trailing Stop Sell 3"; } } } if (AccountProfit() < 0.0) { g_ask_1288 = 0; gd_1296 = 0; gd_1320 = 0; g_ask_1312 = 0; } } } } if (TrailingStop_4 > 0) { if (gi_856 >= TrailingStop_4_StartLevel) { if (TrailingStop_4_EndLevel == 0 || gi_856 < TrailingStop_4_EndLevel) { if (AccountProfit() >= 0.0) { if (g_ask_1368 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1368) g_ask_1368 = MarketInfo(Symbol(), MODE_ASK); if (g_ask_1368 - MarketInfo(Symbol(), MODE_ASK) >= TrailingStop_4 * gd_2928) { gd_1384 = MarketInfo(Symbol(), MODE_ASK) + TrailingStop_4 * gd_2928; if (gd_1376 == 0.0 || gd_1376 > gd_1384) gd_1376 = gd_1384; } if (gd_1376 > 0.0) { if (gd_1392 == 0.0 || MarketInfo(Symbol(), MODE_ASK) < gd_1392) { g_ask_1312 = MarketInfo(Symbol(), MODE_ASK); if (Rebound_4 > 0) gd_1400 = gd_1392 + Rebound_4 * gd_2928; } if (MarketInfo(Symbol(), MODE_ASK) > gd_1376 || MarketInfo(Symbol(), MODE_ASK) > gd_1400) { CloseAll(); gs_2128 = "Trailing Stop Sell 4"; } } } if (AccountProfit() < 0.0) { g_ask_1368 = 0; gd_1376 = 0; gd_1400 = 0; gd_1392 = 0; } } } } if (Start_Safer) { if (gi_856 >= Safer_StartLevel) { if (Safer_EndLevel == 0 || gi_856 < Safer_EndLevel) { if (Safer_Money_CutLoss > 0.0) { if (AccountProfit() >= -NormalizeDouble(Safer_Money_CutLoss, 2)) { CloseAll(); gs_2128 = "Safer_Money_CutLoss Sell"; } } if (AccountProfit() >= 0.0) if (g_ask_1440 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1440) g_ask_1440 = MarketInfo(Symbol(), MODE_ASK); if (g_ask_1440 > 0.0) { if (Safer >= 0) { if (g_ask_1440 - MarketInfo(Symbol(), MODE_ASK) >= Safer * gd_2928) { gd_1448 = MarketInfo(Symbol(), MODE_ASK) + Safer * gd_2928; if (gd_1456 == 0.0 || gd_1456 > gd_1448) gd_1456 = gd_1448; } } if (Safer < 0) { gd_1448 = g_ask_1440 - Safer * gd_2928; if (gd_1456 == 0.0 || gd_1456 > gd_1448) gd_1456 = gd_1448; } } if (gd_1456 > 0.0) { if (MarketInfo(Symbol(), MODE_ASK) > gd_1456) { CloseAll(); gs_2128 = "Safer Sell"; } } if (Safer > 0 && AccountProfit() < 0.0) g_ask_1440 = 0; } } } } } } } if (Doubler == TRUE) { if (DoublerEndLevel <= DoublerStartLevel) DoublerEndLevel = 0; if (DoublerStartLevel < 1) DoublerStartLevel = 1; if (DoublerMaxOrder < 0) DoublerMaxOrder = 0; if (gi_836 != gi_856) { gi_836 = gi_856; if (g_count_1584 > 0 || g_count_1588 > 0) { g_count_1584 = 0; g_count_1588 = 0; } } if (AllBuyLots() > AllSellLots()) { if (gi_300 == TRUE) gi_856 = gi_2256; if (gi_856 >= DoublerStartLevel) { if (DoublerEndLevel == 0 || gi_856 < DoublerEndLevel) { if (DoublerMaxOrder == 0 || g_count_1584 < DoublerMaxOrder) { if (AccountProfit() >= 0.0) { if (DoublerBuyLots() == 0.0) { if (g_lots_1536 > 0.0) { if (DoublerMultiplier <= 0.0 || DoublerMultiplier == 1.0) if (DoublerAddition > 0.0) g_lots_1536 = g_ord_lots_1568 + DoublerAddition; if (DoublerMultiplier > 0.0 && DoublerMultiplier != 1.0) { if (DoublerAddition <= 0.0) { gd_2736 = g_ord_lots_1568 * DoublerMultiplier; g_lots_1536 = MathRound(gd_2736 / MarketInfo(Symbol(), MODE_LOTSTEP)) * MarketInfo(Symbol(), MODE_LOTSTEP); } if (DoublerAddition > 0.0) { gd_2736 = g_ord_lots_1568 * DoublerMultiplier + DoublerAddition; g_lots_1536 = MathRound(gd_2736 / MarketInfo(Symbol(), MODE_LOTSTEP)) * MarketInfo(Symbol(), MODE_LOTSTEP); } } } else g_lots_1536 = DoublerLotSize; if (g_ask_1472 == 0.0) g_ask_1472 = MarketInfo(Symbol(), MODE_ASK); if (g_ask_1472 > 0.0) if (MarketInfo(Symbol(), MODE_ASK) < g_ask_1472) g_ask_1472 = MarketInfo(Symbol(), MODE_ASK); gd_1488 = g_ask_1472 + DoublerRangeFromProfit * gd_2928; if (MarketInfo(Symbol(), MODE_ASK) >= g_ask_1472 + DoublerRangeFromProfit * gd_2928) { if (OrderSend(Symbol(), OP_BUY, g_lots_1536, MarketInfo(Symbol(), MODE_ASK), 3, 0, 0, EAComment, g_magic_2136, 0, CLR_NONE) > 0) { g_count_1584++; g_price_1720 = 0; g_price_1704 = 0; } } } } else { gd_1488 = 0; g_ask_1472 = 0; } } } } } if (AllSellLots() > AllBuyLots()) { if (gi_300 == TRUE) gi_856 = gi_2260; if (gi_856 >= DoublerStartLevel) { if (DoublerEndLevel == 0 || gi_856 < DoublerEndLevel) { if (DoublerMaxOrder == 0 || g_count_1588 < DoublerMaxOrder) { if (AccountProfit() >= 0.0) { if (DoublerSellLots() == 0.0) { if (g_lots_1544 > 0.0) { if (DoublerMultiplier <= 0.0 || DoublerMultiplier == 1.0) if (DoublerAddition > 0.0) g_lots_1544 = g_ord_lots_1576 + DoublerAddition; if (DoublerMultiplier > 0.0 && DoublerMultiplier != 1.0) { if (DoublerAddition <= 0.0) { gd_2744 = g_ord_lots_1576 * DoublerMultiplier; g_lots_1544 = MathRound(gd_2744 / MarketInfo(Symbol(), MODE_LOTSTEP)) * MarketInfo(Symbol(), MODE_LOTSTEP); } if (DoublerAddition > 0.0) { gd_2744 = g_ord_lots_1576 * DoublerMultiplier + DoublerAddition; g_lots_1544 = MathRound(gd_2744 / MarketInfo(Symbol(), MODE_LOTSTEP)) * MarketInfo(Symbol(), MODE_LOTSTEP); } } } else g_lots_1544 = DoublerLotSize; if (g_bid_1480 == 0.0) g_bid_1480 = MarketInfo(Symbol(), MODE_BID); if (g_bid_1480 > 0.0) if (MarketInfo(Symbol(), MODE_BID) > g_bid_1480) g_bid_1480 = MarketInfo(Symbol(), MODE_BID); gd_1496 = g_bid_1480 - DoublerRangeFromProfit * gd_2928; if (MarketInfo(Symbol(), MODE_BID) <= g_bid_1480 - DoublerRangeFromProfit * gd_2928) { if (OrderSend(Symbol(), OP_SELL, g_lots_1544, MarketInfo(Symbol(), MODE_BID), 3, 0, 0, EAComment, g_magic_2136, 0, CLR_NONE) > 0) { g_count_1588++; g_price_1728 = 0; g_price_1712 = 0; } } } } else { gd_1496 = 0; g_bid_1480 = 0; } } } } } for (g_pos_848 = 0; g_pos_848 < OrdersTotal(); g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) { if (OrderMagicNumber() == g_magic_2136) { if (OrderType() == OP_BUY) { g_ord_open_price_1840 = OrderOpenPrice(); g_ord_lots_1568 = OrderLots(); gd_1824 += OrderLots(); if (DoublerTakeProfit <= 0) gd_1504 = 0; if (DoublerTakeProfit > 0) gd_1504 = g_ord_open_price_1840 + DoublerTakeProfit * gd_2928; if (DoublerStopLoss <= 0) gd_1512 = 0; if (DoublerStopLoss > 0) gd_1512 = g_ord_open_price_1840 - DoublerStopLoss * gd_2928; if (g_price_1704 == 0.0) g_price_1704 = gd_1504; if (g_price_1720 == 0.0) g_price_1720 = gd_1512; if (!IsEqual(OrderStopLoss(), g_price_1720)) if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1720, OrderTakeProfit(), 0, CLR_NONE) == FALSE) g_price_1720 -= gd_2928; if (!IsEqual(OrderTakeProfit(), g_price_1704)) if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1720, g_price_1704, 0, CLR_NONE) == FALSE) g_price_1704 += gd_2928; } if (OrderType() == OP_SELL) { g_ord_open_price_1848 = OrderOpenPrice(); g_ord_lots_1576 = OrderLots(); gd_1832 += OrderLots(); if (DoublerTakeProfit <= 0) gd_1520 = 0; if (DoublerTakeProfit > 0) gd_1520 = g_ord_open_price_1848 - DoublerTakeProfit * gd_2928; if (DoublerStopLoss <= 0) gd_1528 = 0; if (DoublerStopLoss > 0) gd_1528 = g_ord_open_price_1848 + DoublerStopLoss * gd_2928; if (g_price_1712 == 0.0) g_price_1712 = gd_1520; if (g_price_1728 == 0.0) g_price_1728 = gd_1528; if (!IsEqual(OrderStopLoss(), g_price_1728)) if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1728, OrderTakeProfit(), 0, CLR_NONE) == FALSE) g_price_1728 += gd_2928; if (!IsEqual(OrderTakeProfit(), g_price_1712)) if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1728, g_price_1712, 0, CLR_NONE) == FALSE) g_price_1712 -= gd_2928; } } } } } } if (BuyLots() + SellLots() > 0.0) LABEL("ACTIVEORDERS_", "Active: " + gi_832, "Arial Bold", 270, gi_3044, gi_2988); else LABEL("ACTIVEORDERS_", "Total Active: " + gi_832, "Arial Bold", 270, gi_3044, gi_3024); gs_2944 = ""; gs_2952 = ""; if (BuyLots() > 0.0) { gs_2944 = " lots @" + DoubleToStr(g_ord_open_price_2816, Digits) + " TP: " + DoubleToStr(g_price_2848, Digits) + " SL: " + DoubleToStr(g_price_2840, Digits); LABEL("BUY_", "Active Buy: " + DoubleToStr(gd_2824, 2) + gs_2944, "Arial Bold", 0, gi_3048, gi_2992); } else LABEL("BUY_", "Active Buy: " + DoubleToStr(gd_2824, 2) + gs_2944, "Arial Bold", 0, gi_3048, gi_3024); if (SellLots() > 0.0) { gs_2952 = " lots @" + DoubleToStr(g_ord_open_price_2864, Digits) + " TP: " + DoubleToStr(g_price_2896, Digits) + " SL: " + DoubleToStr(g_price_2888, Digits); LABEL("SELL_", "Active Sell: " + DoubleToStr(gd_2872, 2) + gs_2952, "Arial Bold", 0, gi_3052, gi_3000); } else LABEL("SELL_", "Active Sell: " + DoubleToStr(gd_2872, 2) + gs_2952, "Arial Bold", 0, gi_3052, gi_3024); if (gd_2832 > 0.0) { gs_2152 = ""; gs_2152 = " lots @" + DoubleToStr(g_ord_open_price_1552, Digits) + " TP: " + DoubleToStr(g_price_2848, Digits) + " SL: " + DoubleToStr(g_price_2840, Digits); LABEL("PENDING_BUY", "Pending Buy Lots: " + DoubleToStr(g_ord_lots_1672, 2) + gs_2152, "Arial Bold", 0, gi_3056, gi_2984); } else ObjectDelete("PENDING_BUY"); if (gd_2880 > 0.0) { gs_2160 = ""; gs_2160 = " lots @" + DoubleToStr(g_ord_open_price_1560, Digits) + " TP: " + DoubleToStr(g_price_2896, Digits) + " SL: " + DoubleToStr(g_price_2888, Digits); LABEL("PENDING_SELL", "Pending Sell Lots: " + DoubleToStr(g_ord_lots_1680, 2) + gs_2160, "Arial Bold", 0, gi_3056, gi_2984); } else ObjectDelete("PENDING_SELL"); if (gi_300 == TRUE || Hedging == TRUE) { if (EALoop > 0) LABEL("LOOP_", "Loop: " + gi_852 + " of " + EALoop, "Arial Bold", 280, gi_3068, gi_3012); else { if (TimeLimit == TRUE) { if (DST_Time) LABEL("LOOP_", "Loop: ON TLimit: " + gi_2044 + "-" + gi_2048 + " GMT (DST)", "Arial Bold", 350, gi_3068, gi_3012); else LABEL("LOOP_", "Loop: ON TLimit: " + gi_2044 + "-" + gi_2048 + " GMT (EST)", "Arial Bold", 350, gi_3068, gi_3012); } if (TimeLimit == FALSE) LABEL("LOOP_", "Loop: ON", "Arial Bold", 280, gi_3068, gi_3012); } } else ObjectDelete("LOOP_"); } } } Sleep(100); return (0); } bool IsEqual(double ad_0, double ad_8) { if (NormalizeDouble(ad_0, Digits) == NormalizeDouble(ad_8, Digits)) return (TRUE); return (FALSE); } int Crossed(double ad_0, double ad_8) { if (ad_0 <= ad_8) gi_3144 = 1; if (ad_0 > ad_8) gi_3144 = 2; if (gi_3144 != gi_3140) gi_3140 = gi_3144; return (gi_3144); } int BuyOrders() { g_count_820 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) { if (OrderMagicNumber() != g_magic_2136 && OrderSymbol() == Symbol()) if (OrderType() == OP_BUYSTOP || OrderType() == OP_BUYLIMIT) g_count_820++; } } return (g_count_820); } int djcal(string a_symbol_0) { int l_digits_8 = MarketInfo(a_symbol_0, MODE_DIGITS); if (l_digits_8 > 4 || l_digits_8 == 3) return (1); return (0); } int sjcal(string a_symbol_0) { int li_8 = MarketInfo(a_symbol_0, MODE_STOPLEVEL); if (gi_1668) li_8 = li_8 / 10.0; if (li_8 <= 5) return (1); return (0); } int sjminlot(string a_symbol_0) { double l_minlot_8 = MarketInfo(a_symbol_0, MODE_MINLOT); if (l_minlot_8 == 0.1) return (1); return (0); } int sjminlot2(string a_symbol_0) { double l_minlot_8 = MarketInfo(a_symbol_0, MODE_MINLOT); if (l_minlot_8 == 0.01) return (1); return (0); } int SellOrders() { g_count_824 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) { if (OrderMagicNumber() != g_magic_2136 && OrderSymbol() == Symbol()) if (OrderType() == OP_SELLSTOP || OrderType() == OP_SELLLIMIT) g_count_824++; } } return (g_count_824); } int SellOpen() { int l_cmd_4; g_count_816 = 0; g_ord_total_844 = OrdersTotal(); int l_cmd_0 = -1; for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS)) { if (OrderMagicNumber() != g_magic_2136) { l_cmd_4 = OrderType(); if (l_cmd_4 == OP_SELL) { l_cmd_0 = l_cmd_4; if (l_cmd_0 != -1) g_count_816++; } } } } return (g_count_816); } int sjcal2(string as_unused_0) { int li_8 = MarketInfo(Symbol(), MODE_STOPLEVEL); if (gi_1668) li_8 = li_8 / 10.0; if (li_8 > 11) return (1); return (0); } int sjcal3(string as_unused_0) { int li_8 = MarketInfo(Symbol(), MODE_STOPLEVEL); if (gi_1668) li_8 = li_8 / 10.0; if (li_8 == 10) return (1); return (0); } int frz(string a_symbol_0) { int l_freezelevel_8 = MarketInfo(a_symbol_0, MODE_FREEZELEVEL); if (l_freezelevel_8 == 3) return (1); return (0); } int BuyOpen() { int l_cmd_4; g_count_812 = 0; g_ord_total_844 = OrdersTotal(); int l_cmd_0 = -1; for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS)) { if (OrderMagicNumber() != g_magic_2136) { l_cmd_4 = OrderType(); if (l_cmd_4 == OP_BUY) { l_cmd_0 = l_cmd_4; if (l_cmd_0 != -1) g_count_812++; } } } } return (g_count_812); } double TotalCorrBuyPos() { double ld_ret_0 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) { if (OrderMagicNumber() != g_magic_2136) { if (OrderSymbol() == gs_eurusd_376 || OrderSymbol() == gs_usdchf_384) if (OrderType() == OP_BUY) ld_ret_0 += 1.0; } } } return (ld_ret_0); } double TotalCorrSellPos() { double ld_ret_0 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) { if (OrderMagicNumber() != g_magic_2136) { if (OrderSymbol() == gs_eurusd_376 || OrderSymbol() == gs_usdchf_384) if (OrderType() == OP_SELL) ld_ret_0 += 1.0; } } } return (ld_ret_0); } double BuyLots() { gd_888 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_2136) gd_888 += OrderLots(); } return (gd_888); } double SellLots() { gd_896 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_2136) gd_896 += OrderLots(); } return (gd_896); } double AllBuyLots() { gd_888 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) gd_888 += OrderLots(); } return (gd_888); } double AllSellLots() { gd_896 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) if (OrderType() == OP_SELL && OrderSymbol() == Symbol()) gd_896 += OrderLots(); } return (gd_896); } double LastOpenBuyPrice() { g_ord_open_price_1016 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) { if (OrderMagicNumber() != g_magic_2136) if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) g_ord_open_price_1016 = OrderOpenPrice(); } } return (g_ord_open_price_1016); } double LastOpenSellPrice() { g_ord_open_price_1024 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) { if (OrderMagicNumber() != g_magic_2136) if (OrderType() == OP_SELL && OrderSymbol() == Symbol()) g_ord_open_price_1024 = OrderOpenPrice(); } } return (g_ord_open_price_1024); } double DoublerBuyLots() { gd_888 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) { if (OrderMagicNumber() == g_magic_2136) if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) gd_888 += OrderLots(); } } return (gd_888); } double DoublerSellLots() { gd_896 = 0; g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 0; g_pos_848 < g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) { if (OrderMagicNumber() == g_magic_2136) if (OrderType() == OP_SELL && OrderSymbol() == Symbol()) gd_896 += OrderLots(); } } return (gd_896); } int DCalc(string a_symbol_0) { int l_digits_8 = MarketInfo(a_symbol_0, MODE_DIGITS); if (l_digits_8 > 4 || l_digits_8 == 3) return (1); return (0); } int SCalc(string a_symbol_0) { int li_8 = MarketInfo(a_symbol_0, MODE_STOPLEVEL); if (gi_2068) li_8 = li_8 / 10.0; if (li_8 <= 5) return (1); return (0); } void CheckOrder() { if (gi_392 == FALSE) { if (gi_348 == TRUE) gi_832 = TotalCorrBuyPos() + TotalCorrSellPos(); if (gi_348 == FALSE) gi_832 = BuyOpen() + SellOpen(); if (CloseOneCloseAll == TRUE) { if (gi_828 > gi_832) { if (OrdersTotal() > 0) { gi_2800 = FALSE; CloseAll(); } if (gs_2128 == "") gs_2128 = "CloseOneCloseAll"; if (OrdersTotal() <= 0) { gi_828 = 0; CheckLoop(); } } else gi_828 = gi_832; } if (CloseOneCloseAll == FALSE) { if (BuyOrders() + SellOrders() > 0) CancelPending(); if (BuyOpen() + SellOpen() <= 0) { if (OrdersTotal() > 0) { gi_2800 = FALSE; CloseAll(); } gs_2128 = "No Open Positions"; if (OrdersTotal() <= 0) CheckLoop(); } } } if (gi_392 == TRUE) gi_748 = TRUE; } int SCalc2(string a_symbol_0) { double ld_8 = MarketInfo(a_symbol_0, MODE_STOPLEVEL); if (gi_2068) ld_8 /= 10.0; if (ld_8 > 11.0) return (1); return (0); } void CheckLoop() { gi_856 = 0; gi_2256 = 0; gi_2260 = 0; gi_1608 = FALSE; if (EALoop <= 0) { MessageDisplay(); gd_2292 = 0; if (gi_332 == TRUE) { if (ObjectsTotal() > 0) ObjectsDeleteAll(); } else LoopObjDelete(); gi_748 = TRUE; gi_2800 = TRUE; } if (EALoop > 0) { if (gi_852 < EALoop) { MessageDisplay(); gd_2292 = 0; gi_852++; if (gi_332 == TRUE) { if (ObjectsTotal() > 0) ObjectsDeleteAll(); } else LoopObjDelete(); gi_748 = TRUE; gi_2800 = TRUE; return; } Print("Loop End"); gi_740 = FALSE; if (OrdersTotal() > 0) CloseAll(); } } int SCalc3(string a_symbol_0) { int li_8 = MarketInfo(a_symbol_0, MODE_STOPLEVEL); if (gi_2068) li_8 = li_8 / 10.0; if (li_8 == 10) return (1); return (0); } int FrzCalc(string a_symbol_0) { int l_freezelevel_8 = MarketInfo(a_symbol_0, MODE_FREEZELEVEL); if (l_freezelevel_8 == 3) return (1); return (0); } void CancelPending() { for (g_pos_848 = OrdersTotal() - 1; g_pos_848 >= 0; g_pos_848--) { if (OrderSelect(g_pos_848, SELECT_BY_POS) != FALSE) { if (OrderType() == OP_BUYSTOP) OrderDelete(OrderTicket()); if (OrderType() == OP_SELLSTOP) OrderDelete(OrderTicket()); if (OrderType() == OP_BUYLIMIT) OrderDelete(OrderTicket()); if (OrderType() == OP_SELLLIMIT) OrderDelete(OrderTicket()); } } } void CheckPos() { double l_price_4; double l_ord_lots_12; int l_ticket_20; bool l_ord_close_24; int l_error_28; int l_cmd_32; int l_cmd_0 = -1; for (g_pos_848 = OrdersTotal() - 1; g_pos_848 >= 0; g_pos_848--) { if (OrderSelect(g_pos_848, SELECT_BY_POS)) { if (OrderSymbol() == Symbol()) { if (OrderMagicNumber() != g_magic_2136) { l_cmd_32 = OrderType(); if (l_cmd_32 <= OP_SELL) { if (OrderProfit() < 0.0) { l_ord_lots_12 = OrderLots(); l_ticket_20 = OrderTicket(); l_cmd_0 = l_cmd_32; while (true) { if (l_cmd_0 == -1) break; switch (l_cmd_0) { case OP_BUY: l_price_4 = Bid; break; case OP_SELL: l_price_4 = Ask; } l_ord_close_24 = OrderClose(l_ticket_20, l_ord_lots_12, l_price_4, 5); if (l_ord_close_24) break; l_error_28 = GetLastError(); switch (l_error_28) { case 4/* SERVER_BUSY */: Sleep(3000); break; case 135/* PRICE_CHANGED */: RefreshRates(); break; case 136/* OFF_QUOTES */: if (RefreshRates() != FALSE) break; while (true) { Sleep(1); if (RefreshRates() == FALSE) continue; break; } break; case 137/* BROKER_BUSY */: Sleep(3000); break; case 146/* TRADE_CONTEXT_BUSY */: Sleep(300); RefreshRates(); break; case 2/* COMMON_ERROR */: Sleep(300); RefreshRates(); break; case 133/* TRADE_DISABLED */: Sleep(300); RefreshRates(); } } // case 64/* ACCOUNT_DISABLED */: } } } } } } } void CloseAll() { gi_748 = FALSE; Print("Closing All Order..."); while (true) { if (OrdersTotal() <= 0) break; CloseAllSequence(1); CloseAllSequence(2); CloseAllSequence(0); CloseAllSequence(3); } } void CloseAllSequence(int ai_0) { double l_ord_lots_4; int l_ticket_12; int l_error_28; int li_32; string ls_36; double l_price_44; int li_52; int l_cmd_56; int l_cmd_16 = -1; string ls_20 = Symbol(); if (gi_2752 != gi_2756 || (gi_2752 == gi_2756 && gi_856 <= gi_2572)) { li_52 = OrdersTotal() - 1; for (g_pos_848 = li_52; g_pos_848 >= 0; g_pos_848--) { if (OrderSelect(g_pos_848, SELECT_BY_POS) == TRUE) { if (ai_0 == 1) { if (OrderSymbol() != ls_20) continue; l_cmd_56 = OrderType(); if (l_cmd_56 > OP_SELL) continue; l_ord_lots_4 = OrderLots(); l_ticket_12 = OrderTicket(); l_cmd_16 = l_cmd_56; while (true) { if (l_cmd_16 == -1) { Alert("No orders available"); break; } switch (l_cmd_16) { case OP_BUY: l_price_44 = Bid; ls_36 = "Buy"; break; case OP_SELL: l_price_44 = Ask; ls_36 = "Sell"; } Print("Attempting to close ", ls_36, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response.."); if (gi_2752 == gi_2756) Sleep(4000); li_32 = OrderClose(l_ticket_12, l_ord_lots_4, l_price_44, 3); if (li_32 == 1) { Print("Order ", ls_36, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed"); break; } l_error_28 = GetLastError(); switch (l_error_28) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { if (gi_2752 == gi_2756) Sleep(5000); else Sleep(1); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); Sleep(300); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", l_error_28, " occured"); Sleep(10); RefreshRates(); } } } if (ai_0 == 2) { if (OrderSymbol() == ls_20) continue; l_cmd_56 = OrderType(); if (l_cmd_56 > OP_SELL) continue; l_ord_lots_4 = OrderLots(); l_ticket_12 = OrderTicket(); l_cmd_16 = l_cmd_56; while (true) { if (l_cmd_16 == -1) { Alert("No orders available"); break; } switch (l_cmd_16) { case OP_BUY: l_price_44 = MarketInfo(OrderSymbol(), MODE_BID); ls_36 = "Buy"; break; case OP_SELL: l_price_44 = MarketInfo(OrderSymbol(), MODE_ASK); ls_36 = "Sell"; } Print("Attempting to close ", ls_36, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response.."); if (gi_2752 == gi_2756) Sleep(3000); li_32 = OrderClose(l_ticket_12, l_ord_lots_4, l_price_44, 3); if (li_32 == 1) { Print("Order ", ls_36, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed"); break; } l_error_28 = GetLastError(); switch (l_error_28) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { if (gi_2752 == gi_2756) Sleep(5000); else Sleep(1); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", l_error_28, " occured"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(10); RefreshRates(); } } } if (ai_0 == 0) { if (OrderSymbol() != ls_20) continue; l_cmd_56 = OrderType(); if (l_cmd_56 < OP_BUYLIMIT) continue; l_ticket_12 = OrderTicket(); l_cmd_16 = l_cmd_56; l_ord_lots_4 = OrderLots(); while (true) { if (l_cmd_16 == -1) { Alert("No orders available"); break; } switch (l_cmd_16) { case OP_BUYLIMIT: ls_36 = "Buy Limit"; break; case OP_SELLLIMIT: ls_36 = "Sell Limit"; break; case OP_BUYSTOP: ls_36 = "Buy Stop"; break; case OP_SELLSTOP: ls_36 = "Sell Stop"; } Print("Attempting to close pending ", ls_36, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response.."); if (gi_2752 == gi_2756) Sleep(4000); li_32 = OrderDelete(l_ticket_12); if (li_32 == 1) { Print("Order ", ls_36, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed"); break; } l_error_28 = GetLastError(); switch (l_error_28) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { if (gi_2752 == gi_2756) Sleep(5000); else Sleep(1); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", l_error_28, " occured"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(10); RefreshRates(); } } } if (ai_0 == 3) { if (OrderSymbol() != ls_20) { l_cmd_56 = OrderType(); if (l_cmd_56 >= OP_BUYLIMIT) { l_ticket_12 = OrderTicket(); l_cmd_16 = l_cmd_56; l_ord_lots_4 = OrderLots(); while (true) { if (l_cmd_16 == -1) { Alert("No orders available"); break; } switch (l_cmd_16) { case OP_BUYLIMIT: ls_36 = "Buy Limit"; break; case OP_SELLLIMIT: ls_36 = "Sell Limit"; break; case OP_BUYSTOP: ls_36 = "Buy Stop"; break; case OP_SELLSTOP: ls_36 = "Sell Stop"; } Print("Attempting to close pending ", ls_36, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response.."); if (gi_2752 == gi_2756) Sleep(3000); li_32 = OrderDelete(l_ticket_12); if (li_32 == 1) { Print("Order ", ls_36, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed"); break; } l_error_28 = GetLastError(); switch (l_error_28) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { if (gi_2752 == gi_2756) Sleep(5000); else Sleep(1); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", l_error_28, " occured"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(10); RefreshRates(); } } } } } } } } if (gi_2752 == gi_2756 && gi_856 > gi_2572) { g_ord_total_844 = OrdersTotal(); for (g_pos_848 = 1; g_pos_848 <= g_ord_total_844; g_pos_848++) { if (OrderSelect(g_pos_848 - 1, SELECT_BY_POS) == TRUE) { if (ai_0 == 1) { if (OrderSymbol() != ls_20) continue; l_cmd_56 = OrderType(); if (l_cmd_56 > OP_SELL) continue; l_ord_lots_4 = OrderLots(); l_ticket_12 = OrderTicket(); l_cmd_16 = l_cmd_56; while (true) { if (l_cmd_16 == -1) { Alert("No orders available"); break; } switch (l_cmd_16) { case OP_BUY: l_price_44 = Bid; ls_36 = "Buy"; break; case OP_SELL: l_price_44 = Ask; ls_36 = "Sell"; } Print("Attempting to close ", ls_36, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response.."); Sleep(7000); li_32 = OrderClose(l_ticket_12, l_ord_lots_4, l_price_44, 3); if (li_32 == 1) { Print("Order ", ls_36, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed"); break; } l_error_28 = GetLastError(); switch (l_error_28) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { Sleep(5000); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); Sleep(5000); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); Sleep(5000); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", l_error_28, " occured"); Sleep(5000); RefreshRates(); } } } if (ai_0 == 2) { if (OrderSymbol() == ls_20) continue; l_cmd_56 = OrderType(); if (l_cmd_56 > OP_SELL) continue; l_ord_lots_4 = OrderLots(); l_ticket_12 = OrderTicket(); l_cmd_16 = l_cmd_56; while (true) { if (l_cmd_16 == -1) { Alert("No orders available"); break; } switch (l_cmd_16) { case OP_BUY: l_price_44 = MarketInfo(OrderSymbol(), MODE_BID); ls_36 = "Buy"; break; case OP_SELL: l_price_44 = MarketInfo(OrderSymbol(), MODE_ASK); ls_36 = "Sell"; } Print("Attempting to close ", ls_36, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response.."); Sleep(5000); li_32 = OrderClose(l_ticket_12, l_ord_lots_4, l_price_44, 3); if (li_32 == 1) { Print("Order ", ls_36, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed"); break; } l_error_28 = GetLastError(); switch (l_error_28) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { Sleep(5000); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); Sleep(5000); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); Sleep(5000); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", l_error_28, " occured"); Sleep(5000); RefreshRates(); } } } if (ai_0 == 0) { if (OrderSymbol() != ls_20) continue; l_cmd_56 = OrderType(); if (l_cmd_56 < OP_BUYLIMIT) continue; l_ticket_12 = OrderTicket(); l_cmd_16 = l_cmd_56; l_ord_lots_4 = OrderLots(); while (true) { if (l_cmd_16 == -1) { Alert("No orders available"); break; } switch (l_cmd_16) { case OP_BUYLIMIT: ls_36 = "Buy Limit"; break; case OP_SELLLIMIT: ls_36 = "Sell Limit"; break; case OP_BUYSTOP: ls_36 = "Buy Stop"; break; case OP_SELLSTOP: ls_36 = "Sell Stop"; } Print("Attempting to close pending ", ls_36, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response.."); Sleep(5000); li_32 = OrderDelete(l_ticket_12); if (li_32 == 1) { Print("Order ", ls_36, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed"); break; } l_error_28 = GetLastError(); switch (l_error_28) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { if (gi_2752 == gi_2756) Sleep(5000); else Sleep(1); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", l_error_28, " occured"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(10); RefreshRates(); } } } if (ai_0 == 3) { if (OrderSymbol() != ls_20) { l_cmd_56 = OrderType(); if (l_cmd_56 >= OP_BUYLIMIT) { l_ticket_12 = OrderTicket(); l_cmd_16 = l_cmd_56; l_ord_lots_4 = OrderLots(); while (true) { if (l_cmd_16 == -1) { Alert("No orders available"); break; } switch (l_cmd_16) { case OP_BUYLIMIT: ls_36 = "Buy Limit"; break; case OP_SELLLIMIT: ls_36 = "Sell Limit"; break; case OP_BUYSTOP: ls_36 = "Buy Stop"; break; case OP_SELLSTOP: ls_36 = "Sell Stop"; } Print("Attempting to close pending ", ls_36, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response.."); Sleep(5000); li_32 = OrderDelete(l_ticket_12); if (li_32 == 1) { Print("Order ", ls_36, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed"); break; } l_error_28 = GetLastError(); switch (l_error_28) { case 135/* PRICE_CHANGED */: Print("The price has changed. Retrying.."); RefreshRates(); continue; break; case 136/* OFF_QUOTES */: Print("No prices. Waiting for a new tick.."); if (RefreshRates() != FALSE) continue; while (true) { if (gi_2752 == gi_2756) Sleep(5000); else Sleep(1); if (RefreshRates() == FALSE) continue; break; } continue; break; case 146/* TRADE_CONTEXT_BUSY */: Print("Trading subsystem is busy. Retrying.."); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 2/* COMMON_ERROR */: Print("Common error"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 133/* TRADE_DISABLED */: Print("Trading is prohibited"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(300); RefreshRates(); continue; break; case 64/* ACCOUNT_DISABLED */: Print("Account is blocked"); break; default: Print("Error ", l_error_28, " occured"); if (gi_2752 == gi_2756) Sleep(5000); else Sleep(10); RefreshRates(); } } } } } } } } } void LoopObjDelete() { Delete("INCREASE_"); Delete("RANGE_"); Delete("INITIALRANGE_"); Delete("TRAILINGSTOPSELL_"); Delete("TRAILINGSTOPSELL_BEP_"); Delete("TRAILINGSTOPBUY_"); Delete("TRAILINGSTOPBUY_BEP_"); Delete("TRAILINGSTOPSELL_2_"); Delete("TRAILINGSTOPSELL_2_BEP_"); Delete("TRAILINGSTOPBUY_2_"); Delete("TRAILINGSTOPBUY_2_BEP_"); Delete("TRAILINGSTOPSELL_3_"); Delete("TRAILINGSTOPSELL_3_BEP_"); Delete("TRAILINGSTOPBUY_3_"); Delete("TRAILINGSTOPBUY_3_BEP_"); Delete("TRAILINGSTOPBUY_4_"); Delete("TRAILINGSTOPBUY_4_BEP_"); Delete("TRAILINGSTOPSELL_4_"); Delete("TRAILINGSTOPSELL_4_BEP_"); Delete("TRAILINGSTOP_"); } void ObjDelete() { Delete("SEQUENCE_"); Delete("BUYROW_"); Delete("SELLROW_"); Delete("ACTIVEORDERS_"); Delete("BUY_"); Delete("SELL_"); Delete("PENDING_"); Delete("PENDING_BUY"); Delete("PENDING_SELL"); Delete("TRAILINGSTOP_"); Delete("FULLHEDGE_"); Delete("GAP_"); } void Delete(string a_name_0) { while (ObjectFind(a_name_0) == 0) ObjectDelete(a_name_0); } void MessageDisplay() { gd_2300 = AccountBalance(); if (gs_2128 == "") gs_2128 = "None"; if (gd_2300 != gd_2292) { Alert("************************************"); Alert("************************************"); Alert("Current Balance = $", DoubleToStr(gd_2300, 2)); Alert("Last Balance = $", DoubleToStr(gd_2292, 2)); if (gd_2300 > gd_2292) { Alert("Your Profit is = $", DoubleToStr(gd_2300 - gd_2292, 2)); Alert("Closed by ", gs_2128); } else { Alert("Your Loss is = $-", DoubleToStr(gd_2292 - gd_2300, 2)); Alert("Closed by ", gs_2128); } } if (gd_2300 == gd_2292) { Alert("************************************"); Alert("************************************"); Alert("************************************"); Alert("Your Current Balance is $", DoubleToStr(gd_2300, 2)); Alert("There is no profit or loss"); Alert("Closed by ", gs_2128); } } void FirstOrder() { double l_ima_0; double l_ima_8; double l_ima_16; double l_ima_24; if (BuyOpen() + SellOpen() <= 0) { if (InitialOrder == "auto" || InitialOrder == "a" || gs_2184 == "auto") { l_ima_0 = iMA(Symbol(), 0, ShortEMA, 0, MODE_EMA, PRICE_CLOSE, 0); l_ima_8 = iMA(Symbol(), 0, LongEMA, 0, MODE_EMA, PRICE_CLOSE, 0); l_ima_16 = iMA(Symbol(), 0, ShortEMA, 0, MODE_EMA, PRICE_CLOSE, 1); l_ima_24 = iMA(Symbol(), 0, LongEMA, 0, MODE_EMA, PRICE_CLOSE, 1); gi_3148 = Crossed(l_ima_8, l_ima_0); while (BuyOpen() + SellOpen() <= 0) { if (gi_3148 == 1) { RefreshRates(); if (OrderSend(Symbol(), OP_BUY, g_lots_2372, MarketInfo(Symbol(), MODE_ASK), 3, 0, 0, EAComment, 0, 0, CLR_NONE) < 0) { Print("Error Buy= ", ErrorDescription(GetLastError())); return; } } if (gi_3148 == 2) { RefreshRates(); if (OrderSend(Symbol(), OP_SELL, g_lots_2372, MarketInfo(Symbol(), MODE_BID), 3, 0, 0, EAComment, 0, 0, CLR_NONE) < 0) { Print("Error Sell = ", ErrorDescription(GetLastError())); return; } } } gs_2184 = "auto"; } if (gi_1600 == FALSE) { if (InitialOrder == "buy auto" || InitialOrder == "ba") { if (g_ask_2276 != MarketInfo(Symbol(), MODE_ASK)) g_ask_2276 = MarketInfo(Symbol(), MODE_ASK); if (OrderSend(Symbol(), OP_BUY, g_lots_2372, g_ask_2276, 3, 0, 0, EAComment, 0, 0, CLR_NONE) < 0) { Print("Error Buy= ", ErrorDescription(GetLastError())); return; } gi_1600 = TRUE; gs_2184 = "auto"; } if (InitialOrder == "sell auto" || InitialOrder == "sa") { if (g_bid_2284 != MarketInfo(Symbol(), MODE_BID)) g_bid_2284 = MarketInfo(Symbol(), MODE_BID); if (OrderSend(Symbol(), OP_SELL, g_lots_2372, g_bid_2284, 3, 0, 0, EAComment, 0, 0, CLR_NONE) < 0) { Print("Error Sell= ", ErrorDescription(GetLastError())); return; } gi_1600 = TRUE; gs_2184 = "auto"; } if (InitialOrder == "manual" || InitialOrder == "m") { gi_1600 = TRUE; gs_2184 = "auto"; gi_748 = FALSE; gi_744 = TRUE; } } } if (BuyOpen() + SellOpen() > 0) { gi_748 = FALSE; gi_744 = TRUE; } } int Scalper_IsTradeTime() { g_datetime_2060 = TimeCurrent(); int l_hour_0 = TimeHour(g_datetime_2060); if (gi_2052 < gi_2056 && l_hour_0 < gi_2052 || l_hour_0 >= gi_2056) return (0); if (gi_2052 > gi_2056 && (l_hour_0 < gi_2052 && l_hour_0 >= gi_2056)) return (0); if (gi_2056 == 0) gi_2056 = 24; if (Hour() == gi_2056 - 1 && Minute() >= 35) return (0); return (1); }