Minggu, 31 Juli 2011

ROBOT FOREX (EA)

Pada halaman ini saya ingin berbagi koleksi robot forex (EA).
semua koleksi robot Forex ini bisa anda download secara gratis.
untuk mengetahui performa robot forex ini, sebaiknya di Test dahulu pada Account Demo.
Saya berharap dengan adanya robot forex gratis ini dapat membantu pembaca baik yang akan terjun ke Forex maupun yang sudah lama berkecimpung di dunia Forex.

PESAN :
1. Jangan langsung di gunakan pada Real Account (Gunakan di account demo lebih dahulau).
2. Robot Forex bukanlah program untuk menghasilkan Profit, tapi program untuk membantu "waktu trading" anda.
3. Gunakan robot forex dengan bijak.
4. Daftar robot Forex Gratis akan terus di update di halaman ini

DAFTAR ROBOT FOREX GRATIS :
1. IndraFX scalping V5
2. Lock Profit
3. Sejuta Umat
4. Pivot Daily
5. Mrobot scalper V5
6. Mrobot scalper V6
7. Mrobot scalper V6.1
8. IndraFX scalping modif V7.1
9. Pasopati Profit
10. Cabe Rawit EA
11. Auto scalper
12. 4X2011XARDTIME FRAME V5
13. EA HIGH PROFIT EUR-USD V.6.0
14. Blessing Martiangle versi 7 modif by Profitea

Kamis, 21 Juli 2011

http://www.4shared.com/dir/-kWJDB22/sharing.html#

http://www.4shared.com/dir/-kWJDB22/sharing.html#

robot super

/*
Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
Website: http://purebeam.biz
E-mail : purebeam@gmail.com
*/
#property copyright "www.brokerfxopen.com"
#property link "abdalla27005@yahoo.co.id"
#property show_inputs

#include

string gs_76 = "www.bokerfxopen.com";
extern string Note = "*** ROBOTSUPER_X4T ***";
extern string Note1 = "This Expert Advisor is a copyright of";
extern string Note2 = "brokerfxopen.com";
extern string Note3 = "email: abdalla27005@yahoo.co.id";
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 = 0;
extern double LotSize = 0.4;
extern bool CloseOneCloseAll = TRUE;
extern bool AutoCalculateLot = FALSE;
extern bool OnlyAllowDecreaseLot = TRUE;
extern double LotEquityRatio = 1.0;
extern int CloseWhileHedgingProfit = 10;
extern string Note7 = "----- INCREMENTAL RANGE -----";
extern int increase = 15;
extern int IncreaseStartLevel = 2;
extern int IncreaseEndLevel = 7;
extern string Note8 = "----- HEDGING STRATEGY -----";
extern bool Hedging = TRUE;
extern int HedgeGap = 23;
extern double Multiplier = 0.0;
extern int TakeProfit = 150;
extern int StopLoss = 0;
extern bool GapAdjustment = FALSE;
extern string Note9 = "----- AVERAGING STRATEGY -----";
extern bool Averaging = FALSE;
extern int AveragingHedgeGap = 20;
extern double AveragingMultiplier = 2.0;
extern int AveragingTakeProfit = 50;
extern int AveragingStopLoss = 0;
extern double MaxLotStop = 0.0;
extern bool StartFromHiLow = FALSE;
extern int MinimumHiLowRange = 130;
extern int RangeFromHiLow = 5;
extern int HiLowIndicatorLevel = 0;
bool gi_300 = FALSE;
double gd_304 = 6.0;
double gd_312 = 20.0;
string gs_buy_320 = "buy";
string gs_eurusd_328 = "EURUSD";
string gs_usdchf_336 = "USDCHF";
bool gi_344 = FALSE;
bool gi_348 = FALSE;
bool gi_352 = TRUE;
double gd_356 = 0.0;
int gi_364 = 10;
int gi_368 = 20;
int gi_372 = 0;
int gi_376 = 8;
int gi_380 = 3;
int gi_384 = 15;
int gi_388 = 10;
extern string Note12 = "----- INITIAL ORDER -----";
extern string InitialOrder = "sa";
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 = 23;
extern int TrailingStopStartLevel = 1;
extern int TrailingStopEndLevel = 3;
extern int Rebound = 3;
extern string Note15 = "----- TRAILING STOP 2-----";
extern int TrailingStop_2 = 17;
extern int TrailingStop_2_StartLevel = 2;
extern int TrailingStop_2_EndLevel = 4;
extern int Rebound_2 = 2;
extern string Note16 = "----- TRAILING STOP 3-----";
extern int TrailingStop_3 = 11;
extern int TrailingStop_3_StartLevel = 3;
extern int TrailingStop_3_EndLevel = 6;
extern int Rebound_3 = 2;
extern string Note17 = "----- TRAILING STOP 4-----";
extern int TrailingStop_4 = 2;
extern int TrailingStop_4_StartLevel = 4;
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 = "0";
extern string EndEATime = "0";
extern string StopLoopTime = "0";
bool gi_684 = TRUE;
bool gi_688 = FALSE;
bool gi_692 = TRUE;
bool gi_696 = TRUE;
bool gi_unused_700 = TRUE;
bool gi_704 = FALSE;
bool gi_708 = FALSE;
bool gi_712 = TRUE;
bool gi_716 = FALSE;
bool gi_720 = FALSE;
int gi_724 = 0;
int g_count_728;
int g_count_732;
int g_count_736;
int g_count_740;
int gi_744 = 0;
int gi_748 = 0;
int gi_752;
int g_error_756;
int g_ord_total_760;
int g_pos_764;
int gi_768 = 1;
int gi_772 = 0;
int gi_776 = 0;
double gd_780;
double gd_788;
double g_ord_lots_796;
double g_ord_lots_804;
double gd_812 = 0.0;
double gd_820 = 0.0;
double g_bid_828;
double g_ask_836;
double g_bid_844 = 0.0;
double g_ask_852 = 0.0;
double gd_860 = 0.0;
double gd_868 = 0.0;
double gd_876 = 0.0;
double gd_884 = 0.0;
double g_ord_open_price_892 = 0.0;
double g_ord_open_price_900 = 0.0;
double gd_unused_908 = 0.0;
double gd_unused_916 = 0.0;
double gd_924;
double gd_932;
double g_price_940;
double g_price_948;
double gd_956 = 0.0;
double gd_964 = 0.0;
double gd_unused_972 = 0.0;
double gd_unused_980 = 0.0;
double gd_988 = 0.0;
double g_bid_996 = 0.0;
double g_ask_1004 = 0.0;
double g_bid_1012;
double gd_1020;
double gd_1028;
double g_bid_1036;
double gd_1044;
double g_ask_1052;
double gd_1060;
double gd_1068;
double g_ask_1076;
double gd_1084;
double g_bid_1092;
double gd_1100;
double gd_1108;
double g_bid_1116;
double gd_1124;
double g_ask_1132;
double gd_1140;
double gd_1148;
double g_ask_1156;
double gd_1164;
double g_bid_1172;
double gd_1180;
double gd_1188;
double g_bid_1196;
double gd_1204;
double g_ask_1212;
double gd_1220;
double gd_1228;
double gd_1236;
double gd_1244;
double g_ask_1252;
double g_bid_1260;
double gd_1268;
double gd_1276;
double gd_1284;
double gd_1292;
double gd_1300;
double gd_1308;
double g_lots_1316;
double g_lots_1324;
double g_ord_open_price_1332;
double g_ord_open_price_1340;
double g_ord_lots_1348;
double g_ord_lots_1356;
int g_count_1364;
int g_count_1368;
bool gi_1372;
bool gi_1376;
bool gi_1380;
bool gi_1384;
double g_ord_lots_1388;
double g_ord_lots_1396;
double gd_1404;
double gd_1412;
double g_price_1420;
double g_price_1428;
double g_price_1436;
double g_price_1444;
double gd_1452;
double gd_1460;
double gd_1468;
double gd_1476;
double gd_1484;
double g_ord_open_price_1492;
double g_ord_open_price_1500;
double g_price_1508;
double g_price_1516;
double g_price_1524;
double g_price_1532;
double gd_1540;
double gd_1548;
double g_ord_open_price_1556;
double g_ord_open_price_1564;
double g_price_1572;
double g_price_1580;
double g_ord_open_price_1588;
double g_ord_open_price_1596;
double gd_1604;
double gd_1612;
double gd_1620;
double gd_1628;
double gd_1636;
double g_price_1644;
double g_price_1652;
double g_high_1660;
double g_low_1668;
double g_ord_open_price_1676;
double g_ord_open_price_1684;
double gd_1692;
double gd_1700;
int g_file_1708;
int g_file_1712;
int gi_1716;
string gs_unused_1720 = "Color Settings";
string gs_1728 = "";
int g_magic_1736 = 12345;
string gs_1740 = "2030.07.10 23:59";
int gi_unused_1748 = 219517;
string gs_1752;
string gs_1760;
string gs_1768;
string gs_1776;
string gs_1784;
string gs_1792;
string gs_1800;
string gs_1808;
string gs_1816;
string g_name_1824 = "initialbalance.txt";
string gs_dummy_1832;
bool gi_1840;
int gi_1848;
int gi_1852;
bool gi_1856;
bool gi_1860;
double g_ask_1868;
double g_bid_1876;
double gd_1884;
double gd_1892;
double gd_1900;
double g_ord_open_price_1908;
double g_ord_open_price_1916;
double gd_1924;
double gd_1932;
double gd_1940;
double g_lots_1948;
double g_price_1956;
double g_price_1964;
double g_lots_1972;
double g_lots_1980;
double gd_1988;
double g_price_1996;
double g_price_2004;
double g_price_2012;
double g_price_2020;
double g_str2dbl_2028;
double gd_2036;
double g_ord_open_price_2044;
double g_ord_open_price_2052;
double g_ord_stoploss_2060;
double g_ord_stoploss_2068;
double gd_2076;
double gd_2084;
double gd_2092;
double gd_2100;
double gd_2108;
double gd_2116;
double g_ask_2124;
double g_bid_2132;
double gd_2140;
double gd_2148;
double gd_2156;
double gd_2164;
double gd_2172;
double gd_2180;
double gd_2188;
double g_lots_2196;
double g_lots_2204;
double gd_2212;
double gd_2220;
bool gi_2228;
bool gi_2232 = TRUE;
double g_ord_open_price_2236;
double gd_2244;
double gd_2252;
double g_price_2260;
double g_price_2268;
double g_ord_open_price_2276;
double gd_2284;
double gd_2292;
double g_price_2300;
double g_price_2308;
double g_lots_2316;
double gd_2324;
double g_point_2332;
double gd_2340;
double gd_2348;
string gs_2356;
string gs_2364;
int gi_2372 = 65535;
int gi_2376 = 16760576;
int gi_2380 = 3329330;
int gi_unused_2384 = 14772545;
int gi_2388 = 255;
int gi_2392 = 55295;
int gi_2396 = 16443110;
int gi_2400 = 9221330;
int gi_2404 = 8388352;
int gi_unused_2408 = 13499135;
int gi_2412 = 11119017;
int gi_2416 = 0;
int gi_2420 = 0;
int gi_2424 = 20;
int gi_2428 = 35;
int gi_2432 = 50;
int gi_2436 = 65;
int gi_2440 = 80;
int gi_2444 = 95;
int gi_2448 = 110;
int gi_2452 = 125;
int gi_2456 = 140;
int gi_2460 = 155;
int gi_2464 = 170;
int gi_2468 = 185;
int gi_2472 = 200;
int gi_2476 = 215;
int gi_2480 = 230;
int gi_2484 = 245;
int gi_2488 = 260;
int gi_2492 = 275;
int gi_2496 = 290;
int gi_2500 = 305;
int gi_2504 = 320;
int gi_2508 = 335;
int gi_2512 = 350;
int gi_2516 = 365;
int gi_2520 = 380;
int gi_2524 = 0;
int gi_2528 = 0;
int gi_2532 = 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_2416);
ObjectSet(a_name_0, OBJPROP_YDISTANCE, ai_28 + 15 + gi_2420);
}

int start() {
int l_file_0;
if (IsTesting()) {
Alert("This Expert Advisor cant be tested by Strategy Tester!");
return (0);
}
LABEL("TITLE_", gs_76, "Arial Bold", 0, gi_2424, gi_2372);
while (!(ObjectFind("TITLE_") < 0)) {
if (AutoCalculateLot == TRUE) {
if (gd_1940 != AccountBalance()) {
gd_1940 = AccountBalance();
if (LotEquityRatio > 0.0) gd_1924 = gd_1940 * LotEquityRatio;
else gd_1924 = gd_1940;
if (MarketInfo(Symbol(), MODE_MINLOT) == 1.0) {
if (gd_1924 >= 100000.0) gd_1932 = MathRound(0.00001 * gd_1924);
if (gd_1924 < 100000.0) gd_1932 = MarketInfo(Symbol(), MODE_MINLOT);
}
if (MarketInfo(Symbol(), MODE_MINLOT) == 0.1) {
if (gd_1924 >= 100000.0) gd_1932 = MathRound(0.00001 * gd_1924);
if (gd_1924 < 100000.0 && gd_1924 >= 10000.0) gd_1932 = MathRound(gd_1924 / 10000.0) / 10.0;
if (gd_1924 < 10000.0) gd_1932 = MarketInfo(Symbol(), MODE_MINLOT);
}
if (MarketInfo(Symbol(), MODE_MINLOT) == 0.01) {
if (gd_1924 >= 100000.0) gd_1932 = MathRound(0.00001 * gd_1924);
if (gd_1924 < 100000.0 && gd_1924 >= 10000.0) gd_1932 = MathRound(gd_1924 / 10000.0) / 10.0;
if (gd_1924 < 10000.0 && gd_1924 >= 1000.0) gd_1932 = MathRound(gd_1924 / 1000.0) / 100.0;
if (gd_1924 < 1000.0) gd_1932 = MarketInfo(Symbol(), MODE_MINLOT);
}
if (OnlyAllowDecreaseLot == FALSE)
if (g_lots_1948 != gd_1932) g_lots_1948 = gd_1932;
if (OnlyAllowDecreaseLot == TRUE)
if (g_lots_1948 == 0.0 || g_lots_1948 > gd_1932) g_lots_1948 = gd_1932;
}
} else g_lots_1948 = LotSize;
if (gi_344 == TRUE) {
DisableTrailingStop = TRUE;
Doubler = FALSE;
CloseOneCloseAll = FALSE;
StopLoopTime = "0";
}
if (Mode == "pyr") {
LotSize = 0.2;
AveragingHedgeGap = 10;
AveragingMultiplier = 2;
AveragingTakeProfit = 15;
increase = 0;
Hedging = FALSE;
gi_300 = FALSE;
Averaging = TRUE;
MaxLotStop = 1;
StartFromHiLow = TRUE;
Mode = "pyramid";
}
gd_2244 = 0;
gd_2284 = 0;
gd_2252 = 0;
gd_2292 = 0;
g_price_2260 = 0;
g_price_2300 = 0;
g_price_2268 = 0;
g_price_2308 = 0;
g_ord_lots_1388 = 0;
g_ord_lots_1396 = 0;
gd_2108 = 0;
gd_2116 = 0;
gd_2140 = 0;
gd_2148 = 0;
gd_2156 = 0;
gd_2164 = 0;
g_point_2332 = MarketInfo(Symbol(), MODE_POINT);
if (MarketInfo(Symbol(), MODE_DIGITS) == 3.0 || MarketInfo(Symbol(), MODE_DIGITS) == 5.0) {
gd_2348 = MarketInfo(Symbol(), MODE_STOPLEVEL) / 10.0;
gd_2340 = 10.0 * g_point_2332;
} else {
gd_2340 = g_point_2332;
gd_2348 = MarketInfo(Symbol(), MODE_STOPLEVEL);
}
if (gd_2324 < MarketInfo(Symbol(), MODE_ASK) - MarketInfo(Symbol(), MODE_BID)) gd_2324 = MarketInfo(Symbol(), MODE_ASK) - MarketInfo(Symbol(), MODE_BID);
if (MaxRiskPercentage > 100.0) MaxRiskPercentage = 100.0;
if (gd_1884 == 0.0) gd_1884 = AccountBalance();
if (gi_348 == TRUE) {
FileDelete(g_name_1824);
g_error_756 = GetLastError();
if (g_error_756 != 0/* NO_ERROR */) {
Print("Error = ", ErrorDescription(g_error_756), " while deleting Balance Amount");
gi_348 = FALSE;
gi_684 = FALSE;
break;
}
Print("Successfully Reseting Balance");
gi_348 = FALSE;
}
if (gd_356 > 0.0) {
g_str2dbl_2028 = gd_356;
g_file_1708 = FileOpen(g_name_1824, FILE_CSV|FILE_WRITE);
for (int l_count_4 = 0; l_count_4 < 1; l_count_4++) gi_1716 = FileWrite(g_file_1708, DoubleToStr(gd_356, 2));
if (gi_1716 > 0) {
Print("InitialBalance is ", g_str2dbl_2028);
gd_356 = 0;
Print("MSInitialBalance= ", DoubleToStr(gd_356, 2));
} else {
Print("Failed setting InitialBalance");
gi_684 = FALSE;
break;
}
FileClose(g_file_1708);
} else {
if (gd_1988 != AccountBalance()) {
l_file_0 = FileOpen(g_name_1824, FILE_CSV|FILE_READ);
gd_1988 = AccountBalance();
if (l_file_0 > 0) {
gs_1816 = FileReadString(l_file_0);
FileClose(l_file_0);
g_str2dbl_2028 = StrToDouble(gs_1816);
}
if (l_file_0 < 0) {
g_file_1712 = FileOpen(g_name_1824, FILE_CSV|FILE_WRITE);
if (g_file_1712 > 0) {
for (l_count_4 = 0; l_count_4 < 1; l_count_4++) FileWrite(g_file_1712, DoubleToStr(gd_1988, 2));
FileClose(g_file_1712);
g_str2dbl_2028 = AccountBalance();
}
if (g_file_1712 < 0) {
Print("File Error. Closing Expert Advisor.");
gi_684 = FALSE;
break;
}
}
}
}
if (!(ObjectFind("LABEL_OFF") < 0)) {
if (gi_724 == 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_724 = 1;
}
}
if (gi_724 == 1) {
gi_684 = FALSE;
break;
}
gi_724 = 2;
if (gi_696 == TRUE) {
if (ObjectsTotal() > 0) ObjectsDeleteAll();
if (ObjectsTotal() <= 0) gi_696 = FALSE;
}
LABEL("LABEL_EXPIRE", "EA Expire: " + gs_1740, "Arial Bold", 220, gi_2428, gi_2404);
if (TimeLocal() < StrToTime(StartEATime)) {
gi_684 = FALSE;
gi_708 = TRUE;
if (BuyOrders() + SellOrders() > 0) CancelPending();
}
if (gi_712 == TRUE) {
if (TimeLocal() >= StrToTime(StartEATime)) {
if (EndEATime > "0" && TimeLocal() >= StrToTime(EndEATime)) {
gi_684 = FALSE;
gi_712 = FALSE;
CloseAll();
gs_1728 = "EndEATime";
}
if (EndEATime > "0" && TimeLocal() < StrToTime(EndEATime)) {
gi_708 = FALSE;
gi_712 = FALSE;
gi_684 = TRUE;
}
}
}
if (StrToTime(gs_1740) < TimeCurrent()) {
if (gi_1372 == FALSE) {
MessageBox("Your Account is expired. Please contact abdalla27005@yahoo.co.id ; skype: abdalla2705");
gi_1372 = TRUE;
}
gi_684 = FALSE;
gi_704 = TRUE;
if (gi_704 != TRUE) break;
ObjectDelete("LABEL_ON");
LABEL("LABEL_OFF", "Expert Advisor is EXPIRED", "Arial Bold", 0, gi_2428, gi_2388);
break;
}
if (StrToTime(gs_1740) < TimeLocal()) {
if (gi_1372 == FALSE) {
MessageBox("Your Account is expired. Please contact abdalla27005@yahoo.co.id ; skype: abdalla2705");
gi_1372 = TRUE;
}
gi_684 = FALSE;
gi_704 = TRUE;
if (gi_704 != TRUE) break;
ObjectDelete("LABEL_ON");
LABEL("LABEL_OFF", "Expert Advisor is EXPIRED", "Arial Bold", 0, gi_2428, gi_2388);
break;
}
if ((Hedging == TRUE && Averaging == TRUE) || (Hedging == TRUE && gi_344 == TRUE) || (Hedging == TRUE && gi_300 == TRUE) || (Averaging == TRUE && gi_300 == TRUE) ||
(Averaging == TRUE && gi_344 == TRUE)) {
if (gi_1856 == FALSE) {
Alert("~~~~oOOo~(_)~oOOo~~~~");
Alert("~~~~ ( o o ) ~~~~");
Alert("~~~~ \\|// ~~~~");
if (Hedging == TRUE && Averaging == TRUE) Alert("Hedging & Averaging could not run at once");
if (Hedging == TRUE && gi_344 == TRUE) Alert("Hedging & MS could not run at once");
if (Hedging == TRUE && gi_300 == TRUE) Alert("Hedging & Corr could not run at once");
if (Averaging == TRUE && gi_344 == TRUE) Alert("Averaging & MS could not run at once");
if (Averaging == TRUE && gi_300 == TRUE) Alert("Averaging & Corr could not run at once");
if (gi_344 == TRUE && gi_300 == TRUE) Alert("MS & Corr could not run at once");
}
gi_1856 = TRUE;
gi_684 = 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_1860 == FALSE) Alert("Your Account Balance is not enough");
gi_1860 = TRUE;
gi_684 = FALSE;
}
if (gi_684 == TRUE) {
ObjectDelete("LABEL_OFF");
LABEL("LABEL_ON", "Expert Advisor is ON", "Arial Bold", 0, gi_2428, gi_2404);
if (!IsExpertEnabled()) {
if (gi_1840 == FALSE) {
Alert("*******************************");
Alert("Send email/YM to abdalla27005@yahoo.co.id");
Alert("skype : abdalla2705");
Alert("Do not turn off Expert Advisor while running!");
}
gi_1840 = TRUE;
}
} else {
if (gi_708 == TRUE) {
ObjectDelete("LABEL_OFF");
LABEL("LABEL_ON", "Waiting to Start. Time Left " + ((StrToTime(StartEATime) - TimeLocal())) + " sec", "Arial Bold", 0, gi_2428, gi_2388);
}
if (gi_708 == FALSE) {
if (gi_1384 == FALSE) {
if (gi_1856 != TRUE && gi_1860 != TRUE) MessageDisplay();
gi_1384 = TRUE;
}
ObjDelete();
ObjectDelete("LABEL_ON");
LABEL("LABEL_OFF", "Expert Advisor is OFF", "Arial Bold", 0, gi_2428, gi_2388);
}
}
if (gi_684 == TRUE) {
if (MarketInfo(Symbol(), MODE_DIGITS) == 3.0 || MarketInfo(Symbol(), MODE_DIGITS) == 5.0) {
gd_2212 = MarketInfo(Symbol(), MODE_SPREAD) / 10.0;
gd_2220 = MarketInfo(Symbol(), MODE_STOPLEVEL) / 10.0;
} else {
gd_2212 = MarketInfo(Symbol(), MODE_SPREAD);
gd_2220 = MarketInfo(Symbol(), MODE_STOPLEVEL);
}
gd_1900 = (MarketInfo(Symbol(), MODE_HIGH) - MarketInfo(Symbol(), MODE_LOW)) / MarketInfo(Symbol(), MODE_POINT);
gs_1768 = "\n[MINLOT " + DoubleToStr(MarketInfo(Symbol(), MODE_MINLOT), 3) + "] [HI-LOW " + DoubleToStr(gd_1900, 0) + "] [SPREAD " + DoubleToStr(gd_2212, 1) + "] www.brokerfxopen.com.com";
if (IsDemo() == TRUE) gs_1776 = "DEMO";
else gs_1776 = "REAL";
Comment("[LOCAL ", TimeToStr(TimeLocal(), TIME_DATE|TIME_SECONDS), "] [SERVER ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS), "] [1:", AccountLeverage(), "] [DIGITS ", Digits, "] [MIN RANGE ", DoubleToStr(gd_2220, 1) +
"] [" + gs_1776 + "]" + gs_1768);
if (BuyLots() > SellLots()) LABEL("SEQUENCE_", "BUY Cycle Active", "Arial Bold", 0, gi_2432, gi_2376);
if (BuyLots() < SellLots()) LABEL("SEQUENCE_", "SELL Cycle Active", "Arial Bold", 0, gi_2432, gi_2376);
if (BuyLots() + SellLots() > 0.0)
if (BuyLots() == SellLots()) LABEL("SEQUENCE_", "FULL HEDGING", "Arial Bold", 0, gi_2432, gi_2376);
if (BuyLots() + SellLots() == 0.0)
if (BuyLots() == SellLots()) LABEL("SEQUENCE_", "Waiting for sequence", "Arial Bold", 0, gi_2432, gi_2376);
if (BuyOpen() + SellOpen() > 0) LABEL("BUYROW_", "Buy Row: " + BuyOpen() + " Sell Row: " + SellOpen(), "Arial Bold", 135, gi_2432, gi_2376);
else LABEL("BUYROW_", "Buy Row: " + BuyOpen() + "Sell Row: " + SellOpen(), "Arial Bold", 135, gi_2432, gi_2412);
if (gd_988 > 0.0) LABEL("GAP_", "Gap : " + DoubleToStr(gd_988 / gd_2340, 0), "Arial Bold", 325, gi_2432, gi_2376);
else ObjectDelete("GAP_");
}
if (Straddle == TRUE) {
if (g_ord_open_price_1492 > 0.0) {
LABEL("STRADDLE_BUY_", "Straddle Buy @ " + DoubleToStr(g_lots_1948, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1492, Digits) + " TP: " + DoubleToStr(g_price_1508, Digits) +
" SL: " + DoubleToStr(g_price_1516, Digits), "Arial Bold", 0, gi_2436, gi_2380);
} else {
LABEL("STRADDLE_BUY_", "Straddle Buy @ " + DoubleToStr(g_lots_1948, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1492, Digits) + " TP: " + DoubleToStr(g_price_1508, Digits) +
" SL: " + DoubleToStr(g_price_1516, Digits), "Arial Bold", 0, gi_2436, gi_2412);
}
if (g_ord_open_price_1500 > 0.0) {
LABEL("STRADDLE_SELL_", "Straddle Sell @ " + DoubleToStr(g_lots_1948, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1500, Digits) + " TP: " + DoubleToStr(g_price_1524, Digits) +
" SL: " + DoubleToStr(g_price_1532, Digits), "Arial Bold", 0, gi_2440, gi_2388);
} else {
LABEL("STRADDLE_SELL_", "Straddle Sell @ " + DoubleToStr(g_lots_1948, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1500, Digits) + " TP: " + DoubleToStr(g_price_1524, Digits) +
" SL: " + DoubleToStr(g_price_1532, Digits), "Arial Bold", 0, gi_2440, gi_2412);
}
if (g_ord_open_price_1492 + g_ord_open_price_1500 > 0.0) LABEL("STRADDLE_INFO_", "[Straddle] Range: " + StraddleRange + " TP: " + StraddleTakeProfit + " SL: " + StraddleStopLoss, "Arial Bold", 0, gi_2444, gi_2376);
else LABEL("STRADDLE_INFO_", "[Straddle] Range: " + StraddleRange + " TP: " + StraddleTakeProfit + " SL: " + StraddleStopLoss, "Arial Bold", 0, gi_2444, gi_2412);
}
if (Averaging == TRUE && StartFromHiLow == TRUE) {
if (BuyOpen() + SellOpen() > 0) gi_2228 = FALSE;
else gi_2228 = TRUE;
if (gi_2228 == TRUE) {
if (BuyOrders() > 0) LABEL("HILOW_BUY_", "HiLow Buy @ " + DoubleToStr(g_lots_1948, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1676, Digits), "Arial Bold", 0, gi_2436, gi_2380);
else LABEL("HILOW_BUY_", "HiLow Buy @ " + DoubleToStr(g_lots_1948, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1676, Digits), "Arial Bold", 0, gi_2436, gi_2412);
if (SellOrders() > 0) LABEL("HILOW_SELL_", "HiLow Sell @ " + DoubleToStr(g_lots_1948, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1684, Digits), "Arial Bold", 0, gi_2440, gi_2388);
else LABEL("HILOW_SELL_", "HiLow Sell @ " + DoubleToStr(g_lots_1948, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1684, Digits), "Arial Bold", 0, gi_2440, gi_2412);
if (BuyOrders() + SellOrders() > 0) LABEL("HILOW_INFO_", "[HiLow] Gap: " + MinimumHiLowRange + " Current: " + DoubleToStr(gd_1900, 0) + " HiLow Range: " + RangeFromHiLow + " Indi Level: " + HiLowIndicatorLevel, "Arial Bold", 0, gi_2444, gi_2376);
else LABEL("HILOW_INFO_", "[HiLow] Gap: " + MinimumHiLowRange + " Current: " + DoubleToStr(gd_1900, 0) + " HiLow Range: " + RangeFromHiLow + " Indi Level: " + HiLowIndicatorLevel, "Arial Bold", 0, gi_2444, gi_2412);
}
}
if (Straddle == FALSE && gi_2228 == FALSE) {
if (gi_344 == TRUE) LABEL("EMA_", "[Init] Bal: " + DoubleToStr(g_str2dbl_2028, 2) + " Cut P/L($): " + gi_384 + " ReB: B @" + DoubleToStr(gd_1692, Digits) + " S @" + DoubleToStr(gd_1700, Digits), "Arial Bold", 0, gi_2448, gi_2392);
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_2448, gi_2392);
} else ObjectDelete("EMA_");
}
if (gi_344 == FALSE) {
if (Hedging == TRUE || Averaging == TRUE) {
if (increase > 0) {
if (gi_772 >= IncreaseStartLevel) LABEL("INCREASE_", "[Increase] Range" + increase + " Start: " + IncreaseStartLevel + " End: " + IncreaseEndLevel, "Arial Bold", 0, gi_2452, gi_2396);
else LABEL("INCREASE_", "[Increase] Range" + increase + " Start: " + IncreaseStartLevel + " End: " + IncreaseEndLevel, "Arial Bold", 0, gi_2452, gi_2412);
} else LABEL("INCREASE_", "[Increase] is OFF", "Arial Bold", 0, gi_2452, gi_2412);
if (Hedging == TRUE) LABEL("RANGE_", "[Current] Range: " + ((HedgeGap + increase * gi_776)) + " Level: " + gi_772 + " of " + MaxLevelAllowed + " P/L: " + DoubleToStr(AccountProfit(), 2), "Arial Bold", 0, gi_2456, gi_2400);
if (Averaging == TRUE) LABEL("RANGE_", "[Current] Range: " + ((AveragingHedgeGap + increase * gi_776)) + " Level: " + gi_772 + " of " + MaxLevelAllowed + " P/L: " + DoubleToStr(AccountProfit(), 2), "Arial Bold", 0, gi_2456, gi_2400);
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_2460, gi_2376);
} else {
if (Hedging == TRUE) {
ObjectDelete("FULLHEDGE_");
LABEL("INITIALRANGE_", "[Basic] Hedge Gap: " + HedgeGap + " Multiplier: " + DoubleToStr(Multiplier, 2) + " Lot " + DoubleToStr(g_lots_1948, 3) + " TP: " + TakeProfit +
" SL: " + StopLoss, "Arial Bold", 0, gi_2460, gi_2376);
}
if (Averaging == TRUE) {
ObjectDelete("FULLHEDGE_");
LABEL("INITIALRANGE_", "[Basic] Average Gap: " + AveragingHedgeGap + " Multiplier: " + DoubleToStr(AveragingMultiplier, 2) + " Lot " + DoubleToStr(g_lots_1948, 3) +
" TP: " + AveragingTakeProfit + " SL: " + AveragingStopLoss, "Arial Bold", 0, gi_2460, gi_2376);
if (MaxLotStop > 0.0) LABEL("MAXLOTSTOP_", "Max Lot Stop: " + DoubleToStr(MaxLotStop, 3), "Arial Bold", 350, gi_2460, gi_2376);
else ObjectDelete("MAXLOTSTOP_");
}
}
} else {
ObjectDelete("INCREASE_");
ObjectDelete("RANGE_");
ObjectDelete("INITIALRANGE_");
}
}
if (gi_344 == TRUE) {
LABEL("RANGE_", "[Current] Range: " + gi_364 + " Bal: " + DoubleToStr(AccountBalance(), 2) + " Cum P/L: " + DoubleToStr(gd_2036, 2) + " P/L: " + DoubleToStr(AccountProfit(), 2), "Arial Bold", 0, gi_2456, gi_2400);
LABEL("INITIALRANGE_", "[Basic] MS Adj Pend: " + gi_388 + " TP: " + gi_368 + " SL: " + gi_372 + " TS: " + gi_376 + " ReB: " + gi_380, "Arial Bold", 0, gi_2460, gi_2376);
}
if (AutoCalculateLot == TRUE) {
gs_1792 = "ON";
if (OnlyAllowDecreaseLot == TRUE) gs_1800 = "ON";
else gs_1800 = "OFF";
LABEL("AUTOLOT_", "[Basic] AutoCalLot: " + gs_1792 + " DecLot: " + gs_1800 + " LotRatio: " + DoubleToStr(LotEquityRatio, 2), "Arial Bold", 0, gi_2464, gi_2376);
} else {
gs_1792 = "OFF";
LABEL("AUTOLOT_", "[Basic] AutoCalLot: OFF", "Arial Bold", 0, gi_2464, gi_2412);
}
if (DisableTrailingStop == FALSE) {
if (TrailingStop > 0) {
if (BuyLots() > SellLots()) {
if (g_bid_996 > 0.0 || gd_1604 != g_bid_996) {
ObjectDelete("TRAILINGSTOPSELL_");
ObjectDelete("TRAILINGSTOPSELL_BEP_");
LABEL("TRAILINGSTOPBUY_", "[TS] Buy Range: " + TrailingStop + " (" + DoubleToStr(gd_956, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_860, Digits) + ") Start: " +
TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_2468, gi_2380);
LABEL("TRAILINGSTOPBUY_BEP_", " BEP: " + DoubleToStr(g_bid_996, Digits), "Arial Bold", 350, gi_2468, gi_2380);
} else {
ObjectDelete("TRAILINGSTOPSELL_");
ObjectDelete("TRAILINGSTOPSELL_BEP_");
LABEL("TRAILINGSTOPBUY_", "[TS] Buy Range: " + TrailingStop + " (" + DoubleToStr(gd_956, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_860, Digits) + ") Start: " +
TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_2468, gi_2412);
LABEL("TRAILINGSTOPBUY_BEP_", " BEP: " + DoubleToStr(g_bid_996, Digits), "Arial Bold", 350, gi_2468, gi_2412);
}
}
if (SellLots() > BuyLots()) {
if (g_ask_1004 > 0.0) {
ObjectDelete("TRAILINGSTOPBUY_");
ObjectDelete("TRAILINGSTOPBUY_BEP_");
LABEL("TRAILINGSTOPSELL_", "[TS] Sell Range: " + TrailingStop + " (" + DoubleToStr(gd_964, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_868, Digits) + ") Start: " +
TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_2468, gi_2380);
LABEL("TRAILINGSTOPSELL_BEP_", " BEP: " + DoubleToStr(g_ask_1004, Digits), "Arial Bold", 350, gi_2468, gi_2380);
} else {
ObjectDelete("TRAILINGSTOPBUY_");
ObjectDelete("TRAILINGSTOPBUY_BEP_");
LABEL("TRAILINGSTOPSELL_", "[TS] Sell Range: " + TrailingStop + " (" + DoubleToStr(gd_964, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_868, Digits) + ") Start: " +
TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_2468, gi_2412);
LABEL("TRAILINGSTOPSELL_BEP_", " BEP: " + DoubleToStr(g_ask_1004, Digits), "Arial Bold", 350, gi_2468, gi_2412);
}
}
} else LABEL("TRAILINGSTOP_", "[TS] is OFF ", "Arial Bold", 0, gi_2468, gi_2412);
if (TrailingStop_2 > 0) {
if (BuyLots() > SellLots()) {
if (g_bid_1012 > 0.0) {
ObjectDelete("TRAILINGSTOPSELL_2_");
ObjectDelete("TRAILINGSTOPSELL_2_BEP_");
LABEL("TRAILINGSTOPBUY_2_", "[TS 2] Buy Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1020, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1044, Digits) +
") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_2472, gi_2380);
LABEL("TRAILINGSTOPBUY_2_BEP_", " BEP: " + DoubleToStr(g_bid_1012, Digits), "Arial Bold", 350, gi_2472, gi_2380);
} else {
ObjectDelete("TRAILINGSTOPSELL_2_");
ObjectDelete("TRAILINGSTOPSELL_2_BEP_");
LABEL("TRAILINGSTOPBUY_2_", "[TS 2] Buy Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1020, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1044, Digits) +
") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_2472, gi_2412);
LABEL("TRAILINGSTOPBUY_2_BEP_", " BEP: " + DoubleToStr(g_bid_1012, Digits), "Arial Bold", 350, gi_2472, gi_2412);
}
}
if (SellLots() > BuyLots()) {
if (g_ask_1052 > 0.0) {
ObjectDelete("TRAILINGSTOPBUY_2_");
ObjectDelete("TRAILINGSTOPBUY_2_BEP_");
LABEL("TRAILINGSTOPSELL_2_", "[TS 2] Sell Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1060, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1084, Digits) +
") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_2472, gi_2380);
LABEL("TRAILINGSTOPSELL_2_BEP_", " BEP: " + DoubleToStr(g_ask_1052, Digits), "Arial Bold", 350, gi_2472, gi_2380);
} else {
ObjectDelete("TRAILINGSTOPBUY_2_");
ObjectDelete("TRAILINGSTOPBUY_2_BEP_");
LABEL("TRAILINGSTOPSELL_2_", "[TS 2] Sell Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1060, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1084, Digits) +
") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_2472, gi_2412);
LABEL("TRAILINGSTOPSELL_2_BEP_", " BEP: " + DoubleToStr(g_ask_1052, Digits), "Arial Bold", 350, gi_2472, gi_2412);
}
}
} else LABEL("TRAILINGSTOP_2_", "[TS 2] is OFF", "Arial Bold", 0, gi_2472, gi_2412);
if (TrailingStop_3 > 0) {
if (BuyLots() > SellLots()) {
if (g_bid_1092 > 0.0) {
ObjectDelete("TRAILINGSTOPSELL_3_");
ObjectDelete("TRAILINGSTOPSELL_3_BEP_");
LABEL("TRAILINGSTOPBUY_3_", "[TS 3] Buy Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1100, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1124, Digits) +
") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_2476, gi_2380);
LABEL("TRAILINGSTOPBUY_3_BEP_", " BEP: " + DoubleToStr(g_bid_1092, Digits), "Arial Bold", 350, gi_2476, gi_2380);
} else {
ObjectDelete("TRAILINGSTOPSELL_3_");
ObjectDelete("TRAILINGSTOPSELL_3_BEP_");
LABEL("TRAILINGSTOPBUY_3_", "[TS 3] Buy Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1100, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1124, Digits) +
") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_2476, gi_2412);
LABEL("TRAILINGSTOPBUY_3_BEP_", " BEP: " + DoubleToStr(g_bid_1092, Digits), "Arial Bold", 350, gi_2476, gi_2412);
}
}
if (SellLots() > BuyLots()) {
if (g_bid_1092 > 0.0) {
ObjectDelete("TRAILINGSTOPBUY_3_");
ObjectDelete("TRAILINGSTOPBUY_3_BEP_");
LABEL("TRAILINGSTOPSELL_3_", "[TS 3] Sell Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1140, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1164, Digits) +
") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_2476, gi_2380);
LABEL("TRAILINGSTOPSELL_3_BEP_", " BEP: " + DoubleToStr(g_ask_1132, Digits), "Arial Bold", 350, gi_2476, gi_2380);
} else {
ObjectDelete("TRAILINGSTOPBUY_3_");
ObjectDelete("TRAILINGSTOPBUY_3_BEP_");
LABEL("TRAILINGSTOPSELL_3_", "[TS 3] Sell Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1140, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1164, Digits) +
") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_2476, gi_2412);
LABEL("TRAILINGSTOPSELL_3_BEP_", " BEP: " + DoubleToStr(g_ask_1132, Digits), "Arial Bold", 350, gi_2476, gi_2412);
}
}
} else LABEL("TrailingStop_3_", "[TS 3] is OFF", "Arial Bold", 0, gi_2476, gi_2412);
if (TrailingStop_4 > 0) {
if (BuyLots() > SellLots()) {
if (g_bid_1172 > 0.0) {
ObjectDelete("TRAILINGSTOPSELL_4_");
ObjectDelete("TRAILINGSTOPSELL_4_BEP_");
LABEL("TRAILINGSTOPBUY_4_", "[TS 4] Buy Range: " + TrailingStop_4 + " (" + DoubleToStr(gd_1180, Digits) + ") ReB: " + Rebound_4 + " (" + DoubleToStr(gd_1204, Digits) +
") Start: " + TrailingStop_4_StartLevel + " End: " + TrailingStop_4_EndLevel, "Arial Bold", 0, gi_2480, gi_2380);
LABEL("TRAILINGSTOPBUY_4_BEP_", " BEP: " + DoubleToStr(g_bid_1172, Digits), "Arial Bold", 350, gi_2480, gi_2380);
} else {
ObjectDelete("TRAILINGSTOPSELL_4_");
ObjectDelete("TRAILINGSTOPSELL_4_BEP_");
LABEL("TRAILINGSTOPBUY_4_", "[TS 4] Buy Range: " + TrailingStop_4 + " (" + DoubleToStr(gd_1180, Digits) + ") ReB: " + Rebound_4 + " (" + DoubleToStr(gd_1204, Digits) +
") Start: " + TrailingStop_4_StartLevel + " End: " + TrailingStop_4_EndLevel, "Arial Bold", 0, gi_2480, gi_2412);
LABEL("TRAILINGSTOPBUY_4_BEP_", " BEP: " + DoubleToStr(g_bid_1172, Digits), "Arial Bold", 350, gi_2480, gi_2412);
}
}
if (SellLots() > BuyLots()) {
if (g_bid_1172 > 0.0) {
ObjectDelete("TRAILINGSTOPBUY_4_");
ObjectDelete("TRAILINGSTOPBUY_4_BEP_");
LABEL("TRAILINGSTOPSELL_4_", "[TS 4] Sell Range: " + TrailingStop_4 + " (" + DoubleToStr(gd_1220, Digits) + ") ReB: " + Rebound_4 + " (" + DoubleToStr(gd_1244, Digits) +
") Start: " + TrailingStop_4_StartLevel + " End: " + TrailingStop_4_EndLevel, "Arial Bold", 0, gi_2480, gi_2380);
LABEL("TRAILINGSTOPSELL_4_BEP_", " BEP: " + DoubleToStr(g_ask_1212, Digits), "Arial Bold", 350, gi_2480, gi_2380);
} else {
ObjectDelete("TRAILINGSTOPBUY_4_");
ObjectDelete("TRAILINGSTOPBUY_4_BEP_");
LABEL("TRAILINGSTOPSELL_4_", "[TS 4] Sell Range: " + TrailingStop_4 + " (" + DoubleToStr(gd_1220, Digits) + ") ReB: " + Rebound_4 + " (" + DoubleToStr(gd_1244, Digits) +
") Start: " + TrailingStop_4_StartLevel + " End: " + TrailingStop_4_EndLevel, "Arial Bold", 0, gi_2480, gi_2412);
LABEL("TRAILINGSTOPSELL_4_BEP_", " BEP: " + DoubleToStr(g_ask_1212, Digits), "Arial Bold", 350, gi_2480, gi_2412);
}
}
} else LABEL("TrailingStop_4_", "[TS 4] is OFF", "Arial Bold", 0, gi_2480, gi_2412);
} 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_2468, gi_2412);
}
if (MaxRiskPercentage > 0.0) {
if (gd_1452 < 0.0) LABEL("MAXRISK_", "[Management] Risk %: " + DoubleToStr(gd_1452, 2) + " % of " + DoubleToStr(-MaxRiskPercentage, 2) + " %", "Arial Bold", 0, gi_2484, gi_2388);
else LABEL("MAXRISK_", "[Management] Risk %: " + DoubleToStr(gd_1452, 2) + " % of " + DoubleToStr(-MaxRiskPercentage, 2) + " %", "Arial Bold", 0, gi_2484, gi_2412);
} else LABEL("MAXRISK_", "[Management] Risk % is OFF ", "Arial Bold", 0, gi_2484, gi_2412);
if (MaxProfit > 0.0) {
if (AccountProfit() > 0.0) LABEL("MAXPROFIT_", "Profit($) " + DoubleToStr(AccountProfit(), 2) + " of " + DoubleToStr(MaxProfit, 2), "Arial Bold", 245, gi_2484, gi_2388);
else LABEL("MAXPROFIT_", "Profit($) " + DoubleToStr(AccountProfit(), 2) + " of " + DoubleToStr(MaxProfit, 2), "Arial Bold", 245, gi_2484, gi_2412);
} else LABEL("MAXPROFIT_", "Profit($) is OFF", "Arial Bold", 245, gi_2484, gi_2412);
if (CloseOneCloseAll == TRUE) {
gs_1808 = "ON";
LABEL("CLOSEONECLOSEALL_", "[Management] CloseOneCloseAll: " + gs_1808, "Arial Bold", 0, gi_2488, gi_2388);
} else {
gs_1808 = "OFF";
LABEL("CLOSEONECLOSEALL_", "[Management] CloseOneCloseAll: " + gs_1808, "Arial Bold", 0, gi_2488, gi_2412);
}
if (MaxLoss > 0.0) {
if (AccountProfit() < 0.0) LABEL("MAXLOSS_", "Loss($) " + DoubleToStr(AccountProfit(), 2) + " of -" + DoubleToStr(MaxLoss, 2), "Arial Bold", 245, gi_2488, gi_2388);
else LABEL("MAXLOSS_", "Loss($) " + DoubleToStr(AccountProfit(), 2) + " of -" + DoubleToStr(MaxLoss, 2), "Arial Bold", 245, gi_2488, gi_2412);
} else LABEL("MAXLOSS_", "Loss($) is OFF", "Arial Bold", 245, gi_2488, gi_2412);
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_2492, gi_2372);
LABEL("DOUBLER_2_", "[Doubler] Multiplier :" + DoubleToStr(DoublerMultiplier, 2) + " Addition: " + DoubleToStr(DoublerAddition, 3), "Arial Bold", 0, gi_2496, gi_2372);
if (DisableTrailingStop == TRUE) LABEL("DOUBLER_3_", "Disable TS: YES", "Arial Bold", 230, gi_2496, gi_2372);
else LABEL("DOUBLER_3_", "Disable TS: NO", "Arial Bold", 230, gi_2496, gi_2372);
} else {
LABEL("DOUBLER_", "[Doubler] Lot " + DoubleToStr(DoublerLotSize, 3) + " Range: " + DoublerRangeFromProfit + " TP: " + DoublerTakeProfit + " SL :" + DoublerStopLoss +
" Start : " + DoublerStartLevel + " End : " + DoublerEndLevel, "Arial Bold", 0, gi_2492, gi_2412);
LABEL("DOUBLER_2_", "[Doubler] Multiplier :" + DoubleToStr(DoublerMultiplier, 2) + " Addition: " + DoubleToStr(DoublerAddition, 3), "Arial Bold", 0, gi_2496, gi_2412);
if (DisableTrailingStop == TRUE) LABEL("DOUBLER_3_", "Disable TS: YES", "Arial Bold", 230, gi_2496, gi_2412);
else LABEL("DOUBLER_3_", "Disable TS: NO", "Arial Bold", 230, gi_2496, gi_2412);
}
if (DoublerBuyLots() > 0.0) {
ObjectDelete("DOUBLER_BUY_OFF");
ObjectDelete("DOUBLER_BUY_2_OFF");
LABEL("DOUBLER_BUY_ON", "[Doubler] Buy " + DoubleToStr(g_ord_lots_1348, 2) + " lots @ " + DoubleToStr(g_ord_open_price_1556, Digits) + " SL: " + DoubleToStr(g_price_1436, Digits) +
" TP: " + DoubleToStr(g_price_1420, Digits), "Arial Bold", 0, gi_2500, gi_2380);
LABEL("DOUBLER_BUY_2_ON", "[Doubler] Buy BEP @ " + DoubleToStr(g_ord_open_price_1556 - DoublerRangeFromProfit * gd_2340, Digits) + " Order " + g_count_1364 + " of " +
DoublerMaxOrder, "Arial Bold", 0, gi_2504, gi_2380);
} else {
ObjectDelete("DOUBLER_BUY_ON");
ObjectDelete("DOUBLER_BUY_2_ON");
LABEL("DOUBLER_BUY_OFF", "[Doubler] Buy " + DoubleToStr(g_lots_1316, 2) + " lots @ " + DoubleToStr(gd_1268, Digits) + " SL: " + DoubleToStr(g_price_1436, Digits) +
" TP: " + DoubleToStr(g_price_1420, Digits), "Arial Bold", 0, gi_2500, gi_2412);
LABEL("DOUBLER_BUY_2_OFF", "[Doubler] Buy BEP @ " + DoubleToStr(g_ask_1252, Digits) + " Order " + g_count_1364 + " of " + DoublerMaxOrder, "Arial Bold", 0, gi_2504, gi_2412);
}
if (DoublerSellLots() > 0.0) {
ObjectDelete("DOUBLER_SELL_OFF");
ObjectDelete("DOUBLER_SELL_2_OFF");
LABEL("DOUBLER_SELL_ON", "[Doubler] Sell " + DoubleToStr(g_ord_lots_1356, 2) + " lots @ " + DoubleToStr(g_ord_open_price_1564, Digits) + " SL: " + DoubleToStr(g_price_1444, Digits) +
" TP: " + DoubleToStr(g_price_1428, Digits), "Arial Bold", 0, gi_2508, gi_2388);
LABEL("DOUBLER_SELL_2_ON", "[Doubler] Sell BEP @ " + DoubleToStr(g_ord_open_price_1564 + DoublerRangeFromProfit * gd_2340, Digits) + " Order " + g_count_1368 + " of " +
DoublerMaxOrder, "Arial Bold", 0, gi_2512, gi_2388);
} else {
ObjectDelete("DOUBLER_SELL_ON");
ObjectDelete("DOUBLER_SELL_2_ON");
LABEL("DOUBLER_SELL_OFF", "[Doubler] Sell " + DoubleToStr(g_lots_1324, 2) + " lots @ " + DoubleToStr(gd_1276, Digits) + " SL: " + DoubleToStr(g_price_1444, Digits) +
" TP: " + DoubleToStr(g_price_1428, Digits), "Arial Bold", 0, gi_2508, gi_2412);
LABEL("DOUBLER_SELL_2_OFF", "[Doubler] Sell BEP @ " + DoubleToStr(g_bid_1260, Digits) + " Order " + g_count_1368 + " of " + DoublerMaxOrder, "Arial Bold", 0, gi_2512, gi_2412);
}
} else LABEL("DOUBLER_", "Doubler is OFF", "Arial Bold", 0, gi_2492, gi_2412);
if (StrToTime(StartEATime) > TimeLocal()) LABEL("START_TIME_", "[Time] Start " + StartEATime, "Arial Bold", 0, gi_2516, gi_2388);
else LABEL("START_TIME_", "[Time] Start " + StartEATime, "Arial Bold", 0, gi_2516, gi_2412);
if (StrToTime(EndEATime) > TimeLocal()) LABEL("END_TIME_", " End " + EndEATime, "Arial Bold", 180, gi_2516, gi_2388);
else LABEL("END_TIME_", " End " + EndEATime, "Arial Bold", 180, gi_2516, gi_2412);
if (gi_344 == FALSE) {
if (Hedging == TRUE || Averaging == TRUE) {
if (StrToTime(StopLoopTime) > TimeLocal()) LABEL("STOP_LOOP_TIME_", "[Loop End Time] " + StopLoopTime, "Arial Bold", 0, gi_2520, gi_2388);
else LABEL("STOP_LOOP_TIME_", "[Loop End] " + StopLoopTime, "Arial Bold", 0, gi_2520, gi_2412);
}
} else LABEL("STOP_LOOP_TIME_", "[Loop End] " + StopLoopTime, "Arial Bold", 0, gi_2520, gi_2412);
}
if (CloseAll == TRUE) {
gi_684 = FALSE;
CloseAll();
CloseAll = FALSE;
gs_1728 = "Manual";
break;
}
if (StopLoss < 0) StopLoss = 0;
if (g_lots_1948 < MarketInfo(Symbol(), MODE_MINLOT)) g_lots_1948 = MarketInfo(Symbol(), MODE_MINLOT);
if (gi_704 == TRUE) {
gi_684 = FALSE;
break;
}
if (gi_684 == TRUE) {
if (StopLoopTime > "0" && TimeLocal() > StrToTime(StopLoopTime))
if (EALoop > 0 && gi_768 != EALoop) gi_768 = EALoop;
if (MaxLevelAllowed > 0) {
if (Averaging == TRUE) {
if (gi_1848 > gi_1852) {
if (gi_1848 > MaxLevelAllowed) {
CloseAll();
gs_1728 = "MaxLevelAllowed";
}
}
if (gi_1852 > gi_1848) {
if (gi_1852 > MaxLevelAllowed) {
CloseAll();
gs_1728 = "MaxLevelAllowed";
}
}
} else {
if (gi_772 > MaxLevelAllowed) {
CloseAll();
gs_1728 = "MaxLevelAllowed";
}
}
}
if (MaxRiskPercentage > 0.0) {
gd_1452 = 100.0 * ((AccountEquity() - AccountBalance()) / AccountBalance());
if (gd_1452 <= -MaxRiskPercentage) {
CloseAll();
gs_1728 = "MaxRiskPercentage";
}
}
if (MaxLoss > 0.0) {
if (AccountProfit() <= -MaxLoss) {
CloseAll();
gs_1728 = "MaxLoss";
}
}
if (gi_692 == TRUE) {
if (gi_1380 == FALSE) {
if (BuyOrders() + SellOrders() > 0) CancelPending();
gi_1380 = TRUE;
}
if (Straddle == FALSE) {
if (gi_344 == FALSE) {
if (Hedging == TRUE) FirstOrder();
if (Hedging == FALSE && Averaging == FALSE && gi_300 == FALSE) FirstOrder();
if (gi_300 == TRUE) {
gi_692 = FALSE;
gi_688 = TRUE;
}
if (Averaging == TRUE && StartFromHiLow == FALSE) FirstOrder();
if (Averaging == TRUE && StartFromHiLow == TRUE) {
if (BuyOpen() + SellOpen() <= 0) {
gi_2228 = TRUE;
if (gd_1900 > MinimumHiLowRange) {
if (g_high_1660 == 0.0) g_high_1660 = MarketInfo(Symbol(), MODE_HIGH);
if (g_low_1668 == 0.0) g_low_1668 = MarketInfo(Symbol(), MODE_LOW);
g_price_1652 = g_high_1660 + RangeFromHiLow * gd_2340 + gd_2324;
g_price_1644 = g_low_1668 - RangeFromHiLow * gd_2340 - gd_2324;
if (BuyOrders() < 1) {
if (OrderSend(Symbol(), OP_BUYLIMIT, g_lots_1948, g_price_1644, 3, 0, 0, "HiLow Buy Limit", 0, 0, CLR_NONE) < 0) {
g_price_1644 -= gd_2340;
Print("Error HiLow Buy Limit = ", ErrorDescription(GetLastError()));
}
}
if (SellOrders() < 1) {
if (OrderSend(Symbol(), OP_SELLLIMIT, g_lots_1948, g_price_1652, 3, 0, 0, "HiLow Sell Limit", 0, 0, CLR_NONE) < 0) {
g_price_1652 += gd_2340;
Print("Error HiLow Sell Limit = ", ErrorDescription(GetLastError()));
}
}
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
if (OrderType() == OP_BUYLIMIT && OrderMagicNumber() != g_magic_1736) g_ord_open_price_1676 = OrderOpenPrice();
if (OrderType() == OP_SELLLIMIT && OrderMagicNumber() != g_magic_1736) g_ord_open_price_1684 = OrderOpenPrice();
}
}
}
}
if (BuyOpen() + SellOpen() > 0) {
if (BuyOrders() > 0 || SellOrders() > 0) CancelPending();
if (ObjectsTotal() > 0) ObjectsDeleteAll();
gi_692 = FALSE;
gi_688 = TRUE;
}
}
}
if (gi_344 == TRUE) {
gi_692 = FALSE;
gi_688 = TRUE;
}
}
if (Straddle == TRUE) {
if (BuyOpen() + SellOpen() <= 0) {
if (BuyOrders() < 1 || SellOrders() < 1) {
gd_924 = MarketInfo(Symbol(), MODE_ASK) + StraddleRange * gd_2340;
gd_932 = MarketInfo(Symbol(), MODE_BID) - StraddleRange * gd_2340 - gd_2324;
if (BuyOrders() == 0) {
if (StraddleBuyPrice > 0.0) {
if (StraddleRange > 0) {
if (StraddleBuyPrice >= gd_924) {
g_price_940 = StraddleBuyPrice;
if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_1948, g_price_940, 3, 0, 0, "Straddle Buy Stop", 0, 0, CLR_NONE) == 0) continue;
gd_924 += gd_2340;
} else {
g_price_940 = gd_924;
if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_1948, g_price_940, 3, 0, 0, "Straddle Buy Stop", 0, 0, CLR_NONE) == 0) continue;
gd_924 += gd_2340;
}
}
if (StraddleRange == 0) {
g_price_940 = StraddleBuyPrice;
if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_1948, g_price_940, 3, 0, 0, "Straddle Buy Stop", 0, 0, CLR_NONE) == 0) continue;
gd_924 += gd_2340;
}
}
if (StraddleBuyPrice == 0.0) {
if (StraddleRange > 0) {
g_price_940 = gd_924;
if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_1948, g_price_940, 3, 0, 0, "Straddle Buy Stop", 0, 0, CLR_NONE) == 0) continue;
gd_924 += gd_2340;
}
if (StraddleRange == 0) {
if (gd_924 == 0.0) gd_924 = MarketInfo(Symbol(), MODE_ASK);
g_price_940 = gd_924;
if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_1948, g_price_940, 3, 0, 0, "Straddle Buy Stop", 0, 0, CLR_NONE) == 0) continue;
gd_924 += gd_2340;
}
}
}
if (SellOrders() == 0) {
if (StraddleSellPrice > 0.0) {
if (StraddleRange > 0) {
if (StraddleSellPrice <= gd_932) {
g_price_948 = StraddleSellPrice;
if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_1948, g_price_948, 3, 0, 0, "Straddle Sell Stop", 0, 0, CLR_NONE) == 0) continue;
gd_932 -= gd_2340;
} else {
g_price_948 = gd_932;
if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_1948, g_price_948, 3, 0, 0, "Straddle Sell Stop", 0, 0, CLR_NONE) == 0) continue;
gd_932 -= gd_2340;
}
}
if (StraddleRange == 0) {
g_price_948 = StraddleSellPrice;
if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_1948, g_price_948, 3, 0, 0, "Straddle Sell Stop", 0, 0, CLR_NONE) == 0) continue;
gd_932 -= gd_2340;
}
}
if (StraddleSellPrice == 0.0) {
if (StraddleRange > 0) {
g_price_948 = gd_932;
if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_1948, g_price_948, 3, 0, 0, "Straddle Sell Stop", 0, 0, CLR_NONE) == 0) continue;
gd_932 -= gd_2340;
}
if (StraddleRange == 0) {
if (gd_932 == 0.0) gd_932 = MarketInfo(Symbol(), MODE_BID);
g_price_948 = gd_932;
if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_1948, g_price_948, 3, 0, 0, "Straddle Sell Stop", 0, 0, CLR_NONE) == 0) continue;
gd_932 -= gd_2340;
}
}
}
}
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
if (OrderType() == OP_BUYSTOP && OrderMagicNumber() != g_magic_1736) {
g_ord_open_price_1492 = OrderOpenPrice();
if (StraddleTakeProfit <= 0) gd_1460 = 0;
if (StraddleTakeProfit > 0) gd_1460 = g_price_940 + StraddleTakeProfit * gd_2340;
if (StraddleStopLoss <= 0) gd_1468 = 0;
if (StraddleStopLoss > 0) gd_1468 = g_price_940 - StraddleStopLoss * gd_2340;
if (g_price_1508 <= 0.0) g_price_1508 = gd_1460;
if (g_price_1516 <= 0.0) g_price_1516 = gd_1468;
if (!IsEqual(OrderTakeProfit(), g_price_1508))
if (OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), g_price_1508, 0, CLR_NONE) == FALSE) g_price_1508 += gd_2340;
if (!IsEqual(OrderStopLoss(), g_price_1516))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1516, g_price_1508, 0, CLR_NONE) == FALSE) g_price_1516 -= gd_2340;
}
if (OrderType() == OP_SELLSTOP && OrderMagicNumber() != g_magic_1736) {
g_ord_open_price_1500 = OrderOpenPrice();
if (StraddleTakeProfit <= 0) gd_1476 = 0;
if (StraddleTakeProfit > 0) gd_1476 = g_ord_open_price_1500 - StraddleTakeProfit * gd_2340;
if (StraddleStopLoss <= 0) gd_1484 = 0;
if (StraddleStopLoss > 0) gd_1484 = g_ord_open_price_1500 + StraddleStopLoss * gd_2340;
if (g_price_1524 <= 0.0) g_price_1524 = gd_1476;
if (g_price_1532 <= 0.0) g_price_1532 = gd_1484;
if (!IsEqual(OrderTakeProfit(), g_price_1524))
if (OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), g_price_1524, 0, CLR_NONE) == FALSE) g_price_1524 -= gd_2340;
if (!IsEqual(OrderStopLoss(), g_price_1532))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1532, g_price_1524, 0, CLR_NONE) == FALSE) g_price_1532 += gd_2340;
}
}
}
}
if (BuyOpen() + SellOpen() > 0) {
if (BuyOrders() > 0 || SellOrders() > 0) CancelPending();
gi_692 = FALSE;
Straddle = FALSE;
gi_688 = TRUE;
if (ObjectsTotal() > 0) ObjectsDeleteAll();
}
}
}
if (gi_344 == FALSE) {
if (BuyLots() + SellLots() > 0.0) {
if (BuyLots() == SellLots()) {
gi_688 = FALSE;
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderMagicNumber() != g_magic_1736) {
if (OrderSelect(g_pos_764, SELECT_BY_POS, MODE_TRADES)) {
if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) {
g_ord_open_price_1908 = OrderOpenPrice();
if (MarketInfo(Symbol(), MODE_BID) - g_ord_open_price_1908 >= CloseWhileHedgingProfit * gd_2340) {
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_1916 = OrderOpenPrice();
if (g_ord_open_price_1916 - MarketInfo(Symbol(), MODE_ASK) >= CloseWhileHedgingProfit * gd_2340) {
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_688 = TRUE;
}
}
if (gi_688 == TRUE) {
CheckOrder();
if (gi_2232 == TRUE) {
if (gi_344 == FALSE && gi_300 == FALSE) {
if (increase <= 0) increase = 0;
if (increase > 0 && IncreaseEndLevel <= IncreaseStartLevel) IncreaseEndLevel = 0;
if (increase > 0 && IncreaseStartLevel < 1) IncreaseStartLevel = 1;
}
if (Hedging == FALSE && Averaging == FALSE && gi_344 == FALSE && gi_300 == FALSE) {
gi_772 = BuyOpen() + SellOpen();
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
if (OrderMagicNumber() != g_magic_1736) {
if (OrderType() == OP_BUY) {
gd_2244 += OrderLots();
g_ord_open_price_2236 = OrderOpenPrice();
}
if (OrderType() == OP_SELL) g_ord_open_price_2276 = OrderOpenPrice();
if (OrderType() == OP_BUYSTOP) gd_2252 += OrderLots();
if (OrderType() == OP_SELLSTOP) gd_2292 += OrderLots();
}
}
}
if (TakeProfit <= 0) {
g_price_2268 = 0;
g_price_2308 = 0;
}
if (TakeProfit > 0) {
g_price_2268 = g_ord_open_price_2236 + TakeProfit * gd_2340;
g_price_2308 = g_ord_open_price_2276 - TakeProfit * gd_2340;
}
if (StopLoss > 0) {
g_price_2260 = g_ord_open_price_2236 - StopLoss * gd_2340;
g_price_2300 = g_ord_open_price_2276 + StopLoss * gd_2340;
}
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_1736) {
if (OrderType() == OP_BUY) {
if (!IsEqual(OrderTakeProfit(), g_price_2268) || !IsEqual(OrderStopLoss(), g_price_2260)) {
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2260, g_price_2268, 0, CLR_NONE)) {
}
}
}
if (OrderType() == OP_SELL) {
if (!IsEqual(OrderTakeProfit(), g_price_2308) || !IsEqual(OrderStopLoss(), g_price_2300)) {
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2300, g_price_2308, 0, CLR_NONE)) {
}
}
}
if (OrderType() == OP_BUYSTOP) {
if (SellOpen() < 1) OrderDelete(OrderTicket());
if (!IsEqual(OrderTakeProfit(), g_price_2268) || !IsEqual(OrderStopLoss(), g_price_2260)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2260, g_price_2268, 0, CLR_NONE);
}
if (OrderType() == OP_SELLSTOP) {
if (BuyOpen() < 1) OrderDelete(OrderTicket());
if (!IsEqual(OrderTakeProfit(), g_price_2308) || !IsEqual(OrderStopLoss(), g_price_2300)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2300, g_price_2308, 0, CLR_NONE);
}
}
}
}
}
if (gi_300 == TRUE) {
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS, MODE_TRADES)) {
if (OrderMagicNumber() != g_magic_1736) {
if (OrderType() == OP_BUY) {
if (OrderSymbol() == gs_eurusd_328) gd_2140 += OrderLots();
if (OrderSymbol() == gs_usdchf_336) gd_2156 += OrderLots();
}
if (OrderType() == OP_SELL) {
if (OrderSymbol() == gs_eurusd_328) gd_2148 += OrderLots();
if (OrderSymbol() == gs_usdchf_336) gd_2164 += OrderLots();
}
}
}
}
gd_2172 = gd_2140 + gd_2156 + gd_2148 + gd_2164;
gd_2180 = gd_2140 + gd_2156;
gd_2188 = gd_2148 + gd_2164;
if (gd_2172 <= 0.0) {
if (gs_buy_320 == "buy" || gs_buy_320 == "b") {
if (gd_2180 <= 0.0)
if (OrderSend(gs_eurusd_328, OP_BUY, g_lots_1948, MarketInfo(gs_eurusd_328, MODE_ASK), 3, 0, 0, "Corr Buy", 0, 0, CLR_NONE) < 0) Print("Error Corr Buy = ", ErrorDescription(GetLastError()));
}
if (gs_buy_320 == "sell" || gs_buy_320 == "s") {
if (gd_2188 <= 0.0)
if (OrderSend(gs_eurusd_328, OP_SELL, g_lots_1948, MarketInfo(gs_eurusd_328, MODE_BID), 3, 0, 0, "Corr Sell", 0, 0, CLR_NONE) < 0) Print("Error Corr Sell = ", ErrorDescription(GetLastError()));
}
}
if (gd_2172 > 0.0) {
if (gd_2180 > 0.0) {
if (gd_2140 > gd_2156) {
g_lots_2196 = gd_2140 - gd_2156;
if (OrderSend(gs_usdchf_336, OP_BUY, g_lots_2196, MarketInfo(gs_usdchf_336, MODE_ASK), 3, 0, 0, "Corr Buy", 0, 0, CLR_NONE) < 0) Print("Error Corr Buy ", gs_usdchf_336, " = ", ErrorDescription(GetLastError()));
}
if (gd_2140 < gd_2156) {
g_lots_2196 = gd_2156 - gd_2140;
if (OrderSend(gs_eurusd_328, OP_BUY, g_lots_2196, MarketInfo(gs_eurusd_328, MODE_ASK), 3, 0, 0, "Corr Buy", 0, 0, CLR_NONE) < 0) Print("Error Corr Buy ", gs_eurusd_328, " = ", ErrorDescription(GetLastError()));
}
}
if (gd_2188 > 0.0) {
if (gd_2148 > gd_2164) {
g_lots_2204 = gd_2148 - gd_2164;
if (OrderSend(gs_usdchf_336, OP_SELL, g_lots_2204, MarketInfo(gs_usdchf_336, MODE_BID), 3, 0, 0, "Corr Sell", 0, 0, CLR_NONE) < 0) Print("Error Corr Sell ", gs_usdchf_336, " = ", ErrorDescription(GetLastError()));
}
if (gd_2148 < gd_2164) {
g_lots_2204 = gd_2164 - gd_2148;
if (OrderSend(gs_eurusd_328, OP_SELL, g_lots_2204, MarketInfo(gs_eurusd_328, MODE_BID), 3, 0, 0, "Corr Sell", 0, 0, CLR_NONE) < 0) Print("Error Corr Sell ", gs_eurusd_328, " = ", ErrorDescription(GetLastError()));
}
}
}
if (AccountProfit() >= gd_304) {
CloseAll();
gs_1728 = "CorrProfitMoney";
}
if (AccountProfit() <= -gd_312) {
CloseAll();
gs_1728 = "CorrLossMoney";
}
}
if (gi_344 == TRUE) {
gd_2244 = BuyLots();
gd_2284 = SellLots();
if (gd_2092 > gd_2244) {
g_price_1996 = 0;
gd_1692 = 0;
gd_2092 = 0;
} else gd_2092 = gd_2244;
if (gd_2100 > gd_2284) {
g_price_2004 = 0;
gd_1700 = 0;
gd_2100 = 0;
} else gd_2100 = gd_2284;
if (gi_364 < gd_2348) {
gi_364 = gd_2348;
Print("MSRange is set to minimum Broker limit = ", DoubleToStr(gi_364, 0));
}
g_price_1956 = gi_364 * gd_2340 + MarketInfo(Symbol(), MODE_ASK) + gd_2324;
g_price_1964 = MarketInfo(Symbol(), MODE_BID) - gi_364 * gd_2340 - gd_2324;
if (TotalBuyLots() + TotalSellLots() <= 0.0) {
if (TotalBuyPos() < 1.0) {
if (OrderSend(Symbol(), OP_BUYSTOP, LotSize, g_price_1956, 3, 0, 0, "MS Buy Stop", 0, 0, CLR_NONE) < 0) {
Print("Error MS Buy Stop = ", ErrorDescription(GetLastError()));
g_price_1956 += gd_2340;
}
}
if (TotalSellPos() < 1.0) {
if (OrderSend(Symbol(), OP_SELLSTOP, LotSize, g_price_1964, 3, 0, 0, "MS Sell Stop", 0, 0, CLR_NONE) < 0) {
Print("Error MS Sell Stop = ", ErrorDescription(GetLastError()));
g_price_1964 -= gd_2340;
}
}
}
if (TotalBuyLots() + TotalSellLots() > 0.0) {
if (NormalizeDouble(TotalBuyLots(), 2) < NormalizeDouble(TotalSellLots(), 2)) {
if (TotalBuyPos() < 1.0) {
g_lots_1972 = TotalSellLots() - TotalBuyLots();
if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_1972, g_price_1956, 3, 0, 0, "MS Counter Buy Stop", 0, 0, CLR_NONE) < 0) {
Print("Error MS Counter Buy Stop = ", ErrorDescription(GetLastError()));
g_price_1956 += gd_2340;
}
}
}
if (NormalizeDouble(TotalBuyLots(), 2) > NormalizeDouble(TotalSellLots(), 2)) {
if (TotalSellPos() < 1.0) {
g_lots_1980 = TotalBuyLots() - TotalSellLots();
if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_1980, g_price_1964, 3, 0, 0, "MS Counter Sell Stop", 0, 0, CLR_NONE) < 0) {
Print("Error MS Counter Sell Stop = ", ErrorDescription(GetLastError()));
g_price_1964 -= gd_2340;
}
}
}
}
if (gi_368 > 0)
if (gi_368 < gd_2348) gi_368 = gd_2348;
if (gi_372 > 0)
if (gi_372 < gd_2348) gi_372 = gd_2348;
if (gi_376 > 0 && gi_376 < gd_2348) {
gi_376 = gd_2348;
Print("MSTrailingStop is set to minimum Broker limit = ", DoubleToStr(gi_376, 0));
}
gd_2036 = AccountBalance() - g_str2dbl_2028 + AccountProfit();
if (NormalizeDouble(gd_2036, 2) > NormalizeDouble(gi_384, 2)) {
gi_688 = FALSE;
if (OrdersTotal() > 0) {
CloseAll();
g_price_1996 = 0;
gd_1692 = 0;
g_price_2004 = 0;
gd_1700 = 0;
}
FileDelete(g_name_1824);
g_error_756 = GetLastError();
if (g_error_756 != 0/* NO_ERROR */) {
Print("Error = ", g_error_756, " while deleting" + g_name_1824);
gi_684 = FALSE;
break;
}
if (OrdersTotal() <= 0) gi_688 = TRUE;
}
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_1736) {
if (OrderType() == OP_BUY) {
gd_2108 += OrderLots();
if (gi_368 > 0) g_price_2268 = OrderOpenPrice() + gi_368 * gd_2340;
else g_price_2268 = 0;
if (gi_372 > 0) g_price_2260 = OrderOpenPrice() - gi_372 * gd_2340;
else g_price_2260 = 0;
if (gi_376 > 0) {
if (!IsEqual(OrderTakeProfit(), g_price_2268))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2260, g_price_2268, 0, CLR_NONE) < FALSE) Print("Error Modifying MS Buy Open TP & SL = ", ErrorDescription(GetLastError()));
g_ord_open_price_2044 = OrderOpenPrice();
g_ord_stoploss_2060 = OrderStopLoss();
g_ord_open_price_2236 = OrderOpenPrice();
if (MarketInfo(Symbol(), MODE_BID) - g_ord_open_price_2044 > gi_376 * gd_2340) {
if (gi_380 > 0)
if (gd_1692 < MarketInfo(Symbol(), MODE_BID) - gi_380 * gd_2340) gd_1692 = MarketInfo(Symbol(), MODE_BID) - gi_380 * gd_2340;
if (g_ord_stoploss_2060 < MarketInfo(Symbol(), MODE_BID) - gi_376 * gd_2340) {
g_price_2012 = MarketInfo(Symbol(), MODE_BID) - gi_376 * gd_2340;
if (!IsEqual(OrderStopLoss(), g_price_2012))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2012, g_price_2268, 0, CLR_NONE) < FALSE) Print("Error Modifying MS Buy Open TS = ", ErrorDescription(GetLastError()));
}
}
if (gd_1692 > 0.0) {
if (MarketInfo(Symbol(), MODE_BID) < gd_1692)
if (OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 3, CLR_NONE) < 0) Print("Closing MS Buy Error ", ErrorDescription(GetLastError()));
}
if (OrderProfit() < 0.0) gd_1692 = 0;
} else {
if (!IsEqual(OrderTakeProfit(), g_price_2268) || !IsEqual(OrderStopLoss(), g_price_2260))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2260, g_price_2268, 0, CLR_NONE) < FALSE) Print("Error Modifying MS Buy Open TP & SL = ", ErrorDescription(GetLastError()));
}
}
if (OrderType() == OP_SELL) {
gd_2116 += OrderLots();
if (gi_368 > 0) g_price_2308 = OrderOpenPrice() - gi_368 * gd_2340;
else g_price_2308 = 0;
if (gi_372 > 0) g_price_2300 = OrderOpenPrice() + gi_372 * gd_2340;
else g_price_2300 = 0;
if (gi_376 > 0) {
if (!IsEqual(OrderTakeProfit(), g_price_2308))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2300, g_price_2308, 0, CLR_NONE) < FALSE) Print("Error Modifying MS Sell Open TP & SL = ", ErrorDescription(GetLastError()));
g_ord_open_price_2052 = OrderOpenPrice();
g_ord_stoploss_2068 = OrderStopLoss();
g_ord_open_price_2276 = OrderOpenPrice();
if (g_ord_open_price_2052 - MarketInfo(Symbol(), MODE_ASK) > gi_376 * gd_2340) {
if (gi_380 > 0)
if (gd_1700 <= 0.0 || gd_1700 > MarketInfo(Symbol(), MODE_ASK) + gi_380 * gd_2340) gd_1700 = MarketInfo(Symbol(), MODE_ASK) + gi_380 * gd_2340;
if (g_ord_stoploss_2068 == 0.0 || g_ord_stoploss_2068 > MarketInfo(Symbol(), MODE_ASK) + gi_376 * gd_2340) {
g_price_2020 = MarketInfo(Symbol(), MODE_ASK) + gi_376 * gd_2340;
if (!IsEqual(OrderStopLoss(), g_price_2020))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2020, g_price_2308, 0, CLR_NONE) < FALSE) Print("Error Modifying MS Sell Open TS = ", ErrorDescription(GetLastError()));
}
}
if (gd_1700 > 0.0) {
if (MarketInfo(Symbol(), MODE_ASK) > gd_1700)
if (OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 3, CLR_NONE) < 0) Print("Closing MS Sell Error ", ErrorDescription(GetLastError()));
}
if (OrderProfit() < 0.0) gd_1700 = 0;
} else {
if (!IsEqual(OrderTakeProfit(), g_price_2308) || !IsEqual(OrderStopLoss(), g_price_2300))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2300, g_price_2308, 0, CLR_NONE) < FALSE) Print("Error Modifying MS Sell Open TP & SL = ", ErrorDescription(GetLastError()));
}
}
if (OrderType() == OP_BUYSTOP) {
if (OrderOpenPrice() < MarketInfo(Symbol(), MODE_ASK)) OrderDelete(OrderTicket());
if (gi_368 > 0) g_price_2268 = OrderOpenPrice() + gi_368 * gd_2340;
else g_price_2268 = 0;
if (gi_372 > 0) g_price_2260 = OrderOpenPrice() - gi_372 * gd_2340;
else g_price_2260 = 0;
if (gi_352 == TRUE) {
if (gd_2116 > 0.0) MSBuyStop();
} else MSBuyStop();
if (!IsEqual(OrderTakeProfit(), g_price_2268) || !IsEqual(OrderStopLoss(), g_price_2260))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2260, g_price_2268, 0, CLR_NONE) < FALSE) Print("Error Modifying MS Buy Stop TP & SL = ", ErrorDescription(GetLastError()));
}
if (OrderType() == OP_SELLSTOP) {
if (OrderOpenPrice() > MarketInfo(Symbol(), MODE_BID)) OrderDelete(OrderTicket());
if (gi_368 > 0) g_price_2308 = OrderOpenPrice() - gi_368 * gd_2340;
else g_price_2308 = 0;
if (gi_372 > 0) g_price_2300 = OrderOpenPrice() + gi_372 * gd_2340;
else g_price_2300 = 0;
if (gi_352 == TRUE) {
if (gd_2108 > 0.0) MSSellStop();
} else MSSellStop();
if (!IsEqual(OrderTakeProfit(), g_price_2308) || !IsEqual(OrderStopLoss(), g_price_2300))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2300, g_price_2308, 0, CLR_NONE) < FALSE) Print("Error Modifying MS Sell Stop TP & SL = ", ErrorDescription(GetLastError()));
}
}
}
}
}
if (Hedging == TRUE) {
if (BuyOpen() + SellOpen() > 0) gi_772 = BuyOpen() + SellOpen();
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
if (OrderMagicNumber() != g_magic_1736) {
if (OrderType() == OP_BUY) {
gd_2244 += OrderLots();
g_ord_open_price_2236 = OrderOpenPrice();
g_ord_lots_796 = OrderLots();
}
if (OrderType() == OP_SELL) {
gd_2284 += OrderLots();
g_ord_open_price_2276 = OrderOpenPrice();
g_ord_lots_804 = OrderLots();
}
if (OrderType() == OP_BUYSTOP) gd_2252 += OrderLots();
if (OrderType() == OP_SELLSTOP) gd_2292 += OrderLots();
}
}
}
if (BuyLots() > SellLots()) {
if (Multiplier == 0.0) g_lots_2316 = 2.0 * BuyLots() - SellLots();
if (Multiplier == 1.0) g_lots_2316 = g_ord_lots_796 + g_lots_1948;
if (Multiplier > 0.0 && Multiplier != 1.0) g_lots_2316 = g_ord_lots_796 * Multiplier;
if (NormalizeDouble(g_lots_2316, 4) > NormalizeDouble(gd_2292, 4)) {
if (gd_1404 == 0.0) gd_1404 = gd_2244;
if (gd_1404 != gd_2244) {
gd_1404 = gd_2244;
CancelPending();
}
if (increase > 0) {
if (gi_772 >= IncreaseStartLevel) {
if (IncreaseEndLevel == 0) gi_776 = gi_772 - IncreaseStartLevel + 1;
if (IncreaseEndLevel > 0 && gi_772 <= IncreaseEndLevel) gi_776 = gi_772 - IncreaseStartLevel + 1;
if (gd_988 > 0.0) g_price_1580 = g_ord_open_price_2236 - HedgeGap * gd_2340 - 2.0 * gd_988 - gi_776 * increase * gd_2340 - gd_2324;
else g_price_1580 = g_ord_open_price_2236 - HedgeGap * gd_2340 - gi_776 * increase * gd_2340 - gd_2324;
}
if (gi_772 < IncreaseStartLevel) {
if (gd_988 > 0.0) g_price_1580 = g_ord_open_price_2236 - HedgeGap * gd_2340 - 2.0 * gd_988 - gd_2324;
else g_price_1580 = g_ord_open_price_2236 - HedgeGap * gd_2340 - gd_2324;
}
} else {
if (gd_988 > 0.0) g_price_1580 = g_ord_open_price_2236 - HedgeGap * gd_2340 - 2.0 * gd_988 - gd_2324;
else g_price_1580 = g_ord_open_price_2236 - HedgeGap * gd_2340 - gd_2324;
}
g_bid_828 = MarketInfo(Symbol(), MODE_BID);
if (g_bid_828 < g_price_1580) {
gd_820 = g_price_1580 - g_bid_828;
g_price_1580 = g_bid_828;
Print("Sell Counter @ ", g_price_1580);
if (OrderSend(Symbol(), OP_SELL, g_lots_2316, g_price_1580, 3, 0, 0, "Sell at Market Price", 0, 0, CLR_NONE) < 0) Print("Error Open Sell at Market Price = ", ErrorDescription(GetLastError()));
if (GapAdjustment == TRUE) gd_988 += gd_820;
else gd_988 = 0;
}
if (g_bid_828 >= g_price_1580)
if (OrderSend(Symbol(), OP_SELLSTOP, g_lots_2316, g_price_1580, 3, 0, 0, "Sell Stop", 0, 0, CLR_NONE) < 0) Print("Error Open Sell Stop = ", ErrorDescription(GetLastError()));
}
if (NormalizeDouble(g_lots_2316, 4) < NormalizeDouble(gd_2292, 4)) CancelPending();
}
if (SellLots() > BuyLots()) {
if (Multiplier == 0.0) g_lots_2316 = 2.0 * SellLots() - BuyLots();
if (Multiplier == 1.0) g_lots_2316 = g_ord_lots_804 + g_lots_1948;
if (Multiplier > 0.0 && Multiplier != 1.0) g_lots_2316 = g_ord_lots_804 * Multiplier;
if (NormalizeDouble(g_lots_2316, 4) > NormalizeDouble(gd_2252, 4)) {
if (gd_1412 == 0.0) gd_1412 = gd_2284;
if (gd_1412 != gd_2284) {
gd_1412 = gd_2284;
CancelPending();
}
if (increase > 0) {
if (gi_772 >= IncreaseStartLevel) {
if (IncreaseEndLevel == 0) gi_776 = gi_772 - IncreaseStartLevel + 1;
if (IncreaseEndLevel > 0 && gi_772 <= IncreaseEndLevel) gi_776 = gi_772 - IncreaseStartLevel + 1;
if (gd_988 > 0.0) g_price_1572 = g_ord_open_price_2276 + HedgeGap * gd_2340 + 2.0 * gd_988 + gi_776 * increase * gd_2340 + gd_2324;
else g_price_1572 = g_ord_open_price_2276 + HedgeGap * gd_2340 + gi_776 * increase * gd_2340 + gd_2324;
}
if (gi_772 < IncreaseStartLevel) {
if (gd_988 > 0.0) g_price_1572 = g_ord_open_price_2276 + HedgeGap * gd_2340 + 2.0 * gd_988 + gd_2324;
else g_price_1572 = g_ord_open_price_2276 + HedgeGap * gd_2340 + gd_2324;
}
} else {
if (gd_988 > 0.0) g_price_1572 = g_ord_open_price_2276 + HedgeGap * gd_2340 + 2.0 * gd_988 + gd_2324;
else g_price_1572 = g_ord_open_price_2276 + HedgeGap * gd_2340 + gd_2324;
}
g_ask_836 = MarketInfo(Symbol(), MODE_ASK);
if (g_ask_836 > g_price_1572) {
gd_812 = g_ask_836 - g_price_1572;
g_price_1572 = g_ask_836;
Print("Buy Counter @ ", g_price_1572);
if (OrderSend(Symbol(), OP_BUY, g_lots_2316, g_price_1572, 3, 0, 0, "Buy at Market Price", 0, 0, CLR_NONE) < 0) Print("Error Open Buy at Market Price= ", ErrorDescription(GetLastError()));
if (GapAdjustment == TRUE) gd_988 += gd_812;
else gd_988 = 0;
}
if (g_ask_836 <= g_price_1572)
if (OrderSend(Symbol(), OP_BUYSTOP, g_lots_2316, g_price_1572, 3, 0, 0, "Buy Stop", 0, 0, CLR_NONE) < 0) Print("Error Open Buy Stop= ", ErrorDescription(GetLastError()));
}
if (NormalizeDouble(g_lots_2316, 4) < NormalizeDouble(gd_2252, 4)) CancelPending();
}
for (int l_pos_8 = 0; l_pos_8 < OrdersTotal(); l_pos_8++) {
if (OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
if (OrderMagicNumber() != g_magic_1736) {
if (OrderType() == OP_BUYSTOP) {
gd_2252 += OrderLots();
g_ord_open_price_1332 = OrderOpenPrice();
g_ord_lots_1388 = OrderLots();
}
if (OrderType() == OP_SELLSTOP) {
gd_2292 += OrderLots();
g_ord_open_price_1340 = OrderOpenPrice();
g_ord_lots_1396 = OrderLots();
}
}
}
}
if (TakeProfit <= 0) {
g_price_2268 = 0;
g_price_2308 = 0;
g_price_2260 = 0;
g_price_2300 = 0;
}
if (TakeProfit > 0) {
if (GapAdjustment == FALSE) {
if (gd_812 > 0.0 || gd_820 > 0.0) {
if (g_price_2268 < LastOpenBuyPrice() + TakeProfit * gd_2340) {
if (LastOpenBuyPrice() == 0.0) g_price_2268 = g_ord_open_price_2236 + TakeProfit * gd_2340;
else g_price_2268 = LastOpenBuyPrice() + TakeProfit * gd_2340;
}
if (g_price_2308 == 0.0 || g_price_2308 > LastOpenSellPrice() - TakeProfit * gd_2340) {
if (LastOpenSellPrice() == 0.0) g_price_2308 = g_ord_open_price_2276 - TakeProfit * gd_2340;
else g_price_2308 = LastOpenSellPrice() - TakeProfit * gd_2340;
}
if (StopLoss == 0) {
g_price_2260 = g_price_2308 - gd_2324;
g_price_2300 = g_price_2268 + gd_2324;
}
if (StopLoss > 0) {
g_price_2260 = g_ord_open_price_2236 - StopLoss * gd_2340;
g_price_2300 = g_ord_open_price_2276 + StopLoss * gd_2340;
}
} else {
if (StopLoss == 0) {
if (gd_2252 > gd_2292) {
g_price_2268 = g_ord_open_price_1332 + TakeProfit * gd_2340;
g_price_2308 = g_ord_open_price_2276 - TakeProfit * gd_2340;
g_price_2260 = g_price_2308 - gd_2324;
g_price_2300 = g_price_2268 + gd_2324;
}
if (gd_2292 > gd_2252) {
g_price_2268 = g_ord_open_price_2236 + TakeProfit * gd_2340;
g_price_2308 = g_ord_open_price_1340 - TakeProfit * gd_2340;
g_price_2260 = g_price_2308 - gd_2324;
g_price_2300 = g_price_2268 + gd_2324;
}
}
if (StopLoss > 0) {
if (gd_2252 > gd_2292) {
g_price_2268 = g_ord_open_price_1332 + TakeProfit * gd_2340;
g_price_2308 = g_ord_open_price_2276 - TakeProfit * gd_2340;
g_price_2260 = g_ord_open_price_1332 - StopLoss * gd_2340;
g_price_2300 = g_ord_open_price_2276 + StopLoss * gd_2340;
}
if (gd_2292 > gd_2252) {
g_price_2268 = g_ord_open_price_2236 + TakeProfit * gd_2340;
g_price_2308 = g_ord_open_price_1340 - TakeProfit * gd_2340;
g_price_2260 = g_ord_open_price_2236 - StopLoss * gd_2340;
g_price_2300 = g_ord_open_price_1340 + StopLoss * gd_2340;
}
}
}
}
if (GapAdjustment == TRUE) {
if (StopLoss == 0) {
if (gd_2252 > gd_2292) {
g_price_2268 = g_ord_open_price_1332 + TakeProfit * gd_2340;
g_price_2308 = g_ord_open_price_2276 - TakeProfit * gd_2340;
g_price_2260 = g_price_2308 - gd_2324;
g_price_2300 = g_price_2268 + gd_2324;
}
if (gd_2292 > gd_2252) {
g_price_2268 = g_ord_open_price_2236 + TakeProfit * gd_2340;
g_price_2308 = g_ord_open_price_1340 - TakeProfit * gd_2340;
g_price_2260 = g_price_2308 - gd_2324;
g_price_2300 = g_price_2268 + gd_2324;
}
}
if (StopLoss > 0) {
if (gd_2252 > gd_2292) {
g_price_2268 = g_ord_open_price_1332 + TakeProfit * gd_2340;
g_price_2308 = g_ord_open_price_2276 - TakeProfit * gd_2340;
g_price_2260 = g_ord_open_price_1332 - StopLoss * gd_2340;
g_price_2300 = g_ord_open_price_2276 + StopLoss * gd_2340;
}
if (gd_2292 > gd_2252) {
g_price_2268 = g_ord_open_price_2236 + TakeProfit * gd_2340;
g_price_2308 = g_ord_open_price_1340 - TakeProfit * gd_2340;
g_price_2260 = g_ord_open_price_2236 - StopLoss * gd_2340;
g_price_2300 = g_ord_open_price_1340 + StopLoss * gd_2340;
}
}
}
}
if (OrderMagicNumber() != g_magic_1736) {
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_1736) {
if (OrderType() == OP_BUY) {
if (!IsEqual(OrderTakeProfit(), g_price_2268) || !IsEqual(OrderStopLoss(), g_price_2260)) {
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2260, g_price_2268, 0, CLR_NONE)) {
}
}
}
if (OrderType() == OP_SELL) {
if (!IsEqual(OrderTakeProfit(), g_price_2308) || !IsEqual(OrderStopLoss(), g_price_2300)) {
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2300, g_price_2308, 0, CLR_NONE)) {
}
}
}
if (OrderType() == OP_BUYSTOP)
if (!IsEqual(OrderTakeProfit(), g_price_2268) || !IsEqual(OrderStopLoss(), g_price_2260)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2260, g_price_2268, 0, CLR_NONE);
if (OrderType() == OP_SELLSTOP)
if (!IsEqual(OrderTakeProfit(), g_price_2308) || !IsEqual(OrderStopLoss(), g_price_2300)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2300, g_price_2308, 0, CLR_NONE);
}
}
}
}
}
if (Averaging == TRUE) {
if (BuyLots() > SellLots()) gi_1848 = BuyOpen();
if (BuyLots() < SellLots()) gi_1852 = SellOpen();
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
if (OrderMagicNumber() != g_magic_1736) {
if (OrderType() == OP_BUY) {
gd_2244 += OrderLots();
g_ord_open_price_2236 = OrderOpenPrice();
g_ord_lots_796 = OrderLots();
}
if (OrderType() == OP_SELL) {
gd_2284 += OrderLots();
g_ord_open_price_2276 = OrderOpenPrice();
g_ord_lots_804 = OrderLots();
}
if (OrderType() == OP_BUYLIMIT) {
gd_2252 += OrderLots();
g_ord_lots_1388 = OrderLots();
}
if (OrderType() == OP_SELLLIMIT) {
gd_2292 += OrderLots();
g_ord_lots_1396 = OrderLots();
}
}
}
}
if (MaxLotStop > 0.0 && MaxLotStop > MarketInfo(Symbol(), MODE_MINLOT)) {
if (NormalizeDouble(g_ord_lots_796, 4) >= NormalizeDouble(MaxLotStop, 4) || NormalizeDouble(g_ord_lots_1388, 4) >= NormalizeDouble(MaxLotStop, 4)) gi_716 = TRUE;
else gi_716 = FALSE;
if (NormalizeDouble(g_ord_lots_804, 4) >= NormalizeDouble(MaxLotStop, 4) || NormalizeDouble(g_ord_lots_1396, 4) >= NormalizeDouble(MaxLotStop, 4)) gi_720 = TRUE;
else gi_720 = FALSE;
}
if (gi_716 == FALSE) {
if (BuyLots() > SellLots()) {
if (StartFromHiLow == TRUE && HiLowIndicatorLevel > 0) {
gd_1612 = g_ord_open_price_2236 - HiLowIndicatorLevel * gd_2340;
if (MarketInfo(Symbol(), MODE_BID) <= gd_1612) gd_1628 = 1;
if (gd_1628 == 1.0) {
if (MarketInfo(Symbol(), MODE_BID) >= g_ord_open_price_2236) {
CloseAll();
gs_1728 = "HiLow Indicator Buy";
gd_1628 = 0;
}
}
}
if (AveragingMultiplier == 0.0) g_lots_2316 = g_lots_1948;
if (AveragingMultiplier == 1.0) g_lots_2316 = g_ord_lots_796 + g_lots_1948;
if (AveragingMultiplier > 0.0 && AveragingMultiplier != 1.0) g_lots_2316 = g_ord_lots_796 * AveragingMultiplier;
if (MaxLotStop > 0.0 && MaxLotStop > MarketInfo(Symbol(), MODE_MINLOT))
if (NormalizeDouble(MaxLotStop, 4) < NormalizeDouble(g_lots_2316, 4)) g_lots_2316 = MaxLotStop;
if (NormalizeDouble(g_lots_2316, 4) > NormalizeDouble(gd_2252, 4)) {
if (gd_1404 == 0.0) gd_1404 = gd_2244;
if (gd_1404 != gd_2244) {
gd_1404 = gd_2244;
CancelPending();
}
if (increase > 0) {
if (gi_1848 >= IncreaseStartLevel) {
if (IncreaseEndLevel == 0) gi_776 = gi_1848 - IncreaseStartLevel + 1;
if (IncreaseEndLevel > 0 && gi_1848 <= IncreaseEndLevel) gi_776 = gi_1848 - IncreaseStartLevel + 1;
if (gd_988 > 0.0) g_price_1572 = g_ord_open_price_2236 - AveragingHedgeGap * gd_2340 - 2.0 * gd_988 - gi_776 * increase * gd_2340 - gd_2324;
else g_price_1572 = g_ord_open_price_2236 - AveragingHedgeGap * gd_2340 - gi_776 * increase * gd_2340 - gd_2324;
}
if (gi_1848 < IncreaseStartLevel) {
if (gd_988 > 0.0) g_price_1572 = g_ord_open_price_2236 - AveragingHedgeGap * gd_2340 - 2.0 * gd_988 - gd_2324;
else g_price_1572 = g_ord_open_price_2236 - AveragingHedgeGap * gd_2340 - gd_2324;
}
} else {
if (gd_988 > 0.0) g_price_1572 = g_ord_open_price_2236 - AveragingHedgeGap * gd_2340 - 2.0 * gd_988 - gd_2324;
else g_price_1572 = g_ord_open_price_2236 - AveragingHedgeGap * gd_2340 - gd_2324;
}
g_ask_836 = MarketInfo(Symbol(), MODE_ASK);
if (g_ask_836 < g_price_1572) {
gd_812 = g_price_1572 - g_ask_836;
g_price_1572 = g_ask_836;
Print("Average Buy Counter @ ", g_price_1572);
if (OrderSend(Symbol(), OP_BUY, g_lots_2316, g_price_1572, 3, 0, 0, "Average Buy at Market Price", 0, 0, CLR_NONE) < 0) Print("Error Open Buy Average at Market Price = ", ErrorDescription(GetLastError()));
if (GapAdjustment == TRUE) gd_988 += gd_812;
else gd_988 = 0;
}
if (g_ask_836 >= g_price_1572)
if (OrderSend(Symbol(), OP_BUYLIMIT, g_lots_2316, g_price_1572, 3, 0, 0, "Buy Limit", 0, 0, CLR_NONE) < 0) Print("Error Open Buy Limit = ", ErrorDescription(GetLastError()));
}
if (NormalizeDouble(g_lots_2316, 4) < NormalizeDouble(gd_2252, 4)) CancelPending();
}
}
if (gi_720 == FALSE) {
if (SellLots() > BuyLots()) {
if (StartFromHiLow == TRUE && HiLowIndicatorLevel > 0) {
gd_1620 = g_ord_open_price_2276 + HiLowIndicatorLevel * gd_2340;
if (MarketInfo(Symbol(), MODE_ASK) >= gd_1620) gd_1636 = 1;
if (gd_1636 == 1.0) {
if (MarketInfo(Symbol(), MODE_BID) <= g_ord_open_price_2276) {
CloseAll();
gs_1728 = "HiLow Indicator Sell";
gd_1636 = 0;
}
}
}
if (AveragingMultiplier == 0.0) g_lots_2316 = g_lots_1948;
if (AveragingMultiplier == 1.0) g_lots_2316 = g_ord_lots_804 + g_lots_1948;
if (AveragingMultiplier > 0.0 && AveragingMultiplier != 1.0) g_lots_2316 = g_ord_lots_804 * AveragingMultiplier;
if (MaxLotStop > 0.0 && MaxLotStop > MarketInfo(Symbol(), MODE_MINLOT))
if (NormalizeDouble(MaxLotStop, 4) < NormalizeDouble(g_lots_2316, 4)) g_lots_2316 = MaxLotStop;
if (NormalizeDouble(g_lots_2316, 4) > NormalizeDouble(gd_2292, 4)) {
if (gd_1412 == 0.0) gd_1412 = gd_2284;
if (gd_1412 != gd_2284) {
gd_1412 = gd_2284;
CancelPending();
}
if (increase > 0) {
if (gi_1852 >= IncreaseStartLevel) {
if (IncreaseEndLevel == 0) gi_776 = gi_1852 - IncreaseStartLevel + 1;
if (IncreaseEndLevel > 0 && gi_1852 <= IncreaseEndLevel) gi_776 = gi_1852 - IncreaseStartLevel + 1;
if (gd_988 > 0.0) g_price_1580 = g_ord_open_price_2276 + AveragingHedgeGap * gd_2340 + 2.0 * gd_988 + gi_776 * increase * gd_2340 + gd_2324;
else g_price_1580 = g_ord_open_price_2276 + AveragingHedgeGap * gd_2340 + gi_776 * increase * gd_2340 + gd_2324;
}
if (gi_1852 < IncreaseStartLevel) {
if (gd_988 > 0.0) g_price_1580 = g_ord_open_price_2276 + AveragingHedgeGap * gd_2340 + 2.0 * gd_988 + gd_2324;
else g_price_1580 = g_ord_open_price_2276 + AveragingHedgeGap * gd_2340 + gd_2324;
}
} else {
if (gd_988 > 0.0) g_price_1580 = g_ord_open_price_2276 + AveragingHedgeGap * gd_2340 + 2.0 * gd_988 + gd_2324;
else g_price_1580 = g_ord_open_price_2276 + AveragingHedgeGap * gd_2340 + gd_2324;
}
g_bid_828 = MarketInfo(Symbol(), MODE_BID);
if (g_bid_828 >= g_price_1580) {
gd_820 = g_bid_828 - g_price_1580;
g_price_1580 = g_bid_828;
Print("Average Sell Counter @ ", g_price_1580);
if (OrderSend(Symbol(), OP_SELL, g_lots_2316, g_price_1580, 3, 0, 0, "Sell Average at Market Price", 0, 0, CLR_NONE) < 0) Print("Error Open Sell Average at Market Price= ", ErrorDescription(GetLastError()));
if (GapAdjustment == TRUE) gd_988 += gd_820;
else gd_988 = 0;
}
if (g_bid_828 < g_price_1580)
if (OrderSend(Symbol(), OP_SELLLIMIT, g_lots_2316, g_price_1580, 3, 0, 0, "Sell Limit", 0, 0, CLR_NONE) < 0) Print("Error Open Sell Limit= ", ErrorDescription(GetLastError()));
}
if (NormalizeDouble(g_lots_2316, 4) < NormalizeDouble(gd_2292, 4)) CancelPending();
}
}
for (l_pos_8 = 0; l_pos_8 < OrdersTotal(); l_pos_8++) {
if (OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
if (OrderMagicNumber() != g_magic_1736) {
if (OrderType() == OP_BUYLIMIT) {
gd_2252 += OrderLots();
g_ord_open_price_1332 = OrderOpenPrice();
g_ord_lots_1388 = OrderLots();
}
if (OrderType() == OP_SELLLIMIT) {
gd_2292 += OrderLots();
g_ord_open_price_1340 = OrderOpenPrice();
g_ord_lots_1396 = OrderLots();
}
}
}
}
if (AveragingTakeProfit <= 0) {
g_price_2268 = 0;
g_price_2308 = 0;
g_price_2260 = 0;
g_price_2300 = 0;
}
if (AveragingTakeProfit > 0) {
if (gd_2244 > gd_2284) {
if (gd_2252 > 0.0) {
if (g_ord_open_price_1332 > FirstOpenBuyPrice()) {
if (g_price_2268 < g_ord_open_price_1332 + AveragingTakeProfit * gd_2340) g_price_2268 = g_ord_open_price_1332 + AveragingTakeProfit * gd_2340;
} else
if (g_price_2268 < FirstOpenBuyPrice() + AveragingTakeProfit * gd_2340) g_price_2268 = FirstOpenBuyPrice() + AveragingTakeProfit * gd_2340;
} else
if (g_price_2268 < FirstOpenBuyPrice() + AveragingTakeProfit * gd_2340) g_price_2268 = FirstOpenBuyPrice() + AveragingTakeProfit * gd_2340;
}
if (gd_2284 > gd_2244) {
if (gd_2292 > 0.0) {
if (g_ord_open_price_1340 < FirstOpenSellPrice()) {
if (g_price_2308 == 0.0 || g_price_2308 > g_ord_open_price_1340 - AveragingTakeProfit * gd_2340) g_price_2308 = g_ord_open_price_1340 - AveragingTakeProfit * gd_2340;
} else
if (g_price_2308 == 0.0 || g_price_2308 > FirstOpenSellPrice() - AveragingTakeProfit * gd_2340) g_price_2308 = FirstOpenSellPrice() - AveragingTakeProfit * gd_2340;
} else
if (g_price_2308 == 0.0 || g_price_2308 > FirstOpenSellPrice() - AveragingTakeProfit * gd_2340) g_price_2308 = FirstOpenSellPrice() - AveragingTakeProfit * gd_2340;
}
} else {
g_price_2268 = 0;
g_price_2308 = 0;
}
if (AveragingStopLoss > 0) {
if (gd_2244 > gd_2284) {
if (gd_2252 > 0.0) {
if (g_ord_open_price_1332 > FirstOpenBuyPrice()) {
if (g_price_2260 == 0.0 || g_price_2260 > FirstOpenBuyPrice() - AveragingStopLoss * gd_2340) g_price_2260 = FirstOpenBuyPrice() - AveragingStopLoss * gd_2340;
} else
if (g_price_2260 == 0.0 || g_price_2260 > g_ord_open_price_1332 - AveragingStopLoss * gd_2340) g_price_2260 = g_ord_open_price_1332 - AveragingStopLoss * gd_2340;
} else
if (g_price_2260 == 0.0 || g_price_2260 > FirstOpenBuyPrice() - AveragingStopLoss * gd_2340) g_price_2260 = FirstOpenBuyPrice() - AveragingStopLoss * gd_2340;
}
if (gd_2284 > gd_2244) {
if (gd_2292 > 0.0) {
if (g_ord_open_price_1340 < FirstOpenSellPrice()) {
if (g_price_2300 < FirstOpenSellPrice() + AveragingStopLoss * gd_2340) g_price_2300 = FirstOpenSellPrice() + AveragingStopLoss * gd_2340;
} else
if (g_price_2300 < g_ord_open_price_1340 + AveragingStopLoss * gd_2340) g_price_2300 = g_ord_open_price_1340 + AveragingStopLoss * gd_2340;
} else
if (g_price_2300 < FirstOpenSellPrice() + AveragingStopLoss * gd_2340) g_price_2300 = FirstOpenSellPrice() + AveragingStopLoss * gd_2340;
}
} else {
g_price_2260 = 0;
g_price_2300 = 0;
}
if (OrderMagicNumber() != g_magic_1736) {
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_1736) {
if (OrderType() == OP_BUY) {
if (!IsEqual(OrderTakeProfit(), g_price_2268) || !IsEqual(OrderStopLoss(), g_price_2260)) {
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2260, g_price_2268, 0, CLR_NONE)) {
}
}
}
if (OrderType() == OP_SELL) {
if (!IsEqual(OrderTakeProfit(), g_price_2308) || !IsEqual(OrderStopLoss(), g_price_2300)) {
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2300, g_price_2308, 0, CLR_NONE)) {
}
}
}
if (OrderType() == OP_BUYLIMIT) {
if (BuyOpen() < 1 && OrderMagicNumber() != 5566) OrderDelete(OrderTicket());
if (!IsEqual(OrderTakeProfit(), g_price_2268) || !IsEqual(OrderStopLoss(), g_price_2260)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2260, g_price_2268, 0, CLR_NONE);
}
if (OrderType() == OP_SELLLIMIT) {
if (SellOpen() < 1 && OrderMagicNumber() != 5566) OrderDelete(OrderTicket());
if (!IsEqual(OrderTakeProfit(), g_price_2308) || !IsEqual(OrderStopLoss(), g_price_2300)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2300, g_price_2308, 0, CLR_NONE);
}
}
}
}
}
}
if (DisableTrailingStop == FALSE) {
if (TrailingStop <= 0) {
TrailingStopStartLevel = 0;
TrailingStopEndLevel = 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 (BuyLots() > SellLots()) {
if (Averaging == TRUE) gi_772 = gi_1848;
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
if (OrderType() == OP_BUY && OrderMagicNumber() != g_magic_1736) {
if (TrailingStop > 0) {
if (gi_772 >= TrailingStopStartLevel) {
if (TrailingStopEndLevel == 0 || gi_772 < TrailingStopEndLevel) {
if (AccountProfit() >= 0.0) {
if (g_bid_996 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_996) g_bid_996 = MarketInfo(Symbol(), MODE_BID);
if (MarketInfo(Symbol(), MODE_BID) - g_bid_996 > TrailingStop * gd_2340) {
gd_876 = MarketInfo(Symbol(), MODE_BID) - TrailingStop * gd_2340;
if (gd_956 < gd_876) gd_956 = gd_876;
}
if (gd_956 > 0.0) {
if (MarketInfo(Symbol(), MODE_BID) > g_bid_844) {
g_bid_844 = MarketInfo(Symbol(), MODE_BID);
if (Rebound > 0) gd_860 = g_bid_844 - Rebound * gd_2340;
}
if (MarketInfo(Symbol(), MODE_BID) < gd_956 || MarketInfo(Symbol(), MODE_BID) < gd_860) {
CloseAll();
gs_1728 = "Trailing Stop Buy";
}
}
}
if (AccountProfit() < 0.0) {
g_bid_996 = 0;
gd_956 = 0;
gd_860 = 0;
g_bid_844 = 0;
}
}
}
}
}
if (TrailingStop_2 > 0) {
if (gi_772 >= TrailingStop_2_StartLevel) {
if (TrailingStop_2_EndLevel == 0 || gi_772 < TrailingStop_2_EndLevel) {
if (AccountProfit() >= 0.0) {
if (g_bid_1012 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1012) g_bid_1012 = MarketInfo(Symbol(), MODE_BID);
if (MarketInfo(Symbol(), MODE_BID) - g_bid_1012 > TrailingStop_2 * gd_2340) {
gd_1028 = MarketInfo(Symbol(), MODE_BID) - TrailingStop_2 * gd_2340;
if (gd_1020 < gd_1028) gd_1020 = gd_1028;
}
if (gd_1020 > 0.0) {
if (MarketInfo(Symbol(), MODE_BID) > g_bid_1036) {
g_bid_1036 = MarketInfo(Symbol(), MODE_BID);
if (Rebound_2 > 0) gd_1044 = g_bid_1036 - Rebound_2 * gd_2340;
}
if (MarketInfo(Symbol(), MODE_BID) < gd_1020 || MarketInfo(Symbol(), MODE_BID) < gd_1044) {
CloseAll();
gs_1728 = "Trailing Stop Buy 2";
}
}
}
if (AccountProfit() < 0.0) {
g_bid_1012 = 0;
gd_1020 = 0;
gd_1044 = 0;
g_bid_1036 = 0;
}
}
}
}
if (TrailingStop_3 > 0) {
if (gi_772 >= TrailingStop_3_StartLevel) {
if (TrailingStop_3_EndLevel == 0 || gi_772 < TrailingStop_3_EndLevel) {
if (AccountProfit() >= 0.0) {
if (g_bid_1092 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1092) g_bid_1092 = MarketInfo(Symbol(), MODE_BID);
if (MarketInfo(Symbol(), MODE_BID) - g_bid_1092 > TrailingStop_3 * gd_2340) {
gd_1108 = MarketInfo(Symbol(), MODE_BID) - TrailingStop_3 * gd_2340;
if (gd_1100 < gd_1108) gd_1100 = gd_1108;
}
if (gd_1100 > 0.0) {
if (MarketInfo(Symbol(), MODE_BID) > g_bid_1116) {
g_bid_1116 = MarketInfo(Symbol(), MODE_BID);
if (Rebound_3 > 0) gd_1124 = g_bid_1116 - Rebound_3 * gd_2340;
}
if (MarketInfo(Symbol(), MODE_BID) < gd_1100 || MarketInfo(Symbol(), MODE_BID) < gd_1124) {
CloseAll();
gs_1728 = "Trailing Stop Buy 3";
}
}
}
if (AccountProfit() < 0.0) {
g_bid_1092 = 0;
gd_1100 = 0;
gd_1124 = 0;
g_bid_1116 = 0;
}
}
}
}
if (TrailingStop_4 > 0) {
if (gi_772 >= TrailingStop_4_StartLevel) {
if (TrailingStop_4_EndLevel == 0 || gi_772 < TrailingStop_4_EndLevel) {
if (AccountProfit() >= 0.0) {
if (g_bid_1172 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1172) g_bid_1172 = MarketInfo(Symbol(), MODE_BID);
if (MarketInfo(Symbol(), MODE_BID) - g_bid_1172 > TrailingStop_4 * gd_2340) {
gd_1188 = MarketInfo(Symbol(), MODE_BID) - TrailingStop_4 * gd_2340;
if (gd_1180 < gd_1188) gd_1180 = gd_1188;
}
if (gd_1180 > 0.0) {
if (MarketInfo(Symbol(), MODE_BID) > g_bid_1196) {
g_bid_1196 = MarketInfo(Symbol(), MODE_BID);
if (Rebound_4 > 0) gd_1204 = g_bid_1196 - Rebound_4 * gd_2340;
}
if (MarketInfo(Symbol(), MODE_BID) < gd_1180 || MarketInfo(Symbol(), MODE_BID) < gd_1204) {
CloseAll();
gs_1728 = "Trailing Stop Buy 4";
}
}
}
if (AccountProfit() < 0.0) {
g_bid_1172 = 0;
gd_1180 = 0;
gd_1204 = 0;
g_bid_1196 = 0;
}
}
}
}
}
}
}
if (SellLots() > BuyLots()) {
if (Averaging == TRUE) gi_772 = gi_1852;
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
if (OrderType() == OP_SELL && OrderMagicNumber() != g_magic_1736) {
if (TrailingStop > 0) {
if (gi_772 >= TrailingStopStartLevel) {
if (TrailingStopEndLevel == 0 || gi_772 < TrailingStopEndLevel) {
if (AccountProfit() >= 0.0) {
if (g_ask_1004 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1004) g_ask_1004 = MarketInfo(Symbol(), MODE_ASK);
if (g_ask_1004 - MarketInfo(Symbol(), MODE_ASK) > TrailingStop * gd_2340) {
gd_884 = MarketInfo(Symbol(), MODE_ASK) + TrailingStop * gd_2340;
if (gd_964 == 0.0 || gd_964 > gd_884) gd_964 = gd_884;
}
if (gd_964 > 0.0) {
if (g_ask_852 == 0.0 || MarketInfo(Symbol(), MODE_ASK) < g_ask_852) {
g_ask_852 = MarketInfo(Symbol(), MODE_ASK);
if (Rebound > 0) gd_868 = g_ask_852 + Rebound * gd_2340;
}
if (MarketInfo(Symbol(), MODE_ASK) > gd_964 || MarketInfo(Symbol(), MODE_ASK) > gd_868) {
CloseAll();
gs_1728 = "Trailing Stop Sell";
}
}
}
if (AccountProfit() < 0.0) {
g_ask_1004 = 0;
gd_964 = 0;
gd_868 = 0;
g_ask_852 = 0;
}
}
}
}
}
if (TrailingStop_2 > 0) {
if (gi_772 >= TrailingStop_2_StartLevel) {
if (TrailingStop_2_EndLevel == 0 || gi_772 < TrailingStop_2_EndLevel) {
if (AccountProfit() >= 0.0) {
if (g_ask_1052 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1052) g_ask_1052 = MarketInfo(Symbol(), MODE_ASK);
if (g_ask_1052 - MarketInfo(Symbol(), MODE_ASK) > TrailingStop_2 * gd_2340) {
gd_1068 = MarketInfo(Symbol(), MODE_ASK) + TrailingStop_2 * gd_2340;
if (gd_1060 == 0.0 || gd_1060 > gd_1068) gd_1060 = gd_1068;
}
if (gd_1060 > 0.0) {
if (g_ask_1076 == 0.0 || MarketInfo(Symbol(), MODE_ASK) < g_ask_1076) {
g_ask_1076 = MarketInfo(Symbol(), MODE_ASK);
if (Rebound_2 > 0) gd_1084 = g_ask_1076 + Rebound_2 * gd_2340;
}
if (MarketInfo(Symbol(), MODE_ASK) > gd_1060 || MarketInfo(Symbol(), MODE_ASK) > gd_1084) {
CloseAll();
gs_1728 = "Trailing Stop Sell 2";
}
}
}
if (AccountProfit() < 0.0) {
g_ask_1052 = 0;
gd_1060 = 0;
gd_1084 = 0;
g_ask_1076 = 0;
}
}
}
}
if (TrailingStop_3 > 0) {
if (gi_772 >= TrailingStop_3_StartLevel) {
if (TrailingStop_3_EndLevel == 0 || gi_772 < TrailingStop_3_EndLevel) {
if (AccountProfit() >= 0.0) {
if (g_ask_1132 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1132) g_ask_1132 = MarketInfo(Symbol(), MODE_ASK);
if (g_ask_1132 - MarketInfo(Symbol(), MODE_ASK) > TrailingStop_3 * gd_2340) {
gd_1148 = MarketInfo(Symbol(), MODE_ASK) + TrailingStop_3 * gd_2340;
if (gd_1140 == 0.0 || gd_1140 > gd_1148) gd_1140 = gd_1148;
}
if (gd_1140 > 0.0) {
if (g_ask_1156 == 0.0 || MarketInfo(Symbol(), MODE_ASK) < g_ask_1156) {
g_ask_1156 = MarketInfo(Symbol(), MODE_ASK);
if (Rebound_3 > 0) gd_1164 = g_ask_1156 + Rebound_3 * gd_2340;
}
if (MarketInfo(Symbol(), MODE_ASK) > gd_1140 || MarketInfo(Symbol(), MODE_ASK) > gd_1164) {
CloseAll();
gs_1728 = "Trailing Stop Sell 3";
}
}
}
if (AccountProfit() < 0.0) {
g_ask_1132 = 0;
gd_1140 = 0;
gd_1164 = 0;
g_ask_1156 = 0;
}
}
}
}
if (TrailingStop_4 > 0) {
if (gi_772 >= TrailingStop_4_StartLevel) {
if (TrailingStop_4_EndLevel == 0 || gi_772 < TrailingStop_4_EndLevel) {
if (AccountProfit() >= 0.0) {
if (g_ask_1212 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1212) g_ask_1212 = MarketInfo(Symbol(), MODE_ASK);
if (g_ask_1212 - MarketInfo(Symbol(), MODE_ASK) > TrailingStop_4 * gd_2340) {
gd_1228 = MarketInfo(Symbol(), MODE_ASK) + TrailingStop_4 * gd_2340;
if (gd_1220 == 0.0 || gd_1220 > gd_1228) gd_1220 = gd_1228;
}
if (gd_1220 > 0.0) {
if (gd_1236 == 0.0 || MarketInfo(Symbol(), MODE_ASK) < gd_1236) {
g_ask_1156 = MarketInfo(Symbol(), MODE_ASK);
if (Rebound_4 > 0) gd_1244 = gd_1236 + Rebound_4 * gd_2340;
}
if (MarketInfo(Symbol(), MODE_ASK) > gd_1220 || MarketInfo(Symbol(), MODE_ASK) > gd_1244) {
CloseAll();
gs_1728 = "Trailing Stop Sell 4";
}
}
}
if (AccountProfit() < 0.0) {
g_ask_1212 = 0;
gd_1220 = 0;
gd_1244 = 0;
gd_1236 = 0;
}
}
}
}
}
}
}
}
if (Doubler == TRUE) {
if (DoublerEndLevel <= DoublerStartLevel) DoublerEndLevel = 0;
if (DoublerStartLevel < 1) DoublerStartLevel = 1;
if (DoublerMaxOrder < 0) DoublerMaxOrder = 0;
if (gi_752 != gi_772) {
gi_752 = gi_772;
if (g_count_1364 > 0 || g_count_1368 > 0) {
g_count_1364 = 0;
g_count_1368 = 0;
}
}
if (AllBuyLots() > AllSellLots()) {
if (Averaging == TRUE) gi_772 = gi_1848;
if (gi_772 >= DoublerStartLevel) {
if (DoublerEndLevel == 0 || gi_772 < DoublerEndLevel) {
if (DoublerMaxOrder == 0 || g_count_1364 < DoublerMaxOrder) {
if (AccountProfit() >= 0.0) {
if (DoublerBuyLots() == 0.0) {
if (g_lots_1316 > 0.0) {
if (DoublerMultiplier <= 0.0 || DoublerMultiplier == 1.0)
if (DoublerAddition > 0.0) g_lots_1316 = g_ord_lots_1348 + DoublerAddition;
if (DoublerMultiplier > 0.0 && DoublerMultiplier != 1.0) {
if (DoublerAddition <= 0.0) g_lots_1316 = g_ord_lots_1348 * DoublerMultiplier;
if (DoublerAddition > 0.0) g_lots_1316 = g_ord_lots_1348 * DoublerMultiplier + DoublerAddition;
}
} else g_lots_1316 = DoublerLotSize;
if (g_ask_1252 == 0.0) g_ask_1252 = MarketInfo(Symbol(), MODE_ASK);
if (g_ask_1252 > 0.0)
if (MarketInfo(Symbol(), MODE_ASK) < g_ask_1252) g_ask_1252 = MarketInfo(Symbol(), MODE_ASK);
gd_1268 = g_ask_1252 + DoublerRangeFromProfit * gd_2340;
if (MarketInfo(Symbol(), MODE_ASK) >= g_ask_1252 + DoublerRangeFromProfit * gd_2340) {
if (OrderSend(Symbol(), OP_BUY, g_lots_1316, MarketInfo(Symbol(), MODE_ASK), 3, 0, 0, "Doubler Buy", g_magic_1736, 0, CLR_NONE) > 0) {
g_count_1364++;
g_price_1436 = 0;
g_price_1420 = 0;
}
}
}
} else {
gd_1268 = 0;
g_ask_1252 = 0;
}
}
}
}
}
if (AllSellLots() > AllBuyLots()) {
if (Averaging == TRUE) gi_772 = gi_1852;
if (gi_772 >= DoublerStartLevel) {
if (DoublerEndLevel == 0 || gi_772 < DoublerEndLevel) {
if (DoublerMaxOrder == 0 || g_count_1368 < DoublerMaxOrder) {
if (AccountProfit() >= 0.0) {
if (DoublerSellLots() == 0.0) {
if (g_lots_1324 > 0.0) {
if (DoublerMultiplier <= 0.0 || DoublerMultiplier == 1.0)
if (DoublerAddition > 0.0) g_lots_1324 = g_ord_lots_1356 + DoublerAddition;
if (DoublerMultiplier > 0.0 && DoublerMultiplier != 1.0) {
if (DoublerAddition <= 0.0) g_lots_1324 = g_ord_lots_1356 * DoublerMultiplier;
if (DoublerAddition > 0.0) g_lots_1324 = g_ord_lots_1356 * DoublerMultiplier + DoublerAddition;
}
} else g_lots_1324 = DoublerLotSize;
if (g_bid_1260 == 0.0) g_bid_1260 = MarketInfo(Symbol(), MODE_BID);
if (g_bid_1260 > 0.0)
if (MarketInfo(Symbol(), MODE_BID) > g_bid_1260) g_bid_1260 = MarketInfo(Symbol(), MODE_BID);
gd_1276 = g_bid_1260 - DoublerRangeFromProfit * gd_2340;
if (MarketInfo(Symbol(), MODE_BID) <= g_bid_1260 - DoublerRangeFromProfit * gd_2340) {
if (OrderSend(Symbol(), OP_SELL, g_lots_1324, MarketInfo(Symbol(), MODE_BID), 3, 0, 0, "Doubler Sell", g_magic_1736, 0, CLR_NONE) > 0) {
g_count_1368++;
g_price_1444 = 0;
g_price_1428 = 0;
}
}
}
} else {
gd_1276 = 0;
g_bid_1260 = 0;
}
}
}
}
}
for (g_pos_764 = 0; g_pos_764 < OrdersTotal(); g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
if (OrderMagicNumber() == g_magic_1736) {
if (OrderType() == OP_BUY) {
g_ord_open_price_1556 = OrderOpenPrice();
g_ord_lots_1348 = OrderLots();
gd_1540 += OrderLots();
if (DoublerTakeProfit <= 0) gd_1284 = 0;
if (DoublerTakeProfit > 0) gd_1284 = g_ord_open_price_1556 + DoublerTakeProfit * gd_2340;
if (DoublerStopLoss <= 0) gd_1292 = 0;
if (DoublerStopLoss > 0) gd_1292 = g_ord_open_price_1556 - DoublerStopLoss * gd_2340;
if (g_price_1420 == 0.0) g_price_1420 = gd_1284;
if (g_price_1436 == 0.0) g_price_1436 = gd_1292;
if (!IsEqual(OrderStopLoss(), g_price_1436))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1436, OrderTakeProfit(), 0, CLR_NONE) == FALSE) g_price_1436 -= gd_2340;
if (!IsEqual(OrderTakeProfit(), g_price_1420))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1436, g_price_1420, 0, CLR_NONE) == FALSE) g_price_1420 += gd_2340;
}
if (OrderType() == OP_SELL) {
g_ord_open_price_1564 = OrderOpenPrice();
g_ord_lots_1356 = OrderLots();
gd_1548 += OrderLots();
if (DoublerTakeProfit <= 0) gd_1300 = 0;
if (DoublerTakeProfit > 0) gd_1300 = g_ord_open_price_1564 - DoublerTakeProfit * gd_2340;
if (DoublerStopLoss <= 0) gd_1308 = 0;
if (DoublerStopLoss > 0) gd_1308 = g_ord_open_price_1564 + DoublerStopLoss * gd_2340;
if (g_price_1428 == 0.0) g_price_1428 = gd_1300;
if (g_price_1444 == 0.0) g_price_1444 = gd_1308;
if (!IsEqual(OrderStopLoss(), g_price_1444))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1444, OrderTakeProfit(), 0, CLR_NONE) == FALSE) g_price_1444 += gd_2340;
if (!IsEqual(OrderTakeProfit(), g_price_1428))
if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_1444, g_price_1428, 0, CLR_NONE) == FALSE) g_price_1428 -= gd_2340;
}
}
}
}
}
}
if (BuyLots() + SellLots() > 0.0) LABEL("ACTIVEORDERS_", "Active: " + gi_748, "Arial Bold", 270, gi_2432, gi_2376);
else LABEL("ACTIVEORDERS_", "Total Active: " + gi_748, "Arial Bold", 270, gi_2432, gi_2412);
gs_2356 = "";
gs_2364 = "";
if (BuyLots() > 0.0) {
gs_2356 = " lots @" + DoubleToStr(g_ord_open_price_2236, Digits) + " TP: " + DoubleToStr(g_price_2268, Digits) + " SL: " + DoubleToStr(g_price_2260, Digits);
LABEL("BUY_", "Active Buy: " + DoubleToStr(gd_2244, 2) + gs_2356, "Arial Bold", 0, gi_2436, gi_2380);
} else LABEL("BUY_", "Active Buy: " + DoubleToStr(gd_2244, 2) + gs_2356, "Arial Bold", 0, gi_2436, gi_2412);
if (SellLots() > 0.0) {
gs_2364 = " lots @" + DoubleToStr(g_ord_open_price_2276, Digits) + " TP: " + DoubleToStr(g_price_2308, Digits) + " SL: " + DoubleToStr(g_price_2300, Digits);
LABEL("SELL_", "Active Sell: " + DoubleToStr(gd_2284, 2) + gs_2364, "Arial Bold", 0, gi_2440, gi_2388);
} else LABEL("SELL_", "Active Sell: " + DoubleToStr(gd_2284, 2) + gs_2364, "Arial Bold", 0, gi_2440, gi_2412);
if (gd_2252 > 0.0) {
gs_1752 = "";
gs_1752 = " lots @" + DoubleToStr(g_ord_open_price_1332, Digits) + " TP: " + DoubleToStr(g_price_2268, Digits) + " SL: " + DoubleToStr(g_price_2260, Digits);
LABEL("PENDING_BUY", "Pending Buy Lots: " + DoubleToStr(g_ord_lots_1388, 2) + gs_1752, "Arial Bold", 0, gi_2444, gi_2372);
} else ObjectDelete("PENDING_BUY");
if (gd_2292 > 0.0) {
gs_1760 = "";
gs_1760 = " lots @" + DoubleToStr(g_ord_open_price_1340, Digits) + " TP: " + DoubleToStr(g_price_2308, Digits) + " SL: " + DoubleToStr(g_price_2300, Digits);
LABEL("PENDING_SELL", "Pending Sell Lots: " + DoubleToStr(g_ord_lots_1396, 2) + gs_1760, "Arial Bold", 0, gi_2444, gi_2372);
} else ObjectDelete("PENDING_SELL");
if (Averaging == TRUE || Hedging == TRUE) {
if (EALoop > 0) LABEL("LOOP_", "Loop: " + gi_768 + " of " + EALoop, "Arial Bold", 280, gi_2456, gi_2400);
else LABEL("LOOP_", "Loop: ON", "Arial Bold", 280, gi_2456, gi_2400);
} else ObjectDelete("LOOP_");
Sleep(10);
}
}
}
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_2528 = 1;
if (ad_0 > ad_8) gi_2528 = 2;
if (gi_2528 != gi_2524) gi_2524 = gi_2528;
return (gi_2528);
}

int BuyOrders() {
g_count_736 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736 && OrderSymbol() == Symbol())
if (OrderType() == OP_BUYSTOP || OrderType() == OP_BUYLIMIT) g_count_736++;
}
}
return (g_count_736);
}

int SellOrders() {
g_count_740 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736 && OrderSymbol() == Symbol())
if (OrderType() == OP_SELLSTOP || OrderType() == OP_SELLLIMIT) g_count_740++;
}
}
return (g_count_740);
}

int SellOpen() {
g_count_732 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736 && OrderSymbol() == Symbol())
if (OrderType() == OP_SELL) g_count_732++;
}
}
return (g_count_732);
}

int BuyOpen() {
g_count_728 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736 && OrderSymbol() == Symbol())
if (OrderType() == OP_BUY) g_count_728++;
}
}
return (g_count_728);
}

double TotalBuyLots() {
double ld_ret_0 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736 && OrderSymbol() == Symbol())
if (OrderType() == OP_BUY || OrderType() == OP_BUYSTOP) ld_ret_0 += OrderLots();
}
}
return (ld_ret_0);
}

double TotalSellLots() {
double ld_ret_0 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736 && OrderSymbol() == Symbol())
if (OrderType() == OP_SELL || OrderType() == OP_SELLSTOP) ld_ret_0 += OrderLots();
}
}
return (ld_ret_0);
}

double TotalBuyPos() {
double ld_ret_0 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736 && OrderSymbol() == Symbol())
if (OrderType() == OP_BUY || OrderType() == OP_BUYSTOP) ld_ret_0 += 1.0;
}
}
return (ld_ret_0);
}

double TotalCorrBuyPos() {
double ld_ret_0 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736) {
if (OrderSymbol() == gs_eurusd_328 || OrderSymbol() == gs_usdchf_336)
if (OrderType() == OP_BUY) ld_ret_0 += 1.0;
}
}
}
return (ld_ret_0);
}

double TotalCorrSellPos() {
double ld_ret_0 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736) {
if (OrderSymbol() == gs_eurusd_328 || OrderSymbol() == gs_usdchf_336)
if (OrderType() == OP_SELL) ld_ret_0 += 1.0;
}
}
}
return (ld_ret_0);
}

double TotalSellPos() {
double ld_ret_0 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736 && OrderSymbol() == Symbol())
if (OrderType() == OP_SELL || OrderType() == OP_SELLSTOP) ld_ret_0 += 1.0;
}
}
return (ld_ret_0);
}

double BuyLots() {
gd_780 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE)
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_1736) gd_780 += OrderLots();
}
return (gd_780);
}

double SellLots() {
gd_788 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE)
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_1736) gd_788 += OrderLots();
}
return (gd_788);
}

double AllBuyLots() {
gd_780 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE)
if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) gd_780 += OrderLots();
}
return (gd_780);
}

double AllSellLots() {
gd_788 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE)
if (OrderType() == OP_SELL && OrderSymbol() == Symbol()) gd_788 += OrderLots();
}
return (gd_788);
}

double LastOpenBuyPrice() {
g_ord_open_price_892 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736)
if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) g_ord_open_price_892 = OrderOpenPrice();
}
}
return (g_ord_open_price_892);
}

double LastOpenSellPrice() {
g_ord_open_price_900 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() != g_magic_1736)
if (OrderType() == OP_SELL && OrderSymbol() == Symbol()) g_ord_open_price_900 = OrderOpenPrice();
}
}
return (g_ord_open_price_900);
}

double FirstOpenBuyPrice() {
g_ord_open_price_1588 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() == g_magic_1736) break;
if (!((OrderType() == OP_BUY && OrderSymbol() == Symbol()))) break;
g_ord_open_price_1588 = OrderOpenPrice();
break;
}
}
return (g_ord_open_price_1588);
}

double FirstOpenSellPrice() {
g_ord_open_price_1596 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() == g_magic_1736) break;
if (!((OrderType() == OP_SELL && OrderSymbol() == Symbol()))) break;
g_ord_open_price_1596 = OrderOpenPrice();
break;
}
}
return (g_ord_open_price_1596);
}

double DoublerBuyLots() {
gd_780 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() == g_magic_1736)
if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) gd_780 += OrderLots();
}
}
return (gd_780);
}

double DoublerSellLots() {
gd_788 = 0;
g_ord_total_760 = OrdersTotal();
for (g_pos_764 = 0; g_pos_764 < g_ord_total_760; g_pos_764++) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) != FALSE) {
if (OrderMagicNumber() == g_magic_1736)
if (OrderType() == OP_SELL && OrderSymbol() == Symbol()) gd_788 += OrderLots();
}
}
return (gd_788);
}

void CheckOrder() {
if (gi_344 == FALSE) {
if (gi_300 == TRUE) gi_748 = TotalCorrBuyPos() + TotalCorrSellPos();
if (gi_300 == FALSE) gi_748 = BuyOpen() + SellOpen();
if (gi_744 > gi_748) {
if (CloseOneCloseAll == TRUE) {
if (OrdersTotal() > 0) {
gi_2232 = FALSE;
CloseAll();
}
if (gs_1728 == "") gs_1728 = "CloseOneCloseAll";
if (OrdersTotal() <= 0) CheckLoop();
}
if (CloseOneCloseAll == FALSE) {
if (BuyOrders() + SellOrders() > 0) CancelPending();
if (BuyOpen() + SellOpen() <= 0) {
if (OrdersTotal() > 0) {
gi_2232 = FALSE;
CloseAll();
}
gs_1728 = "No Open Positions";
if (OrdersTotal() <= 0) CheckLoop();
}
}
gi_744 = 0;
} else gi_744 = gi_748;
}
if (gi_344 == TRUE) gi_692 = TRUE;
}

void CheckLoop() {
gi_772 = 0;
gi_1848 = 0;
gi_1852 = 0;
gi_1384 = FALSE;
if (EALoop <= 0) {
MessageDisplay();
gd_1884 = 0;
if (StartFromHiLow == TRUE) {
if (ObjectsTotal() > 0) ObjectsDeleteAll();
} else LoopObjDelete();
gi_692 = TRUE;
gi_2232 = TRUE;
}
if (EALoop > 0) {
if (gi_768 < EALoop) {
MessageDisplay();
gd_1884 = 0;
gi_768++;
if (StartFromHiLow == TRUE) {
if (ObjectsTotal() > 0) ObjectsDeleteAll();
} else LoopObjDelete();
gi_692 = TRUE;
gi_2232 = TRUE;
return;
}
Print("Loop End");
gi_684 = FALSE;
CloseAll();
}
}

void CancelPending() {
for (g_pos_764 = OrdersTotal() - 1; g_pos_764 >= 0; g_pos_764--) {
if (OrderSelect(g_pos_764, 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 CloseAll() {
gi_692 = 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_16;
int li_20;
string ls_24;
double l_price_32;
int l_cmd_40;
int l_cmd_44 = -1;
string ls_48 = Symbol();
for (g_pos_764 = OrdersTotal() - 1; g_pos_764 >= 0; g_pos_764--) {
if (OrderSelect(g_pos_764, SELECT_BY_POS) == TRUE) {
if (ai_0 == 1) {
if (OrderSymbol() != ls_48) continue;
l_cmd_40 = OrderType();
if (l_cmd_40 > OP_SELL) continue;
l_ord_lots_4 = OrderLots();
l_ticket_12 = OrderTicket();
l_cmd_44 = l_cmd_40;
while (true) {
if (l_cmd_44 == -1) {
Alert("No orders available");
break;
}
switch (l_cmd_44) {
case OP_BUY:
l_price_32 = Bid;
ls_24 = "Buy";
break;
case OP_SELL:
l_price_32 = Ask;
ls_24 = "Sell";
}
Print("Attempting to close ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
li_20 = OrderClose(l_ticket_12, l_ord_lots_4, l_price_32, 3);
if (li_20 == 1) {
Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
break;
}
l_error_16 = GetLastError();
switch (l_error_16) {
case 135/* PRICE_CHANGED */:
Print("The price has changed. Retrying..");
RefreshRates();
break;
case 136/* OFF_QUOTES */:
Print("No prices. Waiting for a new tick..");
if (RefreshRates() != FALSE) break;
while (true) {
Sleep(1);
if (RefreshRates() == FALSE) continue;
break;
}
break;
case 146/* TRADE_CONTEXT_BUSY */:
Print("Trading subsystem is busy. Retrying..");
Sleep(300);
RefreshRates();
break;
case 2/* COMMON_ERROR */:
Print("Common error");
Sleep(300);
RefreshRates();
break;
case 133/* TRADE_DISABLED */:
Print("Trading is prohibited");
Sleep(300);
RefreshRates();
break;
case 64/* ACCOUNT_DISABLED */:
Print("Account is blocked");
break;
default:
Print("Error ", l_error_16, " occured");
Sleep(10);
RefreshRates();
}
}
}
if (ai_0 == 2) {
if (OrderSymbol() == ls_48) continue;
l_cmd_40 = OrderType();
if (l_cmd_40 > OP_SELL) continue;
l_ord_lots_4 = OrderLots();
l_ticket_12 = OrderTicket();
l_cmd_44 = l_cmd_40;
while (true) {
if (l_cmd_44 == -1) {
Alert("No orders available");
break;
}
switch (l_cmd_44) {
case OP_BUY:
l_price_32 = MarketInfo(OrderSymbol(), MODE_BID);
ls_24 = "Buy";
break;
case OP_SELL:
l_price_32 = MarketInfo(OrderSymbol(), MODE_ASK);
ls_24 = "Sell";
}
Print("Attempting to close ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
li_20 = OrderClose(l_ticket_12, l_ord_lots_4, l_price_32, 3);
if (li_20 == 1) {
Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
break;
}
l_error_16 = GetLastError();
switch (l_error_16) {
case 135/* PRICE_CHANGED */:
Print("The price has changed. Retrying..");
RefreshRates();
break;
case 136/* OFF_QUOTES */:
Print("No prices. Waiting for a new tick..");
if (RefreshRates() != FALSE) break;
while (true) {
Sleep(1);
if (RefreshRates() == FALSE) continue;
break;
}
break;
case 146/* TRADE_CONTEXT_BUSY */:
Print("Trading subsystem is busy. Retrying..");
Sleep(300);
RefreshRates();
break;
case 2/* COMMON_ERROR */:
Print("Common error");
Sleep(300);
RefreshRates();
break;
case 133/* TRADE_DISABLED */:
Print("Trading is prohibited");
Sleep(300);
RefreshRates();
break;
case 64/* ACCOUNT_DISABLED */:
Print("Account is blocked");
break;
default:
Print("Error ", l_error_16, " occured");
Sleep(10);
RefreshRates();
}
}
}
if (ai_0 == 0) {
if (OrderSymbol() != ls_48) continue;
l_cmd_40 = OrderType();
if (l_cmd_40 < OP_BUYLIMIT) continue;
l_ticket_12 = OrderTicket();
l_cmd_44 = l_cmd_40;
l_ord_lots_4 = OrderLots();
while (true) {
if (l_cmd_44 == -1) {
Alert("No orders available");
break;
}
switch (l_cmd_44) {
case OP_BUYLIMIT:
ls_24 = "Buy Limit";
break;
case OP_SELLLIMIT:
ls_24 = "Sell Limit";
break;
case OP_BUYSTOP:
ls_24 = "Buy Stop";
break;
case OP_SELLSTOP:
ls_24 = "Sell Stop";
}
Print("Attempting to close pending ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
li_20 = OrderDelete(l_ticket_12);
if (li_20 == 1) {
Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
break;
}
l_error_16 = GetLastError();
switch (l_error_16) {
case 135/* PRICE_CHANGED */:
Print("The price has changed. Retrying..");
RefreshRates();
break;
case 136/* OFF_QUOTES */:
Print("No prices. Waiting for a new tick..");
if (RefreshRates() != FALSE) break;
while (true) {
Sleep(1);
if (RefreshRates() == FALSE) continue;
break;
}
break;
case 146/* TRADE_CONTEXT_BUSY */:
Print("Trading subsystem is busy. Retrying..");
Sleep(300);
RefreshRates();
break;
case 2/* COMMON_ERROR */:
Print("Common error");
Sleep(300);
RefreshRates();
break;
case 133/* TRADE_DISABLED */:
Print("Trading is prohibited");
Sleep(300);
RefreshRates();
break;
case 64/* ACCOUNT_DISABLED */:
Print("Account is blocked");
break;
default:
Print("Error ", l_error_16, " occured");
Sleep(10);
RefreshRates();
}
}
}
if (ai_0 == 3) {
if (OrderSymbol() != ls_48) {
l_cmd_40 = OrderType();
if (l_cmd_40 >= OP_BUYLIMIT) {
l_ticket_12 = OrderTicket();
l_cmd_44 = l_cmd_40;
l_ord_lots_4 = OrderLots();
while (true) {
if (l_cmd_44 == -1) {
Alert("No orders available");
break;
}
switch (l_cmd_44) {
case OP_BUYLIMIT:
ls_24 = "Buy Limit";
break;
case OP_SELLLIMIT:
ls_24 = "Sell Limit";
break;
case OP_BUYSTOP:
ls_24 = "Buy Stop";
break;
case OP_SELLSTOP:
ls_24 = "Sell Stop";
}
Print("Attempting to close pending ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
li_20 = OrderDelete(l_ticket_12);
if (li_20 == 1) {
Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
break;
}
l_error_16 = GetLastError();
switch (l_error_16) {
case 135/* PRICE_CHANGED */:
Print("The price has changed. Retrying..");
RefreshRates();
break;
case 136/* OFF_QUOTES */:
Print("No prices. Waiting for a new tick..");
if (RefreshRates() != FALSE) break;
while (true) {
Sleep(1);
if (RefreshRates() == FALSE) continue;
break;
}
break;
case 146/* TRADE_CONTEXT_BUSY */:
Print("Trading subsystem is busy. Retrying..");
Sleep(300);
RefreshRates();
break;
case 2/* COMMON_ERROR */:
Print("Common error");
Sleep(300);
RefreshRates();
break;
case 133/* TRADE_DISABLED */:
Print("Trading is prohibited");
Sleep(300);
RefreshRates();
break;
case 64/* ACCOUNT_DISABLED */:
Print("Account is blocked");
break;
default:
Print("Error ", l_error_16, " occured");
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_1892 = AccountBalance();
if (gs_1728 == "") gs_1728 = "None";
if (gd_1892 != gd_1884) {
Alert("************************************");
Alert("************************************");
Alert("Current Balance = $", gd_1892);
Alert("Last Balance = $", gd_1884);
if (gd_1892 > gd_1884) {
Alert("Your Profit is = $", gd_1892 - gd_1884);
Alert("Closed by ", gs_1728);
} else {
Alert("Your Loss is = $-", gd_1884 - gd_1892);
Alert("Closed by ", gs_1728);
}
}
if (gd_1892 == gd_1884) {
Alert("************************************");
Alert("************************************");
Alert("************************************");
Alert("Your Current Balance is $", gd_1892);
Alert("There is no profit or loss");
Alert("Closed by ", gs_1728);
}
}

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_1784 == "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_2532 = Crossed(l_ima_8, l_ima_0);
while (BuyOpen() + SellOpen() <= 0) {
if (gi_2532 == 1) {
RefreshRates();
if (OrderSend(Symbol(), OP_BUY, g_lots_1948, MarketInfo(Symbol(), MODE_ASK), 3, 0, 0, "Auto Buy", 0, 0, CLR_NONE) < 0) {
Print("Error Buy= ", ErrorDescription(GetLastError()));
return;
}
}
if (gi_2532 == 2) {
RefreshRates();
if (OrderSend(Symbol(), OP_SELL, g_lots_1948, MarketInfo(Symbol(), MODE_BID), 3, 0, 0, "Auto Sell", 0, 0, CLR_NONE) < 0) {
Print("Error Sell = ", ErrorDescription(GetLastError()));
return;
}
}
}
gs_1784 = "auto";
}
if (gi_1376 == FALSE) {
if (InitialOrder == "buy auto" || InitialOrder == "ba") {
if (g_ask_1868 != MarketInfo(Symbol(), MODE_ASK)) g_ask_1868 = MarketInfo(Symbol(), MODE_ASK);
if (OrderSend(Symbol(), OP_BUY, g_lots_1948, g_ask_1868, 3, 0, 0, "Buy", 0, 0, CLR_NONE) < 0) {
Print("Error Buy= ", ErrorDescription(GetLastError()));
return;
}
gi_1376 = TRUE;
gs_1784 = "auto";
}
if (InitialOrder == "sell auto" || InitialOrder == "sa") {
if (g_bid_1876 != MarketInfo(Symbol(), MODE_BID)) g_bid_1876 = MarketInfo(Symbol(), MODE_BID);
if (OrderSend(Symbol(), OP_SELL, g_lots_1948, g_bid_1876, 3, 0, 0, "Sell", 0, 0, CLR_NONE) < 0) {
Print("Error Sell= ", ErrorDescription(GetLastError()));
return;
}
gi_1376 = TRUE;
gs_1784 = "auto";
}
if (InitialOrder == "manual" || InitialOrder == "m") {
gi_1376 = TRUE;
gs_1784 = "auto";
gi_692 = FALSE;
gi_688 = TRUE;
}
}
}
if (BuyOpen() + SellOpen() > 0) {
gi_692 = FALSE;
gi_688 = TRUE;
}
}

void MSBuyStop() {
gd_2076 = OrderOpenPrice() - gi_388 * gd_2340 - gi_364 * gd_2340 - gd_2324;
if (g_ask_2124 != MarketInfo(Symbol(), MODE_ASK)) {
g_ask_2124 = MarketInfo(Symbol(), MODE_ASK);
return;
}
if (NormalizeDouble(MarketInfo(Symbol(), MODE_ASK), Digits) < NormalizeDouble(gd_2076, Digits)) {
if (g_price_1996 == 0.0 || NormalizeDouble(g_price_1996, Digits) > NormalizeDouble(MarketInfo(Symbol(), MODE_ASK) + gi_364 * gd_2340 + gd_2324, Digits)) {
g_price_1996 = MarketInfo(Symbol(), MODE_ASK) + gi_364 * gd_2340 + gd_2324;
Alert("Adjusting Buy Stop from ", DoubleToStr(OrderOpenPrice(), Digits), " to ", DoubleToStr(g_price_1996, Digits));
if (OrderModify(OrderTicket(), g_price_1996, 0, 0, 0, CLR_NONE) < FALSE) Print("Error Modifying MS Buy Stop = ", ErrorDescription(GetLastError()));
}
}
}

void MSSellStop() {
gd_2084 = OrderOpenPrice() + gi_388 * gd_2340 + gi_364 * gd_2340 + gd_2324;
if (g_bid_2132 != MarketInfo(Symbol(), MODE_BID)) {
g_bid_2132 = MarketInfo(Symbol(), MODE_BID);
return;
}
if (NormalizeDouble(MarketInfo(Symbol(), MODE_BID), Digits) > NormalizeDouble(gd_2084, Digits)) {
if (NormalizeDouble(g_price_2004, Digits) < NormalizeDouble(MarketInfo(Symbol(), MODE_BID) - gi_364 * gd_2340 - gd_2324, Digits)) {
g_price_2004 = MarketInfo(Symbol(), MODE_BID) - gi_364 * gd_2340 - gd_2324;
Alert("Adjusting Sell Stop from ", DoubleToStr(OrderOpenPrice(), Digits), " to ", DoubleToStr(g_price_2004, Digits));
if (OrderModify(OrderTicket(), g_price_2004, 0, 0, 0, CLR_NONE) < FALSE) Print("Error Modifying MS Sell Stop = ", ErrorDescription(GetLastError()));
}
}
}