#property copyright "Forex Crush" #property link "http://automaticforexcrusher.com" extern string EAName = "AutopilotProfit"; extern int SL = 0; extern int TP = 0; extern int TS = 0; extern double lots = 0.1; extern bool RiskManagement = FALSE; extern double RiskPercent = 10.0; extern int slippage = 3; extern int magic = 2703; extern int MAPeriod1 = 60; extern int MAPeriod2 = 189; extern int MAPeriod3 = 7; extern int MAPeriod4 = 15; extern int MAPeriod5 = 13; extern int MAPeriod6 = 24; extern int MAPeriod7 = 30; extern int MAPeriod8 = 47; extern string sec = "Second TSEMA"; extern int TimeFrame2 = 15; datetime g_time_168; datetime g_time_172; int g_ticket_176; int init() { g_time_168 = Time[0]; magic = GenerateMagicNumber(magic, Symbol(), Period()); EAName = GenerateComment(EAName, magic, Period()); int l_ord_total_0 = OrdersTotal(); for (int l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) { OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); if (magic == OrderMagicNumber()) { g_ticket_176 = OrderTicket(); break; } } return (0); } int deinit() { return (0); } int start() { double l_ima_4; double ld_12; double ld_20; double ld_28; double ld_36; double ld_44; double ld_52; double ld_60; double ld_68; double ld_76; double l_ima_84; double ld_92; double ld_100; double ld_108; double ld_116; double ld_124; double ld_132; double ld_140; double ld_148; double ld_156; double l_price_164; double l_price_172; bool l_bool_0 = RiskManagement; if (l_bool_0) { if (RiskPercent < 0.1 || RiskPercent > 100.0) { Comment("Invalid Risk Value."); return (0); } lots = MathFloor(100.0 * (AccountFreeMargin() * AccountLeverage() * RiskPercent * Point) / (Ask * MarketInfo(Symbol(), MODE_LOTSIZE) * MarketInfo(Symbol(), MODE_MINLOT))) * MarketInfo(Symbol(), MODE_MINLOT); } if (l_bool_0 == FALSE) { } g_time_172 = Time[0]; if (g_time_168 != g_time_172) { g_time_168 = g_time_172; l_ima_4 = iMA(NULL, 0, MAPeriod1, 0, MODE_EMA, PRICE_CLOSE, 2); ld_12 = l_ima_4 - iMA(NULL, 0, MAPeriod2, 0, MODE_EMA, PRICE_CLOSE, 2); ld_20 = l_ima_4 - iMA(NULL, 0, MAPeriod3, 0, MODE_EMA, PRICE_CLOSE, 2); ld_28 = l_ima_4 - iMA(NULL, 0, MAPeriod4, 0, MODE_EMA, PRICE_CLOSE, 2); ld_36 = l_ima_4 - iMA(NULL, 0, MAPeriod5, 0, MODE_EMA, PRICE_CLOSE, 2); ld_44 = l_ima_4 - iMA(NULL, 0, MAPeriod6, 0, MODE_EMA, PRICE_CLOSE, 2); ld_52 = l_ima_4 - iMA(NULL, 0, MAPeriod7, 0, MODE_EMA, PRICE_CLOSE, 2); ld_60 = l_ima_4 - iMA(NULL, 0, MAPeriod8, 0, MODE_EMA, PRICE_CLOSE, 2); ld_68 = (ld_12 + ld_20 + ld_28 + ld_36 + ld_44 + ld_52 + ld_60) / 7.0; l_ima_4 = iMA(NULL, 0, MAPeriod1, 0, MODE_EMA, PRICE_CLOSE, 1); ld_12 = l_ima_4 - iMA(NULL, 0, MAPeriod2, 0, MODE_EMA, PRICE_CLOSE, 1); ld_20 = l_ima_4 - iMA(NULL, 0, MAPeriod3, 0, MODE_EMA, PRICE_CLOSE, 1); ld_28 = l_ima_4 - iMA(NULL, 0, MAPeriod4, 0, MODE_EMA, PRICE_CLOSE, 1); ld_36 = l_ima_4 - iMA(NULL, 0, MAPeriod5, 0, MODE_EMA, PRICE_CLOSE, 1); ld_44 = l_ima_4 - iMA(NULL, 0, MAPeriod6, 0, MODE_EMA, PRICE_CLOSE, 1); ld_52 = l_ima_4 - iMA(NULL, 0, MAPeriod7, 0, MODE_EMA, PRICE_CLOSE, 1); ld_60 = l_ima_4 - iMA(NULL, 0, MAPeriod8, 0, MODE_EMA, PRICE_CLOSE, 1); ld_76 = (ld_12 + ld_20 + ld_28 + ld_36 + ld_44 + ld_52 + ld_60) / 7.0; l_ima_84 = iMA(NULL, TimeFrame2, MAPeriod1, 0, MODE_EMA, PRICE_CLOSE, 2); ld_92 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod2, 0, MODE_EMA, PRICE_CLOSE, 2); ld_100 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod3, 0, MODE_EMA, PRICE_CLOSE, 2); ld_108 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod4, 0, MODE_EMA, PRICE_CLOSE, 2); ld_116 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod5, 0, MODE_EMA, PRICE_CLOSE, 2); ld_124 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod6, 0, MODE_EMA, PRICE_CLOSE, 2); ld_132 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod7, 0, MODE_EMA, PRICE_CLOSE, 2); ld_140 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod8, 0, MODE_EMA, PRICE_CLOSE, 2); ld_148 = (ld_92 + ld_100 + ld_108 + ld_116 + ld_124 + ld_132 + ld_140) / 7.0; l_ima_84 = iMA(NULL, TimeFrame2, MAPeriod1, 0, MODE_EMA, PRICE_CLOSE, 1); ld_92 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod2, 0, MODE_EMA, PRICE_CLOSE, 1); ld_100 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod3, 0, MODE_EMA, PRICE_CLOSE, 1); ld_108 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod4, 0, MODE_EMA, PRICE_CLOSE, 1); ld_116 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod5, 0, MODE_EMA, PRICE_CLOSE, 1); ld_124 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod6, 0, MODE_EMA, PRICE_CLOSE, 1); ld_132 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod7, 0, MODE_EMA, PRICE_CLOSE, 1); ld_140 = l_ima_84 - iMA(NULL, TimeFrame2, MAPeriod8, 0, MODE_EMA, PRICE_CLOSE, 1); ld_156 = (ld_92 + ld_100 + ld_108 + ld_116 + ld_124 + ld_132 + ld_140) / 7.0; if (ld_68 < 0.0 && ld_76 > 0.0 && ld_148 < 0.0 && ld_156 > 0.0) { OrderClose(g_ticket_176, lots, Ask, slippage, CLR_NONE); l_price_164 = 0; if (SL != 0) l_price_164 = Ask - SL * Point; l_price_172 = 0; if (TP != 0) l_price_172 = Ask + TP * Point; g_ticket_176 = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, l_price_164, l_price_172, EAName, magic, 0, CLR_NONE); } else { if (ld_68 > 0.0 && ld_76 < 0.0 && ld_148 > 0.0 && ld_156 < 0.0) { OrderClose(g_ticket_176, lots, Bid, slippage, CLR_NONE); l_price_164 = 0; if (SL != 0) l_price_164 = Bid + SL * Point; l_price_172 = 0; if (TP != 0) l_price_172 = Bid - TP * Point; g_ticket_176 = OrderSend(Symbol(), OP_SELL, lots, Bid, slippage, l_price_164, l_price_172, EAName, magic, 0, CLR_NONE); } } } MoveTrailingStop(magic); return (0); } int GenerateMagicNumber(int ai_0, string as_4, int ai_12) { int li_16 = 0; if (as_4 == "EURUSD") li_16 = 1; else { if (as_4 == "GBPUSD") li_16 = 2; else { if (as_4 == "USDJPY") li_16 = 3; else { if (as_4 == "USDCHF") li_16 = 4; else { if (as_4 == "AUDUSD") li_16 = 5; else { if (as_4 == "USDCAD") li_16 = 6; else { if (as_4 == "EURGBP") li_16 = 7; else { if (as_4 == "EURJPY") li_16 = 8; else { if (as_4 == "EURCHF") li_16 = 9; else { if (as_4 == "EURAUD") li_16 = 10; else { if (as_4 == "EURCAD") li_16 = 11; else { if (as_4 == "GBPUSD") li_16 = 12; else { if (as_4 == "GBPJPY") li_16 = 13; else { if (as_4 == "GBPCHF") li_16 = 14; else { if (as_4 == "GBPAUD") li_16 = 15; else if (as_4 == "GBPCAD") li_16 = 16; } } } } } } } } } } } } } } return (StrToInteger(StringConcatenate(ai_0, li_16, ai_12))); } string GenerateComment(string as_0, int ai_8, int ai_12) { return (StringConcatenate(as_0, "-", ai_8, "-", ai_12)); } void MoveTrailingStop(int a_magic_0) { string ls_4 = Symbol(); int l_ord_total_16 = OrdersTotal(); for (int l_pos_12 = 0; l_pos_12 < l_ord_total_16; l_pos_12++) { OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES); if (OrderType() == OP_SELL && OrderSymbol() == ls_4 && OrderMagicNumber() == a_magic_0) if (OrderOpenPrice() - Ask > Point * TS && !(Ask + Point * TS >= OrderStopLoss()) || OrderStopLoss() == 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TS, OrderTakeProfit(), 0, Red); if (OrderType() == OP_BUY && OrderSymbol() == ls_4 && OrderMagicNumber() == a_magic_0) if (Bid - OrderOpenPrice() > Point * TS && !(Bid - Point * TS <= OrderStopLoss()) || OrderStopLoss() == 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TS, OrderTakeProfit(), 0, Green); } }