#include bool gi_76 = TRUE; bool gi_80 = TRUE; bool gi_84 = TRUE; bool gi_88 = TRUE; int gi_unused_92 = 15; extern double LotSize = 0.02; double gd_104 = 0.01; double gd_112 = 5.0; extern int ProfitTarget = 5; double g_pips_124 = 0.0; int gi_132 = 1; int gi_136 = 15; int gi_140 = 10; double gd_144 = 1.0; int gi_152 = 91; bool gi_156 = FALSE; extern string PasueTrading = "for buy:his_man2008@yahoo.com"; int gi_168 = 0; int gi_172 = 0; string gs_unused_176 = "Quit Trading at Time"; int gi_184 = 0; bool gi_188 = TRUE; int gi_192 = 10000; int gi_196 = 3; int gi_200 = 6; double gd_204 = 10000.0; int gi_unused_212 = 1; double g_price_216 = 0.0; int g_error_224 = 0/* NO_ERROR */; int g_pos_228 = 0; int g_slippage_232 = 0; int g_magic_236 = 0; string g_str_concat_240; double g_close_248 = 0.0; int gi_256 = 0; int gi_260 = 0; bool gi_264 = FALSE; string g_str_concat_268; double gd_276; int gi_284; int gi_unused_288 = 100; double gd_292 = 10000000.0; double gd_300 = 10000000.0; int init() { if (Symbol() == "AUDCADm" || Symbol() == "AUDCAD") g_magic_236 = 801001; if (Symbol() == "AUDJPYm" || Symbol() == "AUDJPY") g_magic_236 = 801002; if (Symbol() == "AUDNZDm" || Symbol() == "AUDNZD") g_magic_236 = 801003; if (Symbol() == "AUDUSDm" || Symbol() == "AUDUSD") g_magic_236 = 801004; if (Symbol() == "CHFJPYm" || Symbol() == "CHFJPY") g_magic_236 = 801005; if (Symbol() == "EURAUDm" || Symbol() == "EURAUD") g_magic_236 = 801006; if (Symbol() == "EURCADm" || Symbol() == "EURCAD") g_magic_236 = 801007; if (Symbol() == "EURCHFm" || Symbol() == "EURCHF") g_magic_236 = 801008; if (Symbol() == "EURGBPm" || Symbol() == "EURGBP") g_magic_236 = 801009; if (Symbol() == "EURJPYm" || Symbol() == "EURJPY") g_magic_236 = 801010; if (Symbol() == "EURUSDm" || Symbol() == "EURUSD") g_magic_236 = 801011; if (Symbol() == "GBPCHFm" || Symbol() == "GBPCHF") g_magic_236 = 801012; if (Symbol() == "GBPJPYm" || Symbol() == "GBPJPY") g_magic_236 = 801013; if (Symbol() == "GBPUSDm" || Symbol() == "GBPUSD") g_magic_236 = 801014; if (Symbol() == "NZDJPYm" || Symbol() == "NZDJPY") g_magic_236 = 801015; if (Symbol() == "NZDUSDm" || Symbol() == "NZDUSD") g_magic_236 = 801016; if (Symbol() == "USDCHFm" || Symbol() == "USDCHF") g_magic_236 = 801017; if (Symbol() == "USDJPYm" || Symbol() == "USDJPY") g_magic_236 = 801018; if (Symbol() == "USDCADm" || Symbol() == "USDCAD") g_magic_236 = 801019; if (g_magic_236 == 0) g_magic_236 = 801999; gd_276 = AccountBalance(); g_str_concat_240 = StringConcatenate(Symbol(), " ", Period(), " ", "PM", " S_ID: ", TimeLocal()); g_str_concat_268 = StringConcatenate("fxfactory-v1", Symbol(), "_", Period(), "_M", ".txt"); CalculateLotPrecision(); if (!IsDemo()) { Alert("Invalid Account. Please contact EA Provider"); return (-1); } return (1); } int deinit() { if (ObjectFind("MidPoint") == 0) ObjectDelete("MidPoint"); if (ObjectFind("MarginPercent") == 0) ObjectDelete("MarginPercent"); if (ObjectFind("LowMarginPercent") == 0) ObjectDelete("LowMarginPercent"); Comment(""); return (0); } void CalculateLotPrecision() { double l_lotstep_0 = MarketInfo(Symbol(), MODE_LOTSTEP); if (l_lotstep_0 == 1.0) gi_284 = 0; if (l_lotstep_0 == 0.1) gi_284 = 1; if (l_lotstep_0 == 0.01) gi_284 = 2; if (l_lotstep_0 == 0.001) gi_284 = 3; } void PlaceBuyOrder() { double ld_0; double l_lots_8; double l_ord_open_price_24; double l_ord_open_price_16 = 1000; g_close_248 = 0; RefreshRates(); for (g_pos_228 = OrdersTotal() - 1; g_pos_228 >= 0; g_pos_228--) { if (OrderSelect(g_pos_228, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_236 && OrderType() == OP_BUY) { if (OrderOpenPrice() < l_ord_open_price_16) l_ord_open_price_16 = OrderOpenPrice(); if (OrderOpenPrice() > l_ord_open_price_24) l_ord_open_price_24 = OrderOpenPrice(); ld_0++; } } } if (Ask >= l_ord_open_price_24 + gi_140 * Point) { if (gd_112 == 1.0) l_lots_8 = NormalizeDouble(MathPow(2, ld_0) * LotSize, gi_284); else l_lots_8 = NormalizeDouble(LotSize + gd_104 * ld_0, gi_284); } if (Ask <= l_ord_open_price_16 - gi_136 * Point) { if (gd_144 == 1.0) l_lots_8 = NormalizeDouble(MathPow(2, ld_0) * LotSize, gi_284); else l_lots_8 = NormalizeDouble(LotSize + gd_104 * ld_0, gi_284); } if (ld_0 == 0.0) l_lots_8 = NormalizeDouble(LotSize, gi_284); if (l_lots_8 == 0.0) { if (gd_112 == 1.0) l_lots_8 = NormalizeDouble(LotSize, gi_284); else l_lots_8 = NormalizeDouble(LotSize, gi_284); } if (IsTradeAllowed() == TRUE && ld_0 < gi_196) { if (g_pips_124 == 0.0) g_price_216 = 0; else g_price_216 = Ask - g_pips_124 * Point; OrderSend(Symbol(), OP_BUY, l_lots_8, Ask, g_slippage_232, g_price_216, 0, g_str_concat_240, g_magic_236, 32768); } g_error_224 = GetLastError(); if (g_error_224 != 0/* NO_ERROR */) { Write("Error opening BUY order: " + ErrorDescription(g_error_224) + " (C" + g_error_224 + ") Ask:" + Ask + " Slippage:" + g_slippage_232); return; } g_close_248 = Close[0]; } void PlaceSellOrder() { double ld_0; double l_lots_8; double l_ord_open_price_16; double l_ord_open_price_24 = 1000; g_close_248 = 0; RefreshRates(); for (g_pos_228 = OrdersTotal() - 1; g_pos_228 >= 0; g_pos_228--) { if (OrderSelect(g_pos_228, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_236 && OrderType() == OP_SELL) { if (OrderOpenPrice() > l_ord_open_price_16) l_ord_open_price_16 = OrderOpenPrice(); if (OrderOpenPrice() < l_ord_open_price_24) l_ord_open_price_24 = OrderOpenPrice(); ld_0++; } } } if (Bid <= l_ord_open_price_24 - gi_140 * Point) { if (gd_112 == 1.0) l_lots_8 = NormalizeDouble(MathPow(2, ld_0) * LotSize, gi_284); else l_lots_8 = NormalizeDouble(LotSize + gd_104 * ld_0, gi_284); } if (Bid >= l_ord_open_price_16 + gi_136 * Point) { if (gd_144 == 1.0) l_lots_8 = NormalizeDouble(MathPow(2, ld_0) * LotSize, gi_284); else l_lots_8 = NormalizeDouble(LotSize + gd_104 * ld_0, gi_284); } if (ld_0 == 0.0) l_lots_8 = NormalizeDouble(LotSize, gi_284); if (l_lots_8 == 0.0) { if (gd_112 == 1.0) l_lots_8 = NormalizeDouble(LotSize, gi_284); else l_lots_8 = NormalizeDouble(LotSize, gi_284); } if (IsTradeAllowed() == TRUE && ld_0 < gi_200) { if (g_pips_124 == 0.0) g_price_216 = 0; else g_price_216 = Bid + g_pips_124 * Point; OrderSend(Symbol(), OP_SELL, l_lots_8, Bid, g_slippage_232, g_price_216, 0, g_str_concat_240, g_magic_236, 255); } g_error_224 = GetLastError(); if (g_error_224 != 0/* NO_ERROR */) { Write("Error opening SELL order: " + ErrorDescription(g_error_224) + " (D" + g_error_224 + ") Bid:" + Bid + " Slippage:" + g_slippage_232); return; } g_close_248 = Close[0]; } int start() { double ld_0; int li_24; int li_28; double ld_48; double ld_56; double l_ord_open_price_96; double l_ord_open_price_112; int l_ticket_160; int l_ticket_164; int l_ticket_168; int l_ticket_172; double ld_unused_176; double ld_unused_184; double ld_unused_192; double ld_unused_200; string l_dbl2str_232; string l_dbl2str_240; string l_dbl2str_248; if (!IsDemo()) return (-1); double l_ord_open_price_64 = 999; double l_ord_open_price_72 = 0.0001; double l_ord_open_price_80 = 999; double l_ord_open_price_88 = 0.0001; double ld_120 = 0; double ld_128 = 0; double ld_136 = 0; double ld_144 = 0; double ld_152 = 0; bool li_208 = FALSE; bool li_212 = FALSE; double l_marginrequired_216 = MarketInfo(Symbol(), MODE_MARGINREQUIRED); CutTotalLoss(); for (g_pos_228 = OrdersTotal() - 1; g_pos_228 >= 0; g_pos_228--) { if (OrderSelect(g_pos_228, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_236) { ld_120 = OrderProfit() + OrderSwap() + OrderCommission(); if (OrderType() == OP_BUY) { if (OrderOpenPrice() >= l_ord_open_price_72) { l_ord_open_price_72 = OrderOpenPrice(); l_ticket_160 = OrderTicket(); ld_unused_176 = ld_120; } if (OrderOpenPrice() <= l_ord_open_price_64) { l_ord_open_price_64 = OrderOpenPrice(); l_ticket_164 = OrderTicket(); ld_unused_184 = ld_120; } li_28++; if (li_28 > gi_256) gi_256 = li_28; ld_48 += OrderLots(); ld_128 += ld_120; if (ld_120 > 0.0) ld_144 += ld_120; } if (OrderType() == OP_SELL) { if (OrderOpenPrice() <= l_ord_open_price_80) { l_ord_open_price_80 = OrderOpenPrice(); l_ticket_172 = OrderTicket(); ld_unused_200 = ld_120; } if (OrderOpenPrice() >= l_ord_open_price_88) { l_ord_open_price_88 = OrderOpenPrice(); l_ticket_168 = OrderTicket(); ld_unused_192 = ld_120; } li_24++; if (li_24 > gi_260) gi_260 = li_24; ld_56 += OrderLots(); ld_136 += ld_120; if (ld_120 > 0.0) ld_152 += ld_120; } } } } double ld_unused_8 = ProfitTarget; double ld_unused_16 = ProfitTarget; if (l_ord_open_price_72 >= l_ord_open_price_88) l_ord_open_price_96 = l_ord_open_price_72; else l_ord_open_price_96 = l_ord_open_price_88; if (l_ord_open_price_64 <= l_ord_open_price_80) l_ord_open_price_112 = l_ord_open_price_64; else l_ord_open_price_112 = l_ord_open_price_80; double l_price_104 = (l_ord_open_price_96 + l_ord_open_price_112) / 2.0; RefreshRates(); if (ld_128 + ld_136 >= ProfitTarget) { for (g_pos_228 = OrdersTotal() - 1; g_pos_228 >= 0; g_pos_228--) { if (OrderSelect(g_pos_228, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_236) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_232, Green); g_error_224 = GetLastError(); if (g_error_224 != 0/* NO_ERROR */) Write("Error closing order " + OrderTicket() + ": " + ErrorDescription(g_error_224) + " (F" + g_error_224 + ") Lots:" + OrderLots() + " Ask:" + MarketInfo(OrderSymbol(), MODE_ASK)); } } } RefreshRates(); if (l_ord_open_price_72 > 0.0 && l_ord_open_price_64 < 1000.0) { if (Ask <= l_ord_open_price_64 - gi_136 * Point || Ask >= l_ord_open_price_72 + gi_140 * Point) { li_212 = TRUE; if (gi_132 == 1 && g_close_248 > 0.0 && Close[0] < g_close_248) li_212 = TRUE; } if (gi_156 && li_28 == 0) li_212 = FALSE; if (CCIDecision(1) != 1 || Direction(1) != 1 || PauseAtTime(gi_168, gi_172, 1) != 1) li_212 = FALSE; if (li_212 && gi_80 == TRUE) PlaceBuyOrder(); } if (l_ord_open_price_88 > 0.0 && l_ord_open_price_80 < 1000.0) { if (Bid >= l_ord_open_price_88 + gi_136 * Point || Bid <= l_ord_open_price_80 - gi_140 * Point) { li_208 = TRUE; if (gi_132 == 1 && g_close_248 > 0.0 && Close[0] > g_close_248) li_208 = TRUE; } if (gi_156 && li_24 == 0) li_208 = FALSE; if (CCIDecision(-1) != -1 || Direction(-1) != -1 || PauseAtTime(gi_168, gi_172, -1) != -1) li_208 = FALSE; if (li_208 && gi_76 == TRUE) PlaceSellOrder(); } if (AccountMargin() != 0.0) ld_0 = MathRound(100.0 * (AccountEquity() / AccountMargin())); if (gd_292 > ld_0) gd_292 = ld_0; if (AccountEquity() < gd_300) gd_300 = AccountEquity(); string ls_224 = " براي خريد اکسپرت fxfactory-v1 با ايميل his_man2008@yahoo.com يا همراه: 09188340380 تماس بگريد " + "\n" + "\n" + " نتايج بک تست و اکسپرت دمو در سايت آذرخش www.azarakhshv2.blogfa.com " + "\n" + "\n" + "\n" + " دوستان ارجمند اين ورژن جهت تست حساب دمو ميباشد و استفاده ازسيگنال هاي آن براي حساب ريل توصيه نميشود . ضرر هاي احتماليمتوجه افراد استفاده کننده خواد بود " + "\n" + "\n" + " بالانس " + DoubleToStr(AccountBalance(), 2) + "\n" + " اکوايتي " + DoubleToStr(AccountEquity(), 2) + "\n" + " کمترين ميزان اکوايتي: " + DoubleToStr(gd_300, 2) + "\n" + "\n" + " مارجين " + DoubleToStr(AccountMargin(), 2) + "\n" + " درصد مارجين " + DoubleToStr(ld_0, 2) + "\n" + " ساعت جاري " + TimeToStr(TimeCurrent(), TIME_SECONDS); Comment(ls_224); if (gi_188) { l_dbl2str_232 = DoubleToStr(ld_0, 0); l_dbl2str_240 = DoubleToStr(gd_292, 0); l_dbl2str_248 = DoubleToStr(AccountBalance(), 0); ObjectDelete("MarginPercent"); if (ObjectFind("MarginPercent") != 0) { ObjectCreate("MarginPercent", OBJ_TEXT, 0, Time[0], Close[0]); ObjectSetText("MarginPercent", l_dbl2str_232 + "% " + l_dbl2str_240 + "% $" + l_dbl2str_248, 10, "Arial Black", DodgerBlue); } else ObjectMove("MarginPercent", 0, Time[0], Close[0]); } if (ObjectFind("MidPoint") != 0) { ObjectCreate("MidPoint", OBJ_HLINE, 0, Time[0], l_price_104); ObjectSet("MidPoint", OBJPROP_COLOR, Gold); ObjectSet("MidPoint", OBJPROP_WIDTH, 2); } else ObjectMove("MidPoint", 0, Time[0], l_price_104); getSessionTarget(); QuitAtTime(gi_184); return (0); } void Write(string as_0) { int l_file_8; if (gi_264) { l_file_8 = FileOpen(g_str_concat_268, FILE_CSV|FILE_WRITE|FILE_READ, "/t"); if (l_file_8 < 1) Print("Error opening audit file: Code ", GetLastError()); else { if (!FileSeek(l_file_8, 0, SEEK_END)) Print("Error seeking end of audit file: Code ", GetLastError()); else { if (FileWrite(l_file_8, TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS) + " " + as_0) < 1) Print("Error writing to audit file: Code ", GetLastError()); else FileClose(l_file_8); } } } } int Direction(int ai_0) { int li_ret_4; if (gi_84 == TRUE) { if (iMA(Symbol(), PERIOD_M15, 2, 0, MODE_LWMA, PRICE_WEIGHTED, 0) > iOpen(Symbol(), PERIOD_M30, 0) + MarketInfo(Symbol(), MODE_SPREAD) * Point) li_ret_4 = 1; if (iMA(Symbol(), PERIOD_M15, 2, 0, MODE_LWMA, PRICE_WEIGHTED, 0) < iOpen(Symbol(), PERIOD_M30, 0) - MarketInfo(Symbol(), MODE_SPREAD) * Point) li_ret_4 = -1; } else { if (ai_0 == 1) li_ret_4 = 1; if (ai_0 == -1) li_ret_4 = -1; } return (li_ret_4); } int CCIDecision(int ai_0) { int li_ret_4; double l_icci_8; double l_icci_16; if (gi_88 == TRUE) { l_icci_8 = iCCI(NULL, PERIOD_M1, 12, PRICE_CLOSE, 1); l_icci_16 = iCCI(NULL, PERIOD_M5, 12, PRICE_CLOSE, 1); if (l_icci_8 > 0.0 && l_icci_16 > 0.0) li_ret_4 = 1; if (l_icci_8 < 0.0 && l_icci_16 < 0.0) li_ret_4 = -1; } else { if (ai_0 == 1) li_ret_4 = 1; if (ai_0 == -1) li_ret_4 = -1; } return (li_ret_4); } void QuitAtTime(int ai_0) { int li_4 = 10000 * TimeDay(TimeCurrent()) + 100 * TimeHour(TimeCurrent()) + TimeMinute(TimeCurrent()); if (li_4 >= ai_0 && ai_0 != 0) { gi_156 = TRUE; ExitAllTrades(Gold, "Stopped Trading because endtime reached!"); } } int PauseAtTime(int ai_0, int ai_4, int ai_8) { int li_ret_12; int li_16; if (ai_0 != 0 && ai_4 != 0) { li_16 = 10000 * TimeDay(TimeCurrent()) + 100 * TimeHour(TimeCurrent()) + TimeMinute(TimeCurrent()); if (li_16 >= ai_0 && li_16 <= ai_4) li_ret_12 = 0; else { if (ai_8 == 1) li_ret_12 = 1; if (ai_8 == -1) li_ret_12 = -1; } } else { if (ai_8 == 1) li_ret_12 = 1; if (ai_8 == -1) li_ret_12 = -1; } return (li_ret_12); } double SessionProfit() { double ld_0; double ld_8; for (int l_pos_24 = OrdersHistoryTotal() - 1; l_pos_24 >= 0; l_pos_24--) { OrderSelect(l_pos_24, SELECT_BY_POS, MODE_HISTORY); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_236) if (OrderComment() == g_str_concat_240) ld_0 += OrderProfit(); } for (int l_pos_28 = OrdersTotal() - 1; l_pos_28 >= 0; l_pos_28--) { OrderSelect(l_pos_28, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_236) if (OrderComment() == g_str_concat_240) ld_8 += OrderProfit(); } double ld_ret_16 = ld_0 + ld_8; return (ld_ret_16); } void getSessionTarget() { if (gi_192 > 0) { if (SessionProfit() >= gi_192) { gi_156 = TRUE; ExitAllTrades(Aqua, "Session Target Achieved. YUHUUI!"); } } } void ExitAllTrades(color a_color_0, string as_4) { int l_ord_close_12; for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) { OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_236) { l_ord_close_12 = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_232, a_color_0); if (l_ord_close_12 == 1) Print("Closed all positions because ", as_4); } } } void CutTotalLoss() { double ld_0; double ld_8; for (g_pos_228 = OrdersTotal() - 1; g_pos_228 >= 0; g_pos_228--) { if (OrderSelect(g_pos_228, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_236 && OrderType() == OP_BUY && OrderProfit() < 0.0) ld_8 += OrderProfit() + OrderSwap() + OrderCommission(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_236 && OrderType() == OP_SELL && OrderProfit() < 0.0) ld_0 += OrderProfit() + OrderSwap() + OrderCommission(); } } double ld_16 = MathAbs(ld_8 + ld_0); if (ld_8 < 0.0 || ld_0 < 0.0 && ld_16 >= gd_204) { if (TimeCurrent() - OrderOpenTime() >= gi_152) { ExitAllTrades(Aqua, "SLTotalinDollar was reached"); g_error_224 = GetLastError(); if (g_error_224 != 0/* NO_ERROR */) Write("Error closing BUY order " + OrderTicket() + ": " + ErrorDescription(g_error_224) + " (A" + g_error_224 + ") Lots:" + OrderLots() + " Bid:" + MarketInfo(OrderSymbol(), MODE_BID)); gi_156 = TRUE; } } }