كود PHP:
#property copyright "open trade"
#property link ""
extern int MagicNumber = 20;
int G_magic_80 = 30;
extern int TimeFrame = 60;
extern string Pair = "---Pair Management---";
extern string Suffix = "pro";
extern bool OneSpring = FALSE;
extern bool UseDynamicPairs = TRUE;
extern string Symbol1 = "GBPJPY";
extern string Symbol2 = "CHFJPY";
extern bool InitialHedge = TRUE;
extern string ManualSignal = "--- Signals Catching Management---";
extern bool AutoSignalDetect = TRUE;
extern int Buy_1_Sell_2 = 1;
extern string Filter = "--- Signals Filters ---";
extern int Strict_1_Medium_0 = 1;
bool Gi_160 = FALSE;
bool Gi_164 = FALSE;
extern string Corr = "---Correlation Setting---";
extern bool UseCorrelation = TRUE;
extern double cPeriod = 20.0;
int G_timeframe_188 = 0;
extern double MinCorr = 0.9;
extern string Reverse = "---Reverse Management---";
extern bool OppositeGridwhenR = FALSE;
extern bool CloseWhenReverse = FALSE;
extern bool UseLossPOnlywhenR = FALSE;
extern string MM = "---Money Management---";
extern bool UseMoneyManagement = TRUE;
extern double RiskPercent = 10.0;
extern bool Aggressive_Groodge = FALSE;
extern bool AutoProfit = TRUE;
extern double ProfitPercent = 0.0;
extern double LossPercent = 0.0;
extern bool UseAutoRatio = TRUE;
extern double Ratio = 1.8;
extern string MMM = "---Manual Money Management---";
extern double lots = 0.01;
extern double ProfitTargetUSD = 0.0;
extern double MaxLossUSD = 0.0;
extern string PendingOrders = "---Pending Orders---";
bool Gi_316 = TRUE;
extern int TotalPendingorders = 5;
extern double GridRatioLot = 3.0;
extern int PendingStep = 20;
extern double PipDivergence = 50.0;
extern int TrailStop = 30;
extern bool OppositeGrid = FALSE;
extern string Data = "---ScreenShot & Alert---";
extern bool AlertWhenprofit = TRUE;
extern bool AlertWhenreverse = TRUE;
extern bool AlertWhenentry = TRUE;
extern bool ScreenSWhenR = TRUE;
extern bool ScreenSWhenProfit = TRUE;
extern string STOP = "---Stop Trading---";
extern bool StopTrading = FALSE;
string Gs_unused_392 = "---Bollinger Band Settings---";
double G_period_400 = 20.0;
int G_timeframe_408 = 0;
double Gd_412 = 2.0;
int Gi_420;
double Gd_424;
bool Gi_432;
double Gd_436;
double Gd_444;
double G_period_452 = 200.0;
int G_ticket_460;
string Gsa_464[18];
double Gda_468[18][18];
double Gd_472;
string G_symbol_488;
string G_symbol_496;
string Gs_dummy_504;
string Gs_dummy_512;
string Gs_dummy_520;
bool Gi_528;
bool Gi_532;
double G_lots_536;
double G_lots_544;
int Gi_552;
double G_ibands_556;
double G_ibands_564;
double Gd_572;
bool Gi_652 = FALSE;
string Gs_unused_656 = "";
string Gs_664;
string Gs_672;
double Gd_680;
bool Gi_unused_688 = FALSE;
double G_imacd_692;
double G_imacd_700;
double G_imacd_708;
double G_imacd_716;
double Gd_788;
int Gi_796;
int Gi_800;
int Gi_804;
int Gi_808;
double G_imacd_828;
double G_imacd_836;
double G_imacd_860;
double G_imacd_868;
int Gi_876;
// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
if (!IsTesting()) {
ObjectsDeleteAll();
f0_28("Signal", "Please Wait while Loading ...", Blue, 14, 20, 20, 0);
}
G_magic_80 = 2 * MagicNumber;
if ((!IsTradeAllowed()) && (!IsExpertEnabled())) {
ObjectsDeleteAll();
f0_28("Signal", "Trade is not allowed. Enable checkbox #Allow live trading# in the expert properties.", Red, 14, 20, 20, 0);
}
ArrayInitialize(Gda_468, 0);
return (0);
}
// 52D46093050F38C27267BCE42543EF60
int deinit() {
ObjectsDeleteAll();
Comment("");
return (0);
}
// EA2B2676C28C0DB26D39331A336C6B92
int start() {
string symbol_8;
double Ld_48;
double Ld_56;
int ticket_72;
if (IsTesting()) {
OneSpring = TRUE;
TimeFrame = Period();
}
if (OneSpring) {
Symbol1 = Symbol();
Symbol2 = Symbol();
UseDynamicPairs = FALSE;
}
G_magic_80 = 2 * MagicNumber;
G_timeframe_188 = TimeFrame;
G_timeframe_408 = TimeFrame;
if (Strict_1_Medium_0 == 0) {
Gi_164 = TRUE;
Gi_160 = FALSE;
} else {
Gi_164 = FALSE;
Gi_160 = TRUE;
}
if (!InitialHedge) {
UseAutoRatio = FALSE;
Ratio = 1;
OppositeGrid = FALSE;
OppositeGridwhenR = FALSE;
}
if (OppositeGrid || OppositeGridwhenR) {
CloseWhenReverse = FALSE;
UseLossPOnlywhenR = FALSE;
}
if ((!IsDemo()) && (!IsTesting())) {
f0_28("Signal", "You can not run this EA on a Live Account !!!", Red, 24, 10, 10, 2);
return (0);
}
if (!UseCorrelation) MinCorr = -1;
if (UseCorrelation && MinCorr > 0.99 && f0_30() == 0) {
f0_28("Signal", "Invalid Correlation ...", Red, 24, 10, 10, 2);
return;
}
if ((!G_timeframe_188 == 0 || G_timeframe_188 == PERIOD_M1 || G_timeframe_188 == PERIOD_M5 || G_timeframe_188 == PERIOD_M15 || G_timeframe_188 == PERIOD_M30 || G_timeframe_188 == PERIOD_H1 ||
G_timeframe_188 == PERIOD_H4 || G_timeframe_188 == PERIOD_D1 || G_timeframe_188 == PERIOD_W1 || G_timeframe_188 == PERIOD_MN1) && f0_30() == 0) {
f0_28("Signal", "Invalid Correlation Time Frame ...", Red, 24, 10, 10, 2);
return;
}
if ((!G_timeframe_408 == 0 || G_timeframe_408 == PERIOD_M1 || G_timeframe_408 == PERIOD_M5 || G_timeframe_408 == PERIOD_M15 || G_timeframe_408 == PERIOD_M30 || G_timeframe_408 == PERIOD_H1 ||
G_timeframe_408 == PERIOD_H4 || G_timeframe_408 == PERIOD_D1 || G_timeframe_408 == PERIOD_W1 || G_timeframe_408 == PERIOD_MN1) && f0_30() == 0) {
f0_28("Signal", "Invalid Bollinger Time Frame ...", Red, 24, 10, 10, 2);
return;
}
if (StopTrading == TRUE)
if (f0_30() > 0) Gi_652 = TRUE;
if (Gi_652) {
f0_2();
G_symbol_488 = "";
G_symbol_496 = "";
Gd_472 = 0;
Gi_808 = 0;
Gi_804 = 0;
Gi_796 = 0;
Gi_800 = 0;
}
if (f0_30() == 0 && StopTrading == FALSE) {
Gi_652 = FALSE;
Gi_432 = FALSE;
}
if (MarketInfo(Symbol(), MODE_LOTSTEP) == 0.01) {
Gi_unused_688 = TRUE;
Gi_552 = 2;
} else {
Gi_unused_688 = FALSE;
Gi_552 = 1;
}
string Ls_0 = "";
if (StringLen(Symbol()) > 6) Ls_0 = Suffix;
Gsa_464[0] = "USDCHF" + Ls_0;
Gsa_464[1] = "USDJPY" + Ls_0;
Gsa_464[2] = "EURUSD" + Ls_0;
Gsa_464[3] = "GBPUSD" + Ls_0;
Gsa_464[4] = "EURJPY" + Ls_0;
Gsa_464[5] = "EURCHF" + Ls_0;
Gsa_464[6] = "EURGBP" + Ls_0;
Gsa_464[7] = "USDCAD" + Ls_0;
Gsa_464[8] = "AUDUSD" + Ls_0;
Gsa_464[9] = "GBPCHF" + Ls_0;
Gsa_464[10] = "GBPJPY" + Ls_0;
Gsa_464[11] = "CHFJPY" + Ls_0;
Gsa_464[12] = "NZDUSD" + Ls_0;
Gsa_464[13] = "EURCAD" + Ls_0;
Gsa_464[14] = "AUDJPY" + Ls_0;
Gsa_464[15] = "EURAUD" + Ls_0;
Gsa_464[16] = "AUDNZD" + Ls_0;
Gsa_464[17] = "NZDJPY" + Ls_0;
if (f0_3() > 1 && f0_30() > 0 && (!StopTrading) && (!Gi_652)) {
Gi_432 = TRUE;
if (Gi_316) f0_11();
}
if (f0_3() == 0 && f0_30() > 0) f0_2();
if (f0_30() == 0) {
if (UseDynamicPairs) {
Gi_876 = ArraySize(Gsa_464);
for (int index_16 = 0; index_16 < Gi_876; index_16++) {
for (int Li_20 = index_16 + 1; Li_20 < Gi_876 - 1; Li_20++) {
if (Gi_432 == FALSE) {
if (MarketInfo(Gsa_464[index_16], MODE_ASK) > 0.0 && MarketInfo(Gsa_464[Li_20], MODE_ASK) > 0.0) {
Gda_468[index_16][Li_20] = f0_22(Gsa_464[index_16], Gsa_464[Li_20], 0);
Sleep(10);
if (!UseCorrelation) MinCorr = -1;
if (Gda_468[index_16][Li_20] <= MinCorr) continue;
Gd_472 = Gda_468[index_16][Li_20];
G_symbol_488 = Gsa_464[index_16];
G_symbol_496 = Gsa_464[Li_20];
if (!(AutoSignalDetect)) break;
if (f0_7(G_symbol_488, G_symbol_496) == "BUY" && Gd_472 > MinCorr) {
if (f0_29(G_symbol_488) == "BUY" && InitialHedge && Gi_160) {
symbol_8 = G_symbol_496;
G_symbol_496 = G_symbol_488;
G_symbol_488 = symbol_8;
}
index_16 = Gi_876;
break;
}
if (!(f0_7(G_symbol_488, G_symbol_496) == "SELL" && Gd_472 > MinCorr)) continue;
if (f0_29(G_symbol_488) == "SELL" && InitialHedge && Gi_160) {
symbol_8 = G_symbol_496;
G_symbol_496 = G_symbol_488;
G_symbol_488 = symbol_8;
}
index_16 = Gi_876;
break;
}
if ((!StopTrading) && (!Gi_652)) {
f0_28("Signal", "Please Check Symbol Suffix!!!", Red, 24, 10, 10, 2);
return;
}
}
}
}
if (Gd_472 < MinCorr && (!StopTrading) && (!Gi_652) && f0_30() == 0) {
f0_28("Signal", "Waiting for a good Correlation...", Red, 24, 10, 10, 2);
return;
}
if (AutoSignalDetect && f0_7(G_symbol_488, G_symbol_496) == "" && (!StopTrading) && (!Gi_652) && f0_30() == 0) {
f0_28("Signal", "Waiting for a good signal...", Red, 24, 10, 10, 2);
return;
}
} else {
Ls_0 = "";
if (StringLen(Symbol()) > 6) Ls_0 = Suffix;
G_symbol_488 = Symbol1 + Ls_0;
G_symbol_496 = Symbol2 + Ls_0;
if (MarketInfo(G_symbol_488, MODE_ASK) > 0.0) Gd_472 = f0_22(G_symbol_488, G_symbol_496, 0);
else {
if ((!StopTrading) && (!Gi_652)) {
f0_28("Signal", "Please Check Symbol Suffix!!!", Red, 24, 10, 10, 2);
return;
}
}
}
}
if (AutoSignalDetect) {
if (f0_7(G_symbol_488, G_symbol_496) == "BUY" && StopTrading == FALSE && (!Gi_652)) Gi_528 = TRUE;
else Gi_528 = FALSE;
if (f0_7(G_symbol_488, G_symbol_496) == "SELL" && StopTrading == FALSE && (!Gi_652)) Gi_532 = TRUE;
else Gi_532 = FALSE;
} else {
if (Buy_1_Sell_2 == 1) {
Gi_528 = TRUE;
Gi_532 = FALSE;
}
if (Buy_1_Sell_2 == 2) {
Gi_532 = TRUE;
Gi_528 = FALSE;
}
}
int digits_24 = MarketInfo(G_symbol_488, MODE_DIGITS);
int digits_28 = MarketInfo(G_symbol_496, MODE_DIGITS);
double bid_32 = MarketInfo(G_symbol_488, MODE_BID);
double bid_40 = MarketInfo(G_symbol_496, MODE_BID);
Gi_796 = StringFind(f0_12(), "BUY", 0);
Gi_800 = StringFind(f0_12(), "SELL", 0);
Gi_804 = f0_27();
Gi_808 = f0_17();
if (!StopTrading) {
if (!OneSpring) f0_28("101", "-------------------------", f0_24(G_symbol_488), 25, 4, 44);
f0_28("201", "-------------------------", f0_24(G_symbol_496), 25, 4, 6);
if (!OneSpring) f0_28("1", G_symbol_488, f0_5(G_symbol_488), 25, 140, 60);
f0_28("2", G_symbol_496, f0_5(G_symbol_496), 25, 140, 20);
if (!OneSpring) f0_28("11", DoubleToStr(bid_32, digits_24), f0_5(G_symbol_488), 25, 20, 60);
f0_28("22", DoubleToStr(bid_40, digits_28), f0_5(G_symbol_496), 25, 20, 20);
}
if (Gi_804 > 0 && Gi_796 > 0) OppositeGrid = TRUE;
if (Gi_808 > 0 && Gi_800 > 0) OppositeGrid = TRUE;
if (Gi_796 > 0 && (!OppositeGrid)) f0_28("Signal", "Buy Catching...", Gold, 14, 10, 10, 2);
if (Gi_800 > 0 && (!OppositeGrid)) f0_28("Signal", "Sell Catching...", Gold, 14, 10, 10, 2);
if (Gi_796 > 0 && OppositeGrid) f0_28("Signal", "Buy Catching & Opposite Sell Grid", Gold, 14, 10, 10, 2);
if (Gi_800 > 0 && OppositeGrid) f0_28("Signal", "Sell Catching & Opposite Buy Grid", Gold, 14, 10, 10, 2);
if (f0_30() == 0 && (!Gi_528) && (!Gi_532) && AutoSignalDetect) {
f0_28("Signal", "Waiting for a good signal...", Silver, 14, 10, 10, 2);
if (TimeFrame > 0) Sleep(10 * TimeFrame);
else Sleep(10 * Period());
}
if (StopTrading) f0_28("Signal", "EA STOPPED!!!", Red, 24, 10, 10, 2);
if (f0_30() == 0 && Gd_472 < MinCorr && (!StopTrading)) {
f0_28("Signal", "Waiting for a good Correlation...", Silver, 14, 10, 10, 2);
if (TimeFrame > 0) Sleep(10 * TimeFrame);
else Sleep(10 * Period());
}
if (UseAutoRatio) {
Gd_444 = f0_18(G_symbol_488) / f0_18(G_symbol_496);
Ld_48 = (iMA(G_symbol_488, 0, G_period_452, 0, MODE_SMA, PRICE_HIGH, 0) - iMA(G_symbol_488, 0, G_period_452, 0, MODE_SMA, PRICE_LOW, 0)) / MarketInfo(G_symbol_488,
MODE_POINT);
Ld_56 = (iMA(G_symbol_496, 0, G_period_452, 0, MODE_SMA, PRICE_HIGH, 0) - iMA(G_symbol_496, 0, G_period_452, 0, MODE_SMA, PRICE_LOW, 0)) / MarketInfo(G_symbol_496,
MODE_POINT);
Gd_436 = Ld_56 / Ld_48;
Ratio = Gd_444 / Gd_436;
}
if (UseMoneyManagement) {
G_lots_536 = NormalizeDouble(f0_19() / (Ratio + 1.0), Gi_552);
G_lots_544 = NormalizeDouble(f0_19() / (Ratio + 1.0) * Ratio, Gi_552);
} else {
G_lots_536 = lots;
G_lots_544 = NormalizeDouble(lots * Ratio, Gi_552);
}
if (G_lots_536 / GridRatioLot < MarketInfo(Symbol(), MODE_MINLOT)) G_lots_536 = MarketInfo(Symbol(), MODE_MINLOT) * GridRatioLot;
if (G_lots_544 / GridRatioLot < MarketInfo(Symbol(), MODE_MINLOT)) G_lots_544 = NormalizeDouble(MarketInfo(Symbol(), MODE_MINLOT) * GridRatioLot * Ratio, Gi_552);
if (G_lots_536 < G_lots_544 && ((!OppositeGrid) && (!OppositeGridwhenR))) {
Gd_680 = G_lots_536;
G_lots_536 = G_lots_544;
G_lots_544 = Gd_680;
}
Gd_424 = AccountBalance();
if (UseMoneyManagement) {
if (AutoProfit && RiskPercent > 0.0) {
ProfitTargetUSD = NormalizeDouble((G_lots_536 * f0_18(G_symbol_488) + G_lots_544 * f0_18(G_symbol_496)) / 2.0 * RiskPercent + (f0_13(G_symbol_496) + f0_13(G_symbol_488)),
0);
}
if ((!AutoProfit) && ProfitPercent > 0.0) ProfitTargetUSD = Gd_424 * (ProfitPercent + 100.0) / 100.0 - Gd_424;
if (LossPercent > 0.0) MaxLossUSD = Gd_424 - Gd_424 * (100 - LossPercent) / 100.0;
}
double Ld_64 = f0_6();
if (ProfitTargetUSD > 0.0 && Ld_64 > ProfitTargetUSD) {
if (AlertWhenprofit) PlaySound("news.wav");
f0_28("Signal", "Profit Percent was reached :D !!! " + DoubleToStr(Ld_64, 0) + " USD", Lime, 18, 10, 10, 2);
if (ScreenSWhenProfit) WindowScreenShot("open Result\\ " + DoubleToStr(Ld_64, 0) + " USD" + ".gif", 1078, 720);
f0_2();
G_symbol_488 = "";
G_symbol_496 = "";
Gd_472 = 0;
Gi_652 = TRUE;
Gd_424 = AccountBalance();
Gi_432 = FALSE;
Comment("");
}
if (!UseLossPOnlywhenR) f0_26();
if (f0_7(G_symbol_488, G_symbol_496, 0) == "BUY" && Gi_800 > 0 && f0_3() > 1) {
if (AlertWhenreverse) PlaySound("alert2.wav");
if (ScreenSWhenR) WindowScreenShot("open Result\\ " + DoubleToStr(Ld_64, 0) + " USD" + ".gif", 1078, 720);
if (CloseWhenReverse) {
f0_28("Signal", "Closing While Reverse Signal...", White, 14, 10, 10, 2);
f0_2();
G_symbol_488 = "";
G_symbol_496 = "";
Gd_472 = 0;
Gi_652 = TRUE;
Gd_424 = AccountBalance();
Gi_432 = FALSE;
Comment("");
}
if (UseLossPOnlywhenR) f0_26();
if (OppositeGridwhenR) OppositeGrid = TRUE;
}
if (f0_7(G_symbol_488, G_symbol_496, 0) == "SELL" && Gi_796 > 0 && f0_3() > 1) {
if (CloseWhenReverse) {
PlaySound("alert2.wav");
f0_28("Signal", "Closing While Reverse Signal...", White, 14, 10, 10, 2);
f0_2();
G_symbol_488 = "";
G_symbol_496 = "";
Gd_472 = 0;
Gi_652 = TRUE;
Gd_424 = AccountBalance();
Gi_432 = FALSE;
Comment("");
}
if (UseLossPOnlywhenR) f0_26();
if (OppositeGridwhenR) OppositeGrid = TRUE;
}
if (!StopTrading) {
Comment("\n"
+ "\n"
+ "\n"
+ "opentrade"
+ "\n"
+ ""
+ "\n"
+ ""
+ "\n"
+ ""
+ "\n"
+ "________________________________"
+ "\n"
+ "Broker: " + AccountCompany()
+ "\n"
+ "Brokers Time: " + TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS)
+ "\n"
+ "________________________________"
+ "\n"
+ "Name: " + AccountName()
+ "\n"
+ "Account Number: " + AccountNumber()
+ "\n"
+ "Account Currency: " + AccountCurrency()
+ "\n"
+ "_______________________________" + " \n" + "Correlation: " + DoubleToStr(Gd_472, 2) + " \n" + "Ratio: " + DoubleToStr(Ratio, 1) + " \n" + "All Orders: " + DoubleToStr(f0_4(),
0) + " / " + DoubleToStr(f0_30(), 0) + " \n" + "Current Profit: " + DoubleToStr(f0_6(), 0) + " \n" + "Profit Target: " + DoubleToStr(ProfitTargetUSD, 0) +
" \n" + "_______________________________" + " \n" + "Account BALANCE: " + DoubleToStr(AccountBalance(), 2) + " \n" + "Account EQUITY: " + DoubleToStr(AccountEquity(),
2) + " \n");
}
if (f0_30() == 0 && Gi_528 && Gd_472 > MinCorr && Gi_432 == FALSE && (!Gi_652) && (!StopTrading)) {
if (AlertWhenentry) PlaySound("alert.wav");
ticket_72 = 0;
while (ticket_72 < 1) {
if (InitialHedge) {
ticket_72 = OrderSend(G_symbol_488, OP_SELL, G_lots_536, NormalizeDouble(MarketInfo(G_symbol_488, MODE_BID), f0_31(G_symbol_488)), 3 * f0_32(G_symbol_488), 0, 0,
"Max: " + G_symbol_488 + " & " + G_symbol_496 + " BUY ", MagicNumber, 0, Red);
} else {
ticket_72 = OrderSend(G_symbol_488, OP_BUY, G_lots_536, NormalizeDouble(MarketInfo(G_symbol_488, MODE_ASK), f0_31(G_symbol_488)), 3 * f0_32(G_symbol_488), 0, 0, "Max: " +
G_symbol_488 + " & " + G_symbol_496 + " BUY ", MagicNumber, 0, Red);
}
if (ticket_72 < 0) {
Sleep(1000);
RefreshRates();
}
}
ticket_72 = 0;
while (ticket_72 < 1) {
ticket_72 = OrderSend(G_symbol_496, OP_BUY, G_lots_544, NormalizeDouble(MarketInfo(G_symbol_496, MODE_ASK), f0_31(G_symbol_496)), 3 * f0_32(G_symbol_496), 0, 0, "Max: " +
G_symbol_488 + " & " + G_symbol_496 + " BUY ", MagicNumber, 0, Red);
if (ticket_72 < 0) {
Sleep(1000);
RefreshRates();
}
}
if (Gi_316 == TRUE) {
for (Li_20 = 1; Li_20 <= TotalPendingorders; Li_20++) {
ticket_72 = OrderSend(G_symbol_488, OP_BUYSTOP, NormalizeDouble(G_lots_536 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_488, MODE_ASK) + PendingStep * Li_20 * f0_23(G_symbol_488),
f0_31(G_symbol_488)), 3 * f0_32(G_symbol_488), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Blue);
ticket_72 = OrderSend(G_symbol_496, OP_BUYSTOP, NormalizeDouble(G_lots_544 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_496, MODE_ASK) + PendingStep * Li_20 * f0_23(G_symbol_496),
f0_31(G_symbol_496)), 3 * f0_32(G_symbol_496), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Blue);
}
if (OppositeGrid) {
for (Li_20 = 2; Li_20 <= TotalPendingorders; Li_20++) {
ticket_72 = OrderSend(G_symbol_488, OP_SELLSTOP, NormalizeDouble(G_lots_536 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_488, MODE_BID) - PendingStep * Li_20 * f0_23(G_symbol_488),
f0_31(G_symbol_488)), 3 * f0_32(G_symbol_488), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Red);
ticket_72 = OrderSend(G_symbol_496, OP_SELLSTOP, NormalizeDouble(G_lots_544 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_496, MODE_BID) - PendingStep * Li_20 * f0_23(G_symbol_496),
f0_31(G_symbol_496)), 3 * f0_32(G_symbol_496), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Red);
}
} else {
if (!InitialHedge) {
for (Li_20 = 1; Li_20 <= TotalPendingorders; Li_20++) {
ticket_72 = OrderSend(G_symbol_488, OP_BUYLIMIT, NormalizeDouble(G_lots_536 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_488, MODE_ASK) - PendingStep * Li_20 * f0_23(G_symbol_488),
f0_31(G_symbol_488)), 3 * f0_32(G_symbol_488), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Red);
ticket_72 = OrderSend(G_symbol_496, OP_BUYLIMIT, NormalizeDouble(G_lots_544 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_496, MODE_ASK) - PendingStep * Li_20 * f0_23(G_symbol_496),
f0_31(G_symbol_496)), 3 * f0_32(G_symbol_496), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Red);
}
}
}
}
if (ticket_72 < 0) {
Print("OrderSend failed with error #", GetLastError());
return (0);
}
Sleep(10);
Gi_432 = TRUE;
}
if (f0_30() == 0 && Gi_532 && Gd_472 > MinCorr && Gi_432 == FALSE && (!Gi_652) && (!StopTrading)) {
if (AlertWhenentry) PlaySound("alert.wav");
ticket_72 = 0;
while (ticket_72 < 1) {
if (InitialHedge) {
ticket_72 = OrderSend(G_symbol_488, OP_BUY, G_lots_536, NormalizeDouble(MarketInfo(G_symbol_488, MODE_ASK), f0_31(G_symbol_488)), 3 * f0_32(G_symbol_488), 0, 0, "Max: " +
G_symbol_488 + " & " + G_symbol_496 + " SELL ", MagicNumber, 0, Red);
} else {
ticket_72 = OrderSend(G_symbol_488, OP_SELL, G_lots_536, NormalizeDouble(MarketInfo(G_symbol_488, MODE_BID), f0_31(G_symbol_488)), 3 * f0_32(G_symbol_488), 0, 0,
"Max: " + G_symbol_488 + " & " + G_symbol_496 + " SELL ", MagicNumber, 0, Red);
}
if (ticket_72 < 0) {
Sleep(1000);
RefreshRates();
}
}
ticket_72 = 0;
while (ticket_72 < 1) {
ticket_72 = OrderSend(G_symbol_496, OP_SELL, G_lots_544, NormalizeDouble(MarketInfo(G_symbol_496, MODE_BID), f0_31(G_symbol_496)), 3 * f0_32(G_symbol_496), 0, 0,
"Max: " + G_symbol_488 + " & " + G_symbol_496 + " SELL ", MagicNumber, 0, Red);
if (ticket_72 < 0) {
Sleep(1000);
RefreshRates();
}
}
if (Gi_316 == TRUE) {
for (Li_20 = 1; Li_20 <= TotalPendingorders; Li_20++) {
ticket_72 = OrderSend(G_symbol_488, OP_SELLSTOP, NormalizeDouble(G_lots_536 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_488, MODE_BID) - PendingStep * Li_20 * f0_23(G_symbol_488),
f0_31(G_symbol_488)), 3 * f0_32(G_symbol_488), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Red);
ticket_72 = OrderSend(G_symbol_496, OP_SELLSTOP, NormalizeDouble(G_lots_544 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_496, MODE_BID) - PendingStep * Li_20 * f0_23(G_symbol_496),
f0_31(G_symbol_496)), 3 * f0_32(G_symbol_496), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Red);
}
if (OppositeGrid) {
for (Li_20 = 2; Li_20 <= TotalPendingorders; Li_20++) {
ticket_72 = OrderSend(G_symbol_488, OP_BUYSTOP, NormalizeDouble(G_lots_536 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_488, MODE_ASK) + PendingStep * Li_20 * f0_23(G_symbol_488),
f0_31(G_symbol_488)), 3 * f0_32(G_symbol_488), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Blue);
ticket_72 = OrderSend(G_symbol_496, OP_BUYSTOP, NormalizeDouble(G_lots_544 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_496, MODE_ASK) + PendingStep * Li_20 * f0_23(G_symbol_496),
f0_31(G_symbol_496)), 3 * f0_32(G_symbol_496), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Blue);
}
} else {
if (!InitialHedge) {
for (Li_20 = 1; Li_20 <= TotalPendingorders; Li_20++) {
ticket_72 = OrderSend(G_symbol_488, OP_SELLLIMIT, NormalizeDouble(G_lots_536 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_488, MODE_BID) + PendingStep * Li_20 * f0_23(G_symbol_488),
f0_31(G_symbol_488)), 3 * f0_32(G_symbol_488), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Blue);
ticket_72 = OrderSend(G_symbol_496, OP_SELLLIMIT, NormalizeDouble(G_lots_544 / GridRatioLot, Gi_552), NormalizeDouble(MarketInfo(G_symbol_496, MODE_BID) + PendingStep * Li_20 * f0_23(G_symbol_496),
f0_31(G_symbol_496)), 3 * f0_32(G_symbol_496), 0, 0, "Max: " + G_symbol_488 + " & " + G_symbol_496 + " Grid", G_magic_80, 0, Blue);
}
}
}
}
if (ticket_72 < 0) {
Print("OrderSend failed with error #", GetLastError());
return (0);
}
Sleep(10);
Gi_432 = TRUE;
}
RefreshRates();
WindowRedraw();
return (0);
}
// B8A3F8FB97BA04CFC2A30BFD5FB15645
double f0_22(string A_symbol_0, string A_symbol_8, int Ai_16 = 0) {
double Lda_20[];
double Lda_24[];
double Lda_28[];
double Lda_32[];
double Lda_36[];
double Ld_44;
double Ld_52;
double Ld_60;
ArrayResize(Lda_20, 2.0 * cPeriod);
ArrayResize(Lda_24, 2.0 * cPeriod);
ArrayResize(Lda_28, 2.0 * cPeriod);
ArrayResize(Lda_32, 2.0 * cPeriod);
ArrayResize(Lda_36, 2.0 * cPeriod);
for (int Li_40 = cPeriod + 1.0; Li_40 >= 0; Li_40--) {
Lda_24[Li_40] = iClose(A_symbol_0, G_timeframe_188, Li_40) - iMA(A_symbol_0, G_timeframe_188, cPeriod, 0, MODE_SMA, PRICE_CLOSE, Li_40);
Lda_28[Li_40] = iClose(A_symbol_8, G_timeframe_188, Li_40) - iMA(A_symbol_8, G_timeframe_188, cPeriod, 0, MODE_SMA, PRICE_CLOSE, Li_40);
Lda_32[Li_40] = MathPow(Lda_24[Li_40], 2);
Lda_36[Li_40] = MathPow(Lda_28[Li_40], 2);
Ld_44 = 0;
Ld_52 = 0;
Ld_60 = 0;
for (int Li_68 = cPeriod - 1.0; Li_68 >= 0; Li_68--) {
Ld_44 += (Lda_24[Li_40 + Li_68]) * (Lda_28[Li_40 + Li_68]);
Ld_52 += Lda_32[Li_40 + Li_68];
Ld_60 += Lda_36[Li_40 + Li_68];
}
if (Ld_52 * Ld_60 > 0.0) Lda_20[Li_40] = Ld_44 / MathSqrt(Ld_52 * Ld_60);
}
return (Lda_20[Ai_16]);
}
// 13A2725CD087895B12CCDC6D026BFC6C
int f0_2() {
int cmd_8;
bool Li_12;
G_symbol_488 = "";
G_symbol_496 = "";
Gd_472 = 0;
Gi_796 = 0;
Gi_800 = 0;
Gi_804 = 0;
Gi_808 = 0;
int order_total_0 = OrdersTotal();
for (int pos_4 = order_total_0 - 1; pos_4 >= 0; pos_4--) {
OrderSelect(pos_4, SELECT_BY_POS);
cmd_8 = OrderType();
Li_12 = FALSE;
if (OrderMagicNumber() == MagicNumber || OrderMagicNumber() == G_magic_80) {
switch (cmd_8) {
case OP_BUY:
while (Li_12 == 0) {
RefreshRates();
Li_12 = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(MarketInfo(OrderSymbol(), MODE_BID), f0_31(OrderSymbol())), 3 * f0_32(OrderSymbol()), Blue);
}
break;
case OP_SELL:
while (Li_12 == 0) {
RefreshRates();
Li_12 = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(MarketInfo(OrderSymbol(), MODE_ASK), f0_31(OrderSymbol())), 3 * f0_32(OrderSymbol()), Red);
}
break;
case OP_BUYSTOP:
while (Li_12 == 0) {
RefreshRates();
Li_12 = OrderDelete(OrderTicket());
}
break;
case OP_SELLSTOP:
while (Li_12 == 0) {
RefreshRates();
Li_12 = OrderDelete(OrderTicket());
}
break;
case OP_BUYLIMIT:
while (Li_12 == 0) {
RefreshRates();
Li_12 = OrderDelete(OrderTicket());
}
break;
case OP_SELLLIMIT:
while (Li_12 == 0) {
RefreshRates();
Li_12 = OrderDelete(OrderTicket());
}
}
if (Li_12 == FALSE) {
Print("Order ", OrderTicket(), " failed to close. Error:", GetLastError());
Sleep(3000);
}
}
}
return (0);
}
// 97D674F5CF29B678D98C1105023EC943
double f0_19() {
double Ld_ret_0 = AccountFreeMargin() * RiskPercent / 100.0 * AccountLeverage() / MarketInfo(Symbol(), MODE_LOTSIZE);
if (OppositeGrid) Ld_ret_0 /= 2.0;
if (!Aggressive_Groodge) Ld_ret_0 = Ld_ret_0 * GridRatioLot / (2.0 * GridRatioLot + TotalPendingorders * 2);
if (Ld_ret_0 < MarketInfo(Symbol(), MODE_MINLOT)) Ld_ret_0 = MarketInfo(Symbol(), MODE_MINLOT);
if (Ld_ret_0 > MarketInfo(Symbol(), MODE_MAXLOT)) Ld_ret_0 = MarketInfo(Symbol(), MODE_MAXLOT);
return (Ld_ret_0);
}
// EBEF1CD3FBE8E1B1C7362068F6C1343C
int f0_30() {
int count_0 = 0;
for (int pos_4 = 0; pos_4 < OrdersTotal(); pos_4++) {
if (OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES))
if (OrderMagicNumber() == MagicNumber || OrderMagicNumber() == G_magic_80) count_0++;
}
return (count_0);
}
// 25BC4C8626ED290D5CBF66C41953518C
int f0_4() {
int count_0 = 0;
for (int pos_4 = 0; pos_4 < OrdersTotal(); pos_4++) {
if (OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES))
if (OrderMagicNumber() == MagicNumber || OrderMagicNumber() == G_magic_80 && OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
}
return (count_0);
}
// A139256E7FC9822D765E89F0EA6539FE
double f0_20(string A_symbol_0) {
int cmd_8;
double order_open_price_12 = 1000003600;
int order_total_20 = OrdersTotal();
double order_open_price_24 = 0.0;
for (int pos_32 = order_total_20 - 1; pos_32 >= 0; pos_32--) {
OrderSelect(pos_32, SELECT_BY_POS);
if (OrderSymbol() == A_symbol_0 && OrderMagicNumber() == G_magic_80) {
cmd_8 = OrderType();
if (cmd_8 == OP_BUYSTOP || cmd_8 == OP_BUYLIMIT || cmd_8 == OP_BUY) {
order_open_price_24 = OrderOpenPrice();
if (order_open_price_24 < order_open_price_12) order_open_price_12 = order_open_price_24;
}
}
}
return (order_open_price_12);
}
// CD832D9C9194B5E935C06477BD51C896
double f0_25(string A_symbol_0) {
int cmd_8;
double order_open_price_12 = 0.0;
int order_total_20 = OrdersTotal();
double order_open_price_24 = 0.0;
for (int pos_32 = order_total_20 - 1; pos_32 >= 0; pos_32--) {
OrderSelect(pos_32, SELECT_BY_POS);
if (OrderSymbol() == A_symbol_0 && OrderMagicNumber() == G_magic_80) {
cmd_8 = OrderType();
if (cmd_8 == OP_SELLLIMIT || cmd_8 == OP_SELLSTOP || cmd_8 == OP_SELL) {
order_open_price_24 = OrderOpenPrice();
if (order_open_price_24 > order_open_price_12) order_open_price_12 = order_open_price_24;
}
}
}
return (order_open_price_12);
}
// 9582C3E4AAC2054C18B7DF86BF2DE1B2
int f0_17() {
int cmd_0;
int count_4 = 0;
int order_total_8 = OrdersTotal();
for (int pos_12 = order_total_8 - 1; pos_12 >= 0; pos_12--) {
OrderSelect(pos_12, SELECT_BY_POS);
if (OrderMagicNumber() == G_magic_80) {
cmd_0 = OrderType();
switch (cmd_0) {
case OP_BUYSTOP:
case OP_BUYLIMIT:
count_4++;
}
}
}
return (count_4);
}
// DF4A1C74EA3688083F090C63CB84048B
int f0_27() {
int cmd_0;
int count_4 = 0;
int order_total_8 = OrdersTotal();
for (int pos_12 = order_total_8 - 1; pos_12 >= 0; pos_12--) {
OrderSelect(pos_12, SELECT_BY_POS);
if (OrderMagicNumber() == G_magic_80) {
cmd_0 = OrderType();
switch (cmd_0) {
case OP_SELLLIMIT:
case OP_SELLSTOP:
count_4++;
}
}
}
return (count_4);
}
// 794A17DC939A88D4ED320F2F4C42EB3D
void f0_11() {
double minlot_40;
string symbol_0 = f0_9();
string symbol_8 = f0_14();
G_symbol_488 = symbol_0;
G_symbol_496 = symbol_8;
string Ls_16 = "Max: " + symbol_0 + " & " + symbol_8 + " GRID";
Gd_472 = f0_22(symbol_0, symbol_8, 0);
int Li_32 = StringFind(f0_12(), "BUY", 0);
int Li_36 = StringFind(f0_12(), "SELL", 0);
int Li_24 = f0_27();
int Li_28 = f0_17();
if (TrailStop > 0) {
Gi_420 = TrailStop;
f0_15(symbol_0, Gi_420);
}
if (TrailStop > 0) {
Gi_420 = TrailStop;
f0_15(symbol_8, Gi_420);
}
if (PipDivergence > 0.0) {
if (Li_24 > 0 || Li_36 > 0 || OppositeGrid) {
if (Li_32 > 0 && OppositeGrid) Gd_788 = 2.0 * PipDivergence;
else Gd_788 = PipDivergence;
if (MarketInfo(symbol_0, MODE_BID) - f0_25(symbol_0) > Gd_788 * f0_23(symbol_0)) {
minlot_40 = NormalizeDouble(f0_1(symbol_0) / GridRatioLot, Gi_552);
if (minlot_40 < MarketInfo(Symbol(), MODE_MINLOT)) minlot_40 = MarketInfo(Symbol(), MODE_MINLOT);
f0_8(symbol_0, OP_SELLSTOP);
f0_10(symbol_0, Ls_16, minlot_40);
}
if (MarketInfo(symbol_8, MODE_BID) - f0_25(symbol_8) > Gd_788 * f0_23(symbol_8)) {
minlot_40 = NormalizeDouble(f0_1(symbol_8) / GridRatioLot, Gi_552);
if (minlot_40 < MarketInfo(Symbol(), MODE_MINLOT)) minlot_40 = MarketInfo(Symbol(), MODE_MINLOT);
f0_8(symbol_8, OP_SELLSTOP);
f0_10(symbol_8, Ls_16, minlot_40);
}
}
if (Li_28 > 0 || Li_32 > 0 || OppositeGrid) {
if (Li_36 > 0 && OppositeGrid) Gd_788 = 2.0 * PipDivergence;
else Gd_788 = PipDivergence;
if (f0_20(symbol_0) - MarketInfo(symbol_0, MODE_ASK) > Gd_788 * f0_23(symbol_0)) {
Gs_664 = symbol_0 + " Lowest price :" + DoubleToStr(f0_20(symbol_0), 2) + " Cuurent Price" + DoubleToStr(MarketInfo(symbol_0, MODE_ASK), 2);
minlot_40 = NormalizeDouble(f0_1(symbol_0) / GridRatioLot, Gi_552);
if (minlot_40 < MarketInfo(Symbol(), MODE_MINLOT)) minlot_40 = MarketInfo(Symbol(), MODE_MINLOT);
f0_8(symbol_0, OP_BUYSTOP);
f0_16(symbol_0, Ls_16, minlot_40);
}
if (f0_20(symbol_8) - MarketInfo(symbol_8, MODE_ASK) > Gd_788 * f0_23(symbol_8)) {
Gs_672 = "" + DoubleToStr(f0_20(symbol_8) - MarketInfo(symbol_8, MODE_ASK), 5);
minlot_40 = NormalizeDouble(f0_1(symbol_8) / GridRatioLot, Gi_552);
if (minlot_40 < MarketInfo(Symbol(), MODE_MINLOT)) minlot_40 = MarketInfo(Symbol(), MODE_MINLOT);
f0_8(symbol_8, OP_BUYSTOP);
f0_16(symbol_8, Ls_16, minlot_40);
}
}
}
}
// 6ADDBFC636E1D1A559CD345B2EFD1A12
string f0_9() {
string Ls_unused_12;
int str_len_0 = StringLen(Gsa_464[1]);
string Ls_4 = f0_12();
return (StringSubstr(Ls_4, 5, str_len_0));
}
// 8C9C183F2BFDE3C37078223FA3C2E0D0
string f0_14() {
string Ls_unused_12;
int str_len_0 = StringLen(Gsa_464[1]);
string Ls_4 = f0_12();
return (StringSubstr(Ls_4, str_len_0 + 5 + 3, str_len_0));
}
// 812247ED9EEF2CB1CBEDFBE0BF85611C
string f0_12() {
string Ls_unused_4;
int order_total_0 = OrdersTotal();
for (int pos_12 = order_total_0 - 1; pos_12 >= 0; pos_12--) {
OrderSelect(pos_12, SELECT_BY_POS);
if (OrderMagicNumber() == MagicNumber) return (OrderComment());
}
return ("");
}
// 6D65ACEDCA0419D05FFF7B187FFFF2B8
void f0_10(string A_symbol_0, string A_comment_8, double A_lots_16) {
double Ld_28;
if (Gi_316 == TRUE) {
for (int Li_24 = 1; Li_24 <= TotalPendingorders; Li_24++) {
Ld_28 = NormalizeDouble(MarketInfo(A_symbol_0, MODE_BID) - PendingStep * Li_24 * f0_23(A_symbol_0), f0_31(A_symbol_0));
if (f0_0(A_symbol_0, Ld_28, PendingStep * f0_23(A_symbol_0), 0) == 0) {
G_ticket_460 = OrderSend(A_symbol_0, OP_SELLSTOP, A_lots_16, NormalizeDouble(MarketInfo(A_symbol_0, MODE_BID) - PendingStep * Li_24 * f0_23(A_symbol_0), f0_31(A_symbol_0)),
3 * f0_32(A_symbol_0), 0, 0, A_comment_8, G_magic_80, 0, Red);
}
}
if (G_ticket_460 < 0) Print("OrderSend failed with error #", GetLastError());
}
}
// 901E5EE694119FCC7DDBC18E0B6F3FB6
void f0_16(string A_symbol_0, string A_comment_8, double A_lots_16) {
double Ld_28;
if (Gi_316 == TRUE) {
for (int Li_24 = 1; Li_24 <= TotalPendingorders; Li_24++) {
Ld_28 = NormalizeDouble(MarketInfo(A_symbol_0, MODE_ASK) + PendingStep * Li_24 * f0_23(A_symbol_0), f0_31(A_symbol_0));
if (f0_0(A_symbol_0, Ld_28, PendingStep * f0_23(A_symbol_0), 1) == 0) {
G_ticket_460 = OrderSend(A_symbol_0, OP_BUYSTOP, A_lots_16, NormalizeDouble(MarketInfo(A_symbol_0, MODE_ASK) + PendingStep * Li_24 * f0_23(A_symbol_0), f0_31(A_symbol_0)),
3 * f0_32(A_symbol_0), 0, 0, A_comment_8, G_magic_80, 0, Blue);
}
}
if (G_ticket_460 < 0) Print("OrderSend failed with error #", GetLastError());
}
}
// 6135E1CB8CC22CA693917C921B919F42
void f0_8(string A_symbol_0, int A_cmd_8) {
int cmd_12;
int order_total_16 = OrdersTotal();
bool is_deleted_20 = FALSE;
for (int pos_24 = order_total_16 - 1; pos_24 >= 0; pos_24--) {
OrderSelect(pos_24, SELECT_BY_POS);
if (OrderSymbol() == A_symbol_0 && OrderMagicNumber() == G_magic_80) {
cmd_12 = OrderType();
if (cmd_12 == A_cmd_8) is_deleted_20 = OrderDelete(OrderTicket());
}
}
ObjectsDeleteAll(EMPTY, OBJ_ARROW);
}
// 8D9D0E572AC2F9C7B86B2727CC509B56
void f0_15(string A_symbol_0, int Ai_8) {
int error_12;
bool bool_16;
if (Ai_8 * f0_32(A_symbol_0) < MarketInfo(A_symbol_0, MODE_STOPLEVEL)) Ai_8 = MarketInfo(A_symbol_0, MODE_STOPLEVEL) / f0_32(A_symbol_0);
for (int pos_20 = 0; pos_20 < OrdersTotal(); pos_20++) {
OrderSelect(pos_20, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == A_symbol_0 && OrderMagicNumber() == G_magic_80) {
if (OrderType() == OP_BUY) {
if (NormalizeDouble(MarketInfo(OrderSymbol(), MODE_ASK) - OrderOpenPrice(), f0_31(A_symbol_0)) <= NormalizeDouble(Ai_8 * f0_23(A_symbol_0), f0_31(A_symbol_0))) continue;
if (NormalizeDouble(OrderStopLoss(), f0_31(A_symbol_0)) >= NormalizeDouble(MarketInfo(OrderSymbol(), MODE_BID) - Ai_8 * f0_23(A_symbol_0), f0_31(A_symbol_0))) continue;
bool_16 = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(MarketInfo(OrderSymbol(), MODE_BID) - Ai_8 * f0_23(A_symbol_0), f0_31(A_symbol_0)), OrderTakeProfit(),
255);
if (bool_16 == TRUE) continue;
error_12 = GetLastError();
Print("LastError = ", error_12, " TRAIL =" + NormalizeDouble(Ai_8 * f0_23(A_symbol_0), f0_31(A_symbol_0)));
continue;
}
if (OrderType() == OP_SELL) {
if (NormalizeDouble(OrderOpenPrice() - MarketInfo(OrderSymbol(), MODE_BID), f0_31(A_symbol_0)) > NormalizeDouble(Ai_8 * f0_23(A_symbol_0), f0_31(A_symbol_0))) {
if (NormalizeDouble(OrderStopLoss(), f0_31(A_symbol_0)) > NormalizeDouble(MarketInfo(OrderSymbol(), MODE_ASK) + Ai_8 * f0_23(A_symbol_0), f0_31(A_symbol_0)) || OrderStopLoss() == 0.0) {
bool_16 = OrderModify(OrderTicket(), OrderOpenPrice(), MarketInfo(OrderSymbol(), MODE_ASK) + NormalizeDouble(Ai_8 * f0_23(A_symbol_0), f0_31(A_symbol_0)), OrderTakeProfit(),
255);
if (bool_16 != TRUE) {
error_12 = GetLastError();
Print("LastError = ", error_12, " TRAIL =" + NormalizeDouble(Ai_8 * f0_23(A_symbol_0), f0_31(A_symbol_0)));
}
}
}
}
}
}
}
// 970375831C5B4EAD38E5068C290B1BC3
double f0_18(string As_0) {
double Ld_ret_16;
string Ls_24 = StringSubstr(As_0, 0, 3);
string Ls_32 = StringSubstr(As_0, 3, 3);
string Ls_40 = StringSubstr(As_0, 3, StringLen(As_0) - 3);
double Ld_8 = MarketInfo(As_0, MODE_LOTSIZE) * f0_23(As_0);
if (Ls_32 == "USD") Ld_ret_16 = Ld_8;
else {
if (Ls_24 == "USD") Ld_ret_16 = Ld_8 / MarketInfo(As_0, MODE_BID);
else {
if (f0_21("USD" + Ls_40)) Ld_ret_16 = Ld_8 / MarketInfo("USD" + Ls_40, MODE_BID);
else Ld_ret_16 = Ld_8 * MarketInfo(Ls_32 + "USD", MODE_BID);
}
}
return (Ld_ret_16);
}
// AEC7C17E4573A4950EC836848E353A6D
int f0_21(string A_symbol_0) {
return (MarketInfo(A_symbol_0, MODE_LOTSIZE) > 0.0);
}
// 48DE604C3D65D811D72576955A7276F5
int f0_6() {
int cmd_16;
bool Li_20;
int order_total_0 = OrdersTotal();
int Li_4 = 0;
int Li_ret_8 = 0;
for (int pos_12 = 0; pos_12 < order_total_0; pos_12++) {
OrderSelect(pos_12, SELECT_BY_POS);
cmd_16 = OrderType();
Li_20 = FALSE;
if (OrderMagicNumber() == MagicNumber || OrderMagicNumber() == G_magic_80) Li_20 = TRUE;
if (Li_20) {
switch (cmd_16) {
case OP_BUY:
Li_4 += MathRound((MarketInfo(OrderSymbol(), MODE_BID) - OrderOpenPrice()) / MarketInfo(OrderSymbol(), MODE_POINT));
Li_ret_8 += OrderProfit();
break;
case OP_SELL:
Li_4 += MathRound((OrderOpenPrice() - MarketInfo(OrderSymbol(), MODE_ASK)) / MarketInfo(OrderSymbol(), MODE_POINT));
Li_ret_8 += OrderProfit();
}
}
}
return (Li_ret_8);
}
// 0F98F581C7F79BA7F4C181DC34070CD0
double f0_1(string A_symbol_0) {
double order_lots_12;
int order_total_8 = OrdersTotal();
for (int pos_20 = order_total_8 - 1; pos_20 >= 0; pos_20--) {
OrderSelect(pos_20, SELECT_BY_POS);
if (OrderMagicNumber() == MagicNumber && OrderSymbol() == A_symbol_0) {
order_lots_12 = OrderLots();
return (order_lots_12);
}
}
return (0.0);
}
// E2E55FE76D835B9574F0F0BBDE4389D4
void f0_28(string A_name_0, string A_text_8, color A_color_16, int A_fontsize_20 = 14, int A_x_24 = 20, int A_y_28 = 20, int A_corner_32 = 3) {
ObjectCreate(A_name_0, OBJ_LABEL, 0, 0, 0);
ObjectSetText(A_name_0, A_text_8, A_fontsize_20, "Arial", A_color_16);
ObjectSet(A_name_0, OBJPROP_CORNER, A_corner_32);
ObjectSet(A_name_0, OBJPROP_XDISTANCE, A_x_24);
ObjectSet(A_name_0, OBJPROP_YDISTANCE, A_y_28);
}
// 4564D95D208B850970E4EAAA12B6C30E
int f0_5(string A_symbol_0) {
double Ld_8 = NormalizeDouble(MarketInfo(A_symbol_0, MODE_BID), MarketInfo(A_symbol_0, MODE_DIGITS));
double ima_16 = iMA(A_symbol_0, PERIOD_M1, 1, 0, MODE_EMA, PRICE_CLOSE, 1);
string Ls_unused_24 = "";
int Li_ret_32 = 255;
int Li_ret_36 = 65280;
if (ima_16 >= Ld_8) return (Li_ret_32);
if (ima_16 <= Ld_8) return (Li_ret_36);
return (0);
}
// F18A553A3C1A5C2B7CAB1DF281ACA9C8
int f0_32(string A_symbol_0) {
int Li_ret_8;
if (MarketInfo(A_symbol_0, MODE_DIGITS) == 5.0 || MarketInfo(A_symbol_0, MODE_DIGITS) == 3.0) Li_ret_8 = 10;
else Li_ret_8 = 1;
return (Li_ret_8);
}
// BC08DBBB3701378DD91F02A65F70E48C
double f0_23(string A_symbol_0) {
double Ld_ret_8;
if (MarketInfo(A_symbol_0, MODE_DIGITS) < 4.0) {
Ld_ret_8 = 0.01;
Ld_ret_8 = NormalizeDouble(Ld_ret_8, 2);
} else {
Ld_ret_8 = 0.0001;
Ld_ret_8 = NormalizeDouble(Ld_ret_8, 4);
}
return (Ld_ret_8);
}
// EC62749AAD44122CB1A8FBFEDE172581
int f0_31(string A_symbol_0) {
int Li_ret_8;
if (MarketInfo(A_symbol_0, MODE_DIGITS) < 4.0) Li_ret_8 = 2;
else Li_ret_8 = 4;
return (Li_ret_8);
}
// 04E9FE315800B5A585791126864AC121
int f0_0(string A_symbol_0, double Ad_8, double Ad_16, int Ai_24) {
int cmd_28;
int order_total_32 = OrdersTotal();
for (int pos_36 = 0; pos_36 < order_total_32; pos_36++) {
OrderSelect(pos_36, SELECT_BY_POS);
if (OrderSymbol() == A_symbol_0 && OrderMagicNumber() == G_magic_80) {
cmd_28 = OrderType();
if (MathAbs(OrderOpenPrice() - Ad_8) < 0.9 * Ad_16)
if ((Ai_24 && cmd_28 == OP_BUY) || ((!Ai_24) && cmd_28 == OP_SELL)) return (1);
}
}
return (0);
}
// 4E2AEC2DEB74293AB63F070D048DD33F
string f0_7(string A_symbol_0, string A_symbol_8, int Ai_16 = 1) {
string Ls_ret_20 = "";
int Li_28 = StringFind(f0_12(), "BUY", 0);
int Li_32 = StringFind(f0_12(), "SELL", 0);
if (Gi_160) {
G_imacd_692 = iMACD(A_symbol_0, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);
G_imacd_700 = iMACD(A_symbol_8, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);
G_imacd_828 = iMACD(A_symbol_0, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 2);
G_imacd_836 = iMACD(A_symbol_8, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 2);
if (Ai_16 == 1) {
if ((G_imacd_828 < G_imacd_692 && G_imacd_828 <= 0.0 && G_imacd_692 > 0.0 && G_imacd_700 > 0.0) || (G_imacd_836 < G_imacd_700 && G_imacd_836 <= 0.0 && G_imacd_700 > 0.0 &&
G_imacd_692 > 0.0)) Ls_ret_20 = "BUY";
else {
if ((G_imacd_828 > G_imacd_692 && G_imacd_828 >= 0.0 && G_imacd_692 < 0.0 && G_imacd_700 < 0.0) || (G_imacd_836 > G_imacd_700 && G_imacd_836 >= 0.0 && G_imacd_700 < 0.0 &&
G_imacd_692 < 0.0)) Ls_ret_20 = "SELL";
else Ls_ret_20 = "";
}
} else {
if (Ai_16 == 0) {
if (Li_32 > 0 && G_imacd_692 > 0.0 || G_imacd_700 > 0.0) Ls_ret_20 = "BUY";
if (Li_28 > 0 && G_imacd_692 < 0.0 || G_imacd_700 < 0.0) Ls_ret_20 = "SELL";
}
}
} else {
if (Gi_164) {
G_imacd_692 = iMACD(A_symbol_0, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);
G_imacd_700 = iMACD(A_symbol_8, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);
G_imacd_708 = iMACD(A_symbol_0, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 1);
G_imacd_716 = iMACD(A_symbol_8, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 1);
G_imacd_868 = iMACD(A_symbol_0, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
G_imacd_860 = iMACD(A_symbol_8, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
if (Ai_16 == 1) {
if (G_imacd_692 > G_imacd_708 && G_imacd_700 > G_imacd_716 && G_imacd_868 > G_imacd_692 && G_imacd_860 > G_imacd_700) Ls_ret_20 = "BUY";
else {
if (G_imacd_692 < G_imacd_708 && G_imacd_700 < G_imacd_716 && G_imacd_868 < G_imacd_692 && G_imacd_860 < G_imacd_700) Ls_ret_20 = "SELL";
else Ls_ret_20 = "";
}
} else {
if (Ai_16 == 0) {
if (Li_32 > 0 && G_imacd_700 > G_imacd_716 || G_imacd_692 > G_imacd_708) Ls_ret_20 = "BUY";
if (Li_28 > 0 && G_imacd_692 < G_imacd_708 || G_imacd_700 < G_imacd_716) Ls_ret_20 = "SELL";
}
}
}
}
return (Ls_ret_20);
}
// DEEA7523B075D0BB983FEF6367E7955F
void f0_26() {
if (MaxLossUSD > 0.0 && f0_6() < (-1.0 * MaxLossUSD)) {
f0_28("Signal", "Loss Percent was reached :( ", Red, 18, 10, 10, 2);
f0_2();
G_symbol_488 = "";
G_symbol_496 = "";
Gd_472 = 0;
Gi_652 = TRUE;
Gd_424 = AccountBalance();
Gi_432 = FALSE;
Comment("");
}
}
// 82D8A41558332B3FA8947EE16078D1AE
int f0_13(string As_0) {
int cmd_8;
int count_12 = 0;
int order_total_16 = OrdersTotal();
for (int pos_20 = order_total_16 - 1; pos_20 >= 0; pos_20--) {
OrderSelect(pos_20, SELECT_BY_POS);
if (OrderMagicNumber() == G_magic_80 && Symbol() == As_0) {
cmd_8 = OrderType();
switch (cmd_8) {
case OP_SELL:
case OP_BUY:
count_12++;
}
}
}
return (count_12);
}
// C2A6FDD502450B17C61E1808DFBDD17B
int f0_24(string A_symbol_0) {
int Li_ret_8;
G_ibands_556 = iBands(A_symbol_0, G_timeframe_408, G_period_400, Gd_412, 0, PRICE_CLOSE, MODE_LOWER, 0);
G_ibands_564 = iBands(A_symbol_0, G_timeframe_408, G_period_400, Gd_412, 0, PRICE_CLOSE, MODE_UPPER, 0);
Gd_572 = (G_ibands_556 + G_ibands_564) / 2.0;
if (MarketInfo(A_symbol_0, MODE_ASK) > Gd_572) Li_ret_8 = 16711680;
else {
if (MarketInfo(A_symbol_0, MODE_ASK) < Gd_572) Li_ret_8 = 255;
else Li_ret_8 = 16777215;
}
return (Li_ret_8);
}
// 1EF2723644CFADBCFA3F876DF430B047
int f0_3() {
int cmd_8;
int count_0 = 0;
for (int pos_4 = 0; pos_4 < OrdersTotal(); pos_4++) {
if (OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES)) {
if (OrderMagicNumber() == MagicNumber) {
cmd_8 = OrderType();
if (cmd_8 == OP_BUY || cmd_8 == OP_SELL) count_0++;
}
}
}
return (count_0);
}
// E83DDEF04D6E2357A5DC455E6F3A91A5
string f0_29(string A_symbol_0) {
string Ls_ret_8 = "";
if (Gi_160) {
G_imacd_692 = iMACD(A_symbol_0, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
G_imacd_828 = iMACD(A_symbol_0, G_timeframe_408, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);
if (G_imacd_828 < G_imacd_692 && G_imacd_828 <= 0.0 && G_imacd_692 > 0.0) Ls_ret_8 = "BUY";
else {
if (G_imacd_828 > G_imacd_692 && G_imacd_828 >= 0.0 && G_imacd_692 < 0.0) Ls_ret_8 = "SELL";
else Ls_ret_8 = "";
}
}
return (Ls_ret_8);
}