#property copyright "Copyright © 2009, Oewee" #property link "rprianda@yahoo.com" extern string Header = "Auto Cash Generator"; extern string Creator = "Oewee, Apr 2009"; extern int MagicNo = 4399; extern string Style = "=== Trading Management ==="; extern int StartTime_Hr = 0; extern int EndTime_Hr = 23; extern bool TradeOnFriday = TRUE; extern bool ProtectBalance = FALSE; extern bool ProtectProfit = FALSE; extern double Percent_Over_Balance = 10.0; extern bool UseAutoLot = FALSE; extern double MaxLots = 0.1; extern double MinLots = 0.1; extern int MaxOrder = 1; extern double StopTime = 0.0; extern double MaximumRisk = 5.0; extern double TakeProfit = 25.0; extern double StopLoss = 500.0; extern double DecreaseFactor = 3.0; extern double TrailingStop = 0.0; extern bool TrailingProfit = FALSE; extern int TrailingPips = 1; extern string Header1 = "=== Hedge setting ==="; extern bool Hedge = FALSE; extern int Hedge_Trigger = 100; extern double HedgeLotSize = 2.0; extern double HedgeProfit = 25.0; extern double HedgeStopLoss = 100.0; extern bool HighRisk = FALSE; extern int PipDistance = 50; extern double LtSize = 2.0; extern double HR_StopLoss = 500.0; extern string Wish_U = "=== Good Luck ==="; int g_period_284 = 10; double gd_288 = 10.0; double gd_296 = 3.0; string gs_unused_304 = "=== Indicators setting ==="; double g_period_312 = 5.0; double g_period_320 = 10.0; double g_period_328 = 22.0; double g_period_336 = 20.0; double g_period_344 = 26.0; double g_period_352 = 13.0; double g_period_360 = 15.0; double g_period_368 = 10.0; int g_period_376 = 100; int g_slippage_380 = 5; double g_price_384; double gd_392; double g_point_400; int init() { if (Point == 0.00001) g_point_400 = 0.0001; else { if (Point == 0.001) g_point_400 = 0.01; else g_point_400 = Point; } return (0); } int deinit() { return (0); } double LotsOptimized() { double ld_ret_0 = MaxLots; int l_hist_total_8 = OrdersHistoryTotal(); int l_count_12 = 0; ld_ret_0 = NormalizeDouble(AccountFreeMargin() * MaximumRisk / 100000.0, 1); if (ld_ret_0 < 0.1) ld_ret_0 = 0.1; if (MinLots < 0.1) { ld_ret_0 = NormalizeDouble(AccountFreeMargin() * MaximumRisk / 100000.0, 2); if (ld_ret_0 < 0.01) ld_ret_0 = 0.01; } if (DecreaseFactor > 0.0) { for (int l_pos_16 = l_hist_total_8 - 1; l_pos_16 >= 0; l_pos_16--) { if (OrderSelect(l_pos_16, SELECT_BY_POS, MODE_HISTORY) == FALSE) { Print("Error in history!"); break; } if (OrderSymbol() != Symbol() || OrderType() > OP_SELL) continue; if (OrderProfit() > 0.0) break; if (OrderProfit() < 0.0) l_count_12++; } if (l_count_12 > 1) ld_ret_0 = NormalizeDouble(ld_ret_0 - ld_ret_0 * l_count_12 / DecreaseFactor, 1); } if (ld_ret_0 < MinLots) ld_ret_0 = MinLots; if (ld_ret_0 > MaxLots) ld_ret_0 = MaxLots; if (!UseAutoLot) ld_ret_0 = MaxLots; return (ld_ret_0); } double Predict() { double l_ima_4; double l_ima_28; double l_ima_36; double l_istddev_132; double ld_ret_172; double ld_44 = 0; double ld_52 = 0; double ld_68 = 0; double ld_76 = 0; double ld_unused_84 = 0; double ld_unused_92 = 0; double ld_100 = 0; double ld_108 = 0; double ld_116 = 0; double ld_124 = 0; double ld_140 = 0; double ld_unused_60 = 0; double ld_156 = 0; double ld_164 = 0; double ld_180 = 0; double ld_20 = 0; double l_ima_12 = iMA(NULL, 0, g_period_284, 0, MODE_SMA, PRICE_CLOSE, 0); for (int li_0 = 1; li_0 <= g_period_284; li_0++) { l_ima_4 = iMA(NULL, 0, g_period_284, 0, MODE_SMA, PRICE_CLOSE, li_0); l_ima_28 = iMA(NULL, 0, g_period_284, 0, MODE_SMA, PRICE_HIGH, li_0); l_ima_36 = iMA(NULL, 0, g_period_284, 0, MODE_SMA, PRICE_LOW, li_0); l_istddev_132 = iStdDev(NULL, 0, g_period_284, 0, MODE_SMA, PRICE_CLOSE, li_0); ld_44 += (High[li_0] + Low[li_0]) / 2.0; ld_52 += Close[li_0]; ld_68 += ld_44 - ld_52; ld_76 += l_ima_4; ld_124 += l_istddev_132; ld_156 += Close[li_0] - Open[li_0] - (Close[li_0 - 1] - (Open[li_0 - 1])); ld_20 = ld_20 + (l_ima_28 - l_ima_4) + (l_ima_36 - l_ima_4); } ld_100 = ld_44 / g_period_284; ld_108 = ld_52 / g_period_284; ld_116 = ld_76 / g_period_284; ld_140 = ld_124 / g_period_284; ld_180 = ld_68 / g_period_284; ld_164 = ld_156 / g_period_284; if (ld_180 > 0.0 && l_ima_12 > ld_116 && ld_164 > 0.0 && Open[0] < l_ima_12 + ld_140 && Open[0] > l_ima_12) { ld_ret_172 = 1; gd_392 = 10000.0 * (gd_296 * ld_140) + gd_288; } if (ld_180 < 0.0 && l_ima_12 < ld_116 && ld_164 < 0.0 && Open[0] > l_ima_12 - ld_140 && Open[0] < l_ima_12) { ld_ret_172 = 2; gd_392 = 10000.0 * (gd_296 * ld_140) + gd_288; } if (ld_180 > 0.0 && l_ima_12 > ld_116 && ld_164 > 0.0 && Open[0] < l_ima_12 - ld_140) { ld_ret_172 = 3; gd_392 = 10000.0 * (2.0 * ld_140) + 10.0; } if (ld_180 < 0.0 && l_ima_12 < ld_116 && ld_164 < 0.0 && Open[0] > l_ima_12 + ld_140) { ld_ret_172 = 4; gd_392 = 10000.0 * (2.0 * ld_140) + 10.0; } return (ld_ret_172); } double Predict2() { double ld_ret_68; double ld_28 = 0; double ld_36 = 0; double ld_44 = 0; double ld_52 = 0; double ld_60 = 0; double ld_76 = 0; double ld_100 = 0; double ld_116 = 0; double ld_132 = 0; double l_istddev_84 = 0; double ld_148 = 0; double ld_156 = 0; double ld_164 = 0; l_istddev_84 = iStdDev(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, 0); double l_istddev_92 = iStdDev(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, 0); double l_ima_4 = iMA(NULL, PERIOD_M30, 10, 0, MODE_SMA, PRICE_CLOSE, 0); double l_ima_12 = iMA(NULL, PERIOD_M30, 10, 0, MODE_SMA, PRICE_CLOSE, 1); double l_ima_20 = iMA(NULL, PERIOD_M30, 10, 0, MODE_SMA, PRICE_CLOSE, 2); for (int li_0 = 1; li_0 <= 20; li_0++) { ld_28 += Close[li_0]; ld_36 += High[li_0] - Low[li_0]; ld_44 += Close[li_0] - Open[li_0]; if (li_0 <= 10) { ld_148 += Close[li_0]; ld_156 += High[li_0] - Low[li_0]; ld_164 += Close[li_0] - Open[li_0]; } } ld_52 = ld_28 / 20.0; ld_60 = ld_36 / 20.0; ld_76 = ld_44 / 20.0; double ld_172 = ld_148 / 10.0; double ld_180 = ld_156 / 10.0; double ld_188 = ld_164 / 10.0; ld_132 = (Open[0] - ld_172) / l_istddev_84; double ld_140 = (Open[0] - ld_52) / l_istddev_92; ld_100 = ld_172 + 0.308 * ld_180; double ld_108 = ld_52 + 0.18 * ld_60; ld_116 = ld_172 - 0.308 * ld_180; double ld_124 = ld_52 - 0.18 * ld_60; if ((l_ima_4 - l_ima_20 > l_ima_12 - l_ima_20 + 0.0002 && ld_188 > 0.0 && ld_164 > 0.0 && Open[0] > ld_116 && Open[0] <= ld_172 + ld_132 * ld_188 && ld_132 < 0.0 && High[1] - Low[1] < 1.777 * ld_180) || (l_ima_4 - l_ima_20 > l_ima_12 - l_ima_20 + 0.0002 && ld_76 > 0.0 && ld_44 > 0.0 && Open[0] > ld_124 && Open[0] <= ld_52 + ld_132 * ld_76 && ld_140 < 0.0 && High[1] - Low[1] < 1.586 * ld_180)) { ld_ret_68 = 1; gd_392 = 10000.0 * l_istddev_92 + 10.0; } if ((l_ima_4 - l_ima_20 < l_ima_12 - l_ima_20 - 0.0002 && ld_188 < 0.0 && ld_164 < 0.0 && Open[0] < ld_100 && Open[0] >= ld_172 + ld_132 * ld_188 && ld_132 > 0.0 && High[1] - Low[1] < 1.777 * ld_180) || (l_ima_4 - l_ima_20 < l_ima_12 - l_ima_20 - 0.0002 && ld_76 < 0.0 && ld_44 < 0.0 && Open[0] < ld_108 && Open[0] >= ld_52 + ld_132 * ld_76 && ld_140 > 0.0 && High[1] - Low[1] < 1.586 * ld_180)) { ld_ret_68 = 2; gd_392 = 10000.0 * l_istddev_92 + 10.0; } return (ld_ret_68); } int start() { int l_ticket_4; double l_price_12; double ld_148; bool li_252; bool li_256; bool li_260; bool li_264; bool li_268; bool li_272; bool li_276; bool li_280; int l_cmd_352; bool l_ord_close_356; double l_lots_364; double l_price_372; double l_price_380; bool li_392; int li_unused_396; double l_price_400; double l_ima_28 = iMA(NULL, 0, g_period_312, 0, MODE_EMA, PRICE_HIGH, 0); double l_ima_100 = iMA(NULL, 0, g_period_312, 0, MODE_EMA, PRICE_HIGH, 1); double l_ima_20 = iMA(NULL, 0, g_period_312, 0, MODE_EMA, PRICE_LOW, 0); double l_ima_92 = iMA(NULL, 0, g_period_312, 0, MODE_EMA, PRICE_LOW, 1); double l_ima_36 = iMA(NULL, 0, g_period_328, 0, MODE_SMA, PRICE_CLOSE, 0); double l_ima_108 = iMA(NULL, 0, g_period_328, 0, MODE_SMA, PRICE_CLOSE, 5); double l_ima_116 = iMA(NULL, 0, g_period_328, 0, MODE_SMA, PRICE_CLOSE, 1); double l_ima_60 = iMA(NULL, 0, g_period_320, 0, MODE_SMA, PRICE_CLOSE, 0); double l_ima_68 = iMA(NULL, 0, g_period_320, 0, MODE_SMA, PRICE_CLOSE, 1); double l_ima_76 = iMA(NULL, 0, g_period_320, 0, MODE_SMA, PRICE_CLOSE, 2); double l_ima_124 = iMA(NULL, 0, g_period_320, 0, MODE_EMA, PRICE_CLOSE, 1); double l_ima_84 = iMA(NULL, 0, g_period_320, 0, MODE_SMA, PRICE_CLOSE, 5); double l_ima_44 = iMA(NULL, 0, g_period_312, 0, MODE_EMA, PRICE_CLOSE, 0); double l_ima_52 = iMA(NULL, 0, g_period_312, 0, MODE_EMA, PRICE_CLOSE, 1); double l_ima_284 = iMA(NULL, 0, g_period_376, 0, MODE_SMA, PRICE_CLOSE, 0); double l_istddev_156 = iStdDev(NULL, 0, g_period_336, 0, MODE_EMA, PRICE_CLOSE, 0); double l_istddev_164 = iStdDev(NULL, 0, g_period_336, 0, MODE_EMA, PRICE_CLOSE, 1); double l_istddev_292 = iStdDev(NULL, 0, g_period_376, 0, MODE_SMA, PRICE_CLOSE, 0); double l_iwpr_132 = iWPR(NULL, 0, g_period_344, 0); double l_iwpr_140 = iWPR(NULL, 0, g_period_344, 1); double l_idemarker_172 = iDeMarker(NULL, 0, g_period_352, 0); double l_idemarker_180 = iDeMarker(NULL, 0, g_period_352, 1); double l_istochastic_188 = iStochastic(NULL, 0, g_period_360, 6, 7, MODE_EMA, 0, MODE_MAIN, 0); double l_istochastic_196 = iStochastic(NULL, 0, g_period_360, 6, 7, MODE_EMA, 0, MODE_MAIN, 1); double l_istochastic_204 = iStochastic(NULL, 0, g_period_360, 6, 7, MODE_EMA, 0, MODE_SIGNAL, 0); double l_istochastic_212 = iStochastic(NULL, 0, g_period_360, 6, 7, MODE_EMA, 0, MODE_SIGNAL, 1); if (l_istochastic_196 < l_istochastic_212 - 5.0 && l_istochastic_188 >= l_istochastic_204) li_252 = TRUE; if (l_istochastic_196 > l_istochastic_212 + 5.0 && l_istochastic_188 <= l_istochastic_204) li_256 = TRUE; if (l_istochastic_196 > l_istochastic_212 && l_istochastic_188 > l_istochastic_204) li_260 = TRUE; if (l_istochastic_196 < l_istochastic_212 && l_istochastic_188 < l_istochastic_204) li_264 = TRUE; double l_istochastic_220 = iStochastic(NULL, 0, g_period_368, 5, 5, MODE_SMA, 0, MODE_MAIN, 0); double l_istochastic_228 = iStochastic(NULL, 0, g_period_368, 5, 5, MODE_SMA, 0, MODE_MAIN, 1); double l_istochastic_236 = iStochastic(NULL, 0, g_period_368, 5, 5, MODE_SMA, 0, MODE_SIGNAL, 0); double l_istochastic_244 = iStochastic(NULL, 0, g_period_368, 5, 5, MODE_SMA, 0, MODE_SIGNAL, 1); if (l_istochastic_228 < l_istochastic_244 && l_istochastic_220 >= l_istochastic_236) li_268 = TRUE; if (l_istochastic_228 > l_istochastic_244 && l_istochastic_220 <= l_istochastic_236) li_272 = TRUE; if (l_istochastic_228 > l_istochastic_244 && l_istochastic_220 > l_istochastic_236) li_276 = TRUE; if (l_istochastic_228 < l_istochastic_244 && l_istochastic_220 < l_istochastic_236) li_280 = TRUE; double l_high_300 = High[iHighest(NULL, 0, MODE_HIGH, g_period_376, 0)]; double l_low_308 = Low[iLowest(NULL, 0, MODE_LOW, g_period_376, 0)]; Comment("\n", " Auto Cash Generator Copyright © 2008, Oewee - rprianda@yahoo.com", "\n", " Broker Time : ", TimeToStr(TimeCurrent()), "\n", "\n", " Minimum Lot Size : ", MarketInfo(Symbol(), MODE_MINLOT), "\n", " Maximum Lot Size : ", MarketInfo(Symbol(), MODE_MAXLOT), "\n", " Step For Changing Lot : ", MarketInfo(Symbol(), MODE_LOTSTEP), "\n", " Stop Level : ", MarketInfo(Symbol(), MODE_STOPLEVEL), "\n", " Spread : ", MarketInfo(Symbol(), MODE_SPREAD), "\n", "\n", " Highest Price in ", g_period_376, " Bars Period : ", l_high_300, "\n", " Lowest Price in ", g_period_376, " Bars Period : ", l_low_308, "\n", " Current Price -> Bid : ", Bid, " Ask : ", Ask, "\n", "\n", " Balance : ", AccountBalance(), "\n", " Equity : ", AccountEquity(), "\n", " Orders Total : ", OrdersTotal(), "\n", " Total Profit/Loss : ", AccountProfit(), "\n"); if (Bars < 100) { Print("bars less than 100"); return (0); } if (!IsConnected()) { Print("No Connection!!!"); Sleep(5000); return (0); } double ld_316 = AccountBalance(); double l_price_324 = StopLoss; int l_hour_332 = TimeHour(TimeCurrent()); if (l_price_324 <= 0.0) l_price_324 = 0; int l_count_336 = 0; int l_count_340 = 0; int l_ord_total_8 = OrdersTotal(); if ((DayOfWeek() == 5 && TradeOnFriday == FALSE) || l_hour_332 < StartTime_Hr || l_hour_332 > EndTime_Hr) return (0); if (l_ord_total_8 > 0) { for (int l_pos_344 = 0; l_pos_344 < l_ord_total_8; l_pos_344++) { OrderSelect(l_pos_344, SELECT_BY_POS); if (OrderMagicNumber() == MagicNo) { if (OrderType() <= OP_SELL && OrderSymbol() == Symbol()) l_count_336++; else l_count_340++; } } } if (l_count_336 > 0) { OrderSelect(l_count_336 - 1, SELECT_BY_POS, MODE_TRADES); if (OrderMagicNumber() == MagicNo) if (TimeCurrent() - OrderOpenTime() <= 60.0 * StopTime) return (0); } if (l_count_336 < MaxOrder) { if (AccountFreeMargin() < 100.0 * LotsOptimized()) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return (0); } if (Predict() == 3.0 && ((l_iwpr_132 > l_iwpr_140 + 9.0 && li_276) || (l_iwpr_132 > l_iwpr_140 + 9.0 && li_260) && l_idemarker_172 > l_idemarker_180 + 0.05 && l_ima_68 < l_ima_116) || (l_istochastic_188 < 40.0 && Open[1] < l_ima_92 && l_ima_36 > l_ima_84) || (l_istochastic_228 < 40.0 && l_ima_36 > l_ima_116 && l_ima_124 > l_ima_68) || (Open[2] > l_ima_68 && Open[1] < Close[1] && Open[0] > Close[1] && li_260 && l_iwpr_132 > l_iwpr_140 + 7.0 && l_idemarker_172 > l_idemarker_180 + 0.05)) { l_ticket_4 = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, g_slippage_380, 0, 0, "ACG Ultimate", MagicNo, 0, Green); if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); RefreshRates(); if (l_price_324 > 0.0) l_price_324 = Ask - StopLoss * g_point_400; g_price_384 = Ask + gd_392 * g_point_400; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_324, g_price_384, 0, CLR_NONE); } else Print("Error opening BUY order : ", GetLastError()); return (0); } if (Predict() == 1.0 && ((l_iwpr_132 > l_iwpr_140 + 9.0 && l_istochastic_220 < 60.0 && li_276) || (l_iwpr_132 > l_iwpr_140 + 18.0 && l_istochastic_188 < 70.0 && li_260) && l_iwpr_132 < -15.0 && l_idemarker_172 > l_idemarker_180 && l_ima_68 > l_ima_116 && l_ima_36 > l_ima_116) || (l_istochastic_188 < 40.0 && Open[1] > l_ima_92 && l_ima_60 < l_ima_84) || (l_istochastic_228 < 40.0 && l_ima_36 > l_ima_116 && l_ima_124 > l_ima_68) || (Open[2] > l_ima_68 && Open[1] < Close[1] && Open[0] > Close[1] && li_260 && l_iwpr_132 > l_iwpr_140 + 7.0 && l_idemarker_172 > l_idemarker_180 + 0.1)) { l_ticket_4 = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, g_slippage_380, 0, 0, "ACG Ultimate", MagicNo, 0, Green); if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); RefreshRates(); if (l_price_324 > 0.0) l_price_324 = Ask - StopLoss * g_point_400; g_price_384 = Ask + gd_392 * g_point_400; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_324, g_price_384, 0, CLR_NONE); } else Print("Error opening BUY order : ", GetLastError()); return (0); } if ((Predict2() == 1.0 && (l_istochastic_188 < 50.0 && Open[1] > l_ima_92 && l_ima_60 < l_ima_84 && li_260 && Open[0] > Close[1] && Open[1] > Close[1])) || (Predict2() == 1.0 && l_istochastic_188 < 50.0 && li_260 && l_iwpr_132 > l_iwpr_140 + 7.0 && Open[2] < Close[2] && Open[0] > Close[1] && Open[1] > Close[1]) || (Predict2() == 3.0 && Open[0] > Close[1] && Open[1] < Close[1])) { l_ticket_4 = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, g_slippage_380, 0, 0, "ACG Ultimate", MagicNo, 0, Green); if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); RefreshRates(); if (l_price_324 > 0.0) l_price_324 = Ask - StopLoss * g_point_400; g_price_384 = Ask + gd_392 * g_point_400; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_324, g_price_384, 0, CLR_NONE); } else Print("Error opening BUY order : ", GetLastError()); return (0); } if (Predict() == 4.0 && ((l_iwpr_132 < l_iwpr_140 - 9.0 && li_280) || (l_iwpr_132 < l_iwpr_140 - 9.0 && li_264) && l_idemarker_172 < l_idemarker_180 - 0.05 && l_ima_68 > l_ima_116) || (l_istochastic_188 > 60.0 && Open[1] > l_ima_100 && l_ima_36 < l_ima_84) || (l_istochastic_228 > 60.0 && l_ima_36 < l_ima_116 && l_ima_124 < l_ima_68) || (Open[2] < l_ima_68 && Open[1] > Close[1] && Open[0] < Close[1] && li_264 && l_iwpr_132 < l_iwpr_140 - 7.0 && l_idemarker_172 < l_idemarker_180 - 0.05)) { l_ticket_4 = OrderSend(Symbol(), OP_SELL, LotsOptimized(), Bid, g_slippage_380, 0, 0, "ACG Ultimate", MagicNo, 0, Red); if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); RefreshRates(); if (l_price_324 > 0.0) l_price_324 = Bid + StopLoss * g_point_400; g_price_384 = Bid - gd_392 * g_point_400; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_324, g_price_384, 0, CLR_NONE); } else Print("Error opening SELL order : ", GetLastError()); return (0); } if (Predict() == 2.0 && ((l_iwpr_132 < l_iwpr_140 - 9.0 && l_istochastic_220 > 40.0 && li_280) || (l_iwpr_132 < l_iwpr_140 - 18.0 && l_istochastic_188 > 30.0 && li_264) && l_iwpr_132 > -85.0 && l_idemarker_172 < l_idemarker_180 && l_ima_68 < l_ima_116 && l_ima_36 < l_ima_116) || (l_istochastic_188 > 60.0 && Open[1] < l_ima_100 && l_ima_60 > l_ima_84) || (l_istochastic_228 > 60.0 && l_ima_36 < l_ima_116 && l_ima_124 < l_ima_68) || (Open[2] < l_ima_68 && Open[1] > Close[1] && Open[0] < Close[1] && li_264 && l_iwpr_132 < l_iwpr_140 - 7.0 && l_idemarker_172 < l_idemarker_180 - 0.1)) { l_ticket_4 = OrderSend(Symbol(), OP_SELL, LotsOptimized(), Bid, g_slippage_380, 0, 0, "ACG Ultimate", MagicNo, 0, Red); if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); RefreshRates(); if (l_price_324 > 0.0) l_price_324 = Bid + StopLoss * g_point_400; g_price_384 = Bid - gd_392 * g_point_400; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_324, g_price_384, 0, CLR_NONE); } else Print("Error opening SELL order : ", GetLastError()); return (0); } if ((Predict2() == 2.0 && (l_istochastic_188 > 50.0 && Open[1] < l_ima_100 && l_ima_60 > l_ima_84 && li_264 && Open[0] < Close[1] && Open[1] < Close[1])) || (Predict2() == 2.0 && li_264 && l_istochastic_188 > 50.0 && l_iwpr_132 < l_iwpr_140 - 7.0 && Open[2] > Close[2] && Open[0] < Close[1] && Open[1] < Close[1]) || (Predict2() == 4.0 && Open[0] < Close[1] && Open[1] > Close[1])) { l_ticket_4 = OrderSend(Symbol(), OP_SELL, LotsOptimized(), Bid, g_slippage_380, 0, 0, "ACG Ultimate", MagicNo, 0, Red); if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); RefreshRates(); if (l_price_324 > 0.0) l_price_324 = Bid + StopLoss * g_point_400; g_price_384 = Bid - gd_392 * g_point_400; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_324, g_price_384, 0, CLR_NONE); } else Print("Error opening SELL order : ", GetLastError()); return (0); } if ((l_ima_44 > l_ima_52 && l_ima_60 > l_ima_68 && l_ima_36 > l_ima_116 && l_ima_36 > l_ima_108 + 0.0005 && l_ima_60 - l_ima_68 > l_ima_36 - l_ima_116 && l_ima_44 - l_ima_36 > l_ima_52 - l_ima_116 && li_260 && l_iwpr_132 < -15.0 && l_iwpr_132 > l_iwpr_140 + 15.0 && l_ima_44 > l_ima_60 && l_ima_60 > l_ima_36 && Open[0] > l_ima_44) || (l_ima_44 > l_ima_52 && l_ima_36 > l_ima_116 + 0.0002 && Open[0] < l_ima_36 + l_istddev_156 && (l_istochastic_220 > l_istochastic_228 && l_istochastic_236 > l_istochastic_244) || (l_istochastic_188 > l_istochastic_196 && l_istochastic_204 > l_istochastic_212) && l_iwpr_132 < -15.0 && l_iwpr_132 > l_iwpr_140 + 3.0 && li_260 && l_ima_60 > l_ima_36 && Open[0] > l_ima_44) || (li_268 && l_istochastic_228 < 25.0 && l_ima_36 > l_ima_116 + 0.0002 && l_ima_124 > l_ima_68) || (li_252 && l_istochastic_188 < 30.0 && Open[1] > l_ima_92 && Close[1] > l_ima_84 && Open[0] > l_ima_28 && l_ima_60 < l_ima_84 && l_ima_60 < l_ima_68) || (li_252 && Open[1] > l_ima_92 && Open[0] > l_ima_28 && Open[1] < Close[1] && l_iwpr_132 > l_iwpr_140 + 7.0 && l_idemarker_172 > l_idemarker_180 + 0.08 && l_istddev_156 > l_istddev_164) || (Low[1] < l_ima_36 - 3.2 * l_istddev_164 && l_iwpr_132 > l_iwpr_140 + 7.0 && l_iwpr_132 < -75.0 && li_260 && (l_istochastic_188 >= 20.0 && l_istddev_156 > l_istddev_164) || l_iwpr_140 < ld_148) || (Close[3] > l_ima_84 && Open[2] > l_ima_68 && Open[1] < Close[1] && Open[1] > Close[2] && Close[1] > l_ima_36 + 2.2 * l_istddev_164 && Open[0] > Close[1] && l_istddev_156 > l_istddev_164 && li_260 && l_iwpr_132 > l_iwpr_140 + 9.0 && l_iwpr_132 < -10.0) || (l_ima_68 < l_ima_76 - 0.0001 && l_ima_60 > l_ima_68 + 0.0002 && l_ima_60 > l_ima_76 + 0.0001 && l_ima_68 < l_ima_116 && li_260 || li_276 && Open[0] > Close[1]) || (l_ima_116 - l_ima_284 < l_ima_36 - l_ima_284 && l_ima_284 < (l_high_300 + l_low_308) / 2.0 - 2.0 * l_istddev_292 && l_ima_36 - l_ima_284 > l_istddev_292 && Open[0] > Close[1] && li_260)) { l_ticket_4 = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, g_slippage_380, 0, 0, "ACG Ultimate", MagicNo, 0, Green); if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); RefreshRates(); if (l_price_324 > 0.0) l_price_324 = Ask - StopLoss * g_point_400; g_price_384 = Ask + TakeProfit * g_point_400; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_324, g_price_384, 0, CLR_NONE); } else Print("Error opening BUY order : ", GetLastError()); return (0); } if ((l_ima_44 < l_ima_52 && l_ima_60 < l_ima_68 && l_ima_36 < l_ima_116 && l_ima_36 < l_ima_108 - 0.0005 && l_ima_68 - l_ima_60 > l_ima_116 - l_ima_36 && l_ima_36 - l_ima_44 > l_ima_116 - l_ima_52 && li_264 && l_iwpr_132 > -85.0 && l_iwpr_132 < l_iwpr_140 - 15.0 && l_ima_44 < l_ima_60 && l_ima_60 < l_ima_36 && Open[0] < l_ima_44) || (l_ima_44 < l_ima_52 && l_ima_36 < l_ima_116 - 0.0002 && Open[0] >= l_ima_36 - l_istddev_156 && (l_istochastic_220 < l_istochastic_228 && l_istochastic_236 < l_istochastic_244) || (l_istochastic_188 < l_istochastic_196 && l_istochastic_204 < l_istochastic_212) && l_iwpr_132 > -85.0 && l_iwpr_132 < l_iwpr_140 - 3.0 && li_264 && l_ima_60 < l_ima_36 && Open[0] < l_ima_44) || (li_272 && l_istochastic_228 > 75.0 && l_ima_36 < l_ima_116 - 0.0002 && l_ima_124 < l_ima_68) || (li_256 && l_istochastic_188 > 70.0 && Open[1] < l_ima_100 && Close[1] < l_ima_84 && Open[0] < l_ima_20 && l_ima_60 > l_ima_84 && l_ima_60 > l_ima_68) || (li_256 && Open[1] < l_ima_100 && Open[0] < l_ima_20 && Open[1] > Close[1] && l_iwpr_132 < l_iwpr_140 - 7.0 && l_idemarker_172 < l_idemarker_180 - 0.08 && l_istddev_156 > l_istddev_164) || (High[1] > l_ima_36 + 3.2 * l_istddev_164 && l_iwpr_132 < l_iwpr_140 - 7.0 && l_iwpr_132 > -25.0 && li_264 && (l_istochastic_188 <= 80.0 && l_istddev_156 > l_istddev_164) || l_iwpr_140 > ld_148) || (Close[3] < l_ima_84 && Open[2] < l_ima_68 && Open[1] > Close[1] && Open[1] < Close[2] && Close[1] < l_ima_36 - 2.2 * l_istddev_164 && Open[0] < Close[1] && l_istddev_156 > l_istddev_164 && li_264 && l_iwpr_132 < l_iwpr_140 - 9.0 && l_iwpr_132 > -90.0) || (l_ima_68 > l_ima_76 + 0.0001 && l_ima_60 < l_ima_68 - 0.0002 && l_ima_60 < l_ima_76 - 0.0001 && l_ima_68 > l_ima_116 && li_264 || li_280 && Open[0] < Close[1]) || (l_ima_116 - l_ima_284 > l_ima_36 - l_ima_284 && l_ima_284 > (l_high_300 + l_low_308) / 2.0 + 2.0 * l_istddev_292 && l_ima_284 - l_ima_36 > l_istddev_292 && Open[0] < Close[1] && li_264)) { l_ticket_4 = OrderSend(Symbol(), OP_SELL, LotsOptimized(), Bid, g_slippage_380, 0, 0, "ACG Ultimate", MagicNo, 0, Red); if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); RefreshRates(); if (l_price_324 > 0.0) l_price_324 = Bid + StopLoss * g_point_400; g_price_384 = Bid - TakeProfit * g_point_400; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_324, g_price_384, 0, CLR_NONE); } else Print("Error opening SELL order : ", GetLastError()); return (0); } return (0); } if (ProtectProfit && AccountEquity() > AccountBalance() * (Percent_Over_Balance / 100.0 + 1.0)) { for (int l_pos_348 = OrdersTotal() - 1; l_pos_348 >= 0; l_pos_348--) { OrderSelect(l_pos_348, SELECT_BY_POS); l_cmd_352 = OrderType(); l_ord_close_356 = FALSE; switch (l_cmd_352) { case OP_BUY: l_ord_close_356 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), g_slippage_380, Pink); break; case OP_SELL: l_ord_close_356 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), g_slippage_380, Pink); } if (l_ord_close_356 == 0) Sleep(1000); } Print("Account Profit Reached. All Open Trades Have Been Closed"); return (0); } for (int l_pos_0 = 0; l_pos_0 < l_count_336; l_pos_0++) { li_392 = FALSE; OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNo) { li_unused_396 = MarketInfo(Symbol(), MODE_STOPLEVEL); l_price_400 = OrderStopLoss(); if (OrderType() == OP_BUY) { if (AccountFreeMargin() <= 0.0 || (ProtectBalance && AccountEquity() + AccountMargin() < AccountBalance() * (1 - MaximumRisk / 50.0))) { OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_380, Violet); return (0); } if (Bid + Hedge_Trigger * g_point_400 <= OrderOpenPrice() && !li_392 && l_count_336 <= MaxOrder && l_count_340 < l_count_336 && Hedge) { l_lots_364 = OrderLots() * HedgeLotSize; l_price_324 = Bid + HedgeStopLoss * g_point_400; if (HedgeStopLoss <= 0.0) l_price_324 = 0; l_price_380 = Bid - HedgeProfit * g_point_400; l_ticket_4 = OrderSend(Symbol(), OP_SELL, l_lots_364, Bid, g_slippage_380, l_price_324, l_price_380, "Hedging", MagicNo, 0, Yellow); li_392 = TRUE; if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); } else Print("Error opening SELL order : ", GetLastError()); if (HighRisk && li_392) { l_lots_364 = OrderLots() * LtSize; l_price_372 = OrderOpenPrice() + PipDistance * g_point_400; l_price_324 = l_price_372 - HR_StopLoss * g_point_400; if (HR_StopLoss <= 0.0) l_price_324 = 0; l_price_380 = l_price_372 + (Hedge_Trigger - PipDistance + TakeProfit) * g_point_400; l_ticket_4 = OrderSend(Symbol(), OP_BUYSTOP, l_lots_364, l_price_372, g_slippage_380, l_price_324, l_price_380, "High Risk", MagicNo, 0, Green); if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY_STOP order opened : ", OrderOpenPrice()); } else Print("Error opening BUY_STOP order : ", GetLastError()); } return (0); } if (TrailingStop <= 0.0) continue; if (Bid - OrderOpenPrice() <= g_point_400 * TrailingStop) continue; if (l_price_400 >= Bid - g_point_400 * TrailingStop) continue; l_price_400 = Bid - g_point_400 * TrailingStop; l_price_12 = OrderTakeProfit(); if (TrailingProfit && li_260 && l_istochastic_188 < 70.0) l_price_12 = OrderTakeProfit() + TrailingPips * g_point_400; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_400, l_price_12, 0, Blue); return (0); } if (AccountFreeMargin() <= 0.0 || (ProtectBalance && AccountEquity() + AccountMargin() < AccountBalance() * (1 - MaximumRisk / 50.0))) { OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_380, Violet); return (0); } if (OrderOpenPrice() <= Ask - Hedge_Trigger * g_point_400 && !li_392 && l_count_336 <= MaxOrder && l_count_340 < l_count_336 && Hedge) { l_lots_364 = OrderLots() * HedgeLotSize; l_price_324 = Ask - HedgeStopLoss * g_point_400; if (HedgeStopLoss <= 0.0) l_price_324 = 0; l_price_380 = Ask + HedgeProfit * g_point_400; l_ticket_4 = OrderSend(Symbol(), OP_BUY, l_lots_364, Ask, g_slippage_380, l_price_324, l_price_380, "Hedging", MagicNo, 0, Green); li_392 = TRUE; if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); } else Print("Error opening BUY order : ", GetLastError()); if (HighRisk && li_392) { l_lots_364 = OrderLots() * LtSize; l_price_372 = OrderOpenPrice() - PipDistance * g_point_400; l_price_324 = l_price_372 + HR_StopLoss * g_point_400; if (HR_StopLoss <= 0.0) l_price_324 = 0; l_price_380 = l_price_372 - (Hedge_Trigger - PipDistance + TakeProfit) * g_point_400; l_ticket_4 = OrderSend(Symbol(), OP_SELLSTOP, l_lots_364, l_price_372, g_slippage_380, l_price_324, l_price_380, "High Risk", MagicNo, 0, Yellow); if (l_ticket_4 > 0) { if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); } else Print("Error opening SELL order : ", GetLastError()); } return (0); } if (TrailingStop > 0.0) { if (OrderOpenPrice() - Ask > g_point_400 * TrailingStop) { if (l_price_400 > Ask + g_point_400 * TrailingStop || l_price_400 == 0.0) { l_price_400 = Ask + g_point_400 * TrailingStop; l_price_12 = OrderTakeProfit(); if (TrailingProfit && li_264 && l_istochastic_188 > 30.0) l_price_12 = OrderTakeProfit() - TrailingPips * g_point_400; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_400, l_price_12, 0, Red); return (0); } } } } } return (0); }