#property copyright "Ch1qho" #property link "ch1qho@yahoo.com" extern string Time_Info = "Base on Server Time"; extern int OpenHour = 22; extern int CloseHour = 5; extern bool MM = TRUE; extern int Risk = 50; extern double Lots = 0.1; extern int LotsDigit = 2; extern int Slippage = 3; extern int StopLoss = 60; extern string Atr_Info = "Read my manual before apply spesific filter"; extern bool TradeLowRangeDay = TRUE; extern bool TradeOutSideBand = TRUE; extern double MaxDayAtr = 250.0; extern string EquityInfo = "It is better to set amount target when running on multiple pair"; extern double EquityTarget = 0.0; extern bool SecureMyEquityTarget = FALSE; extern int MaxTradePerBar = 1; extern int MaxTradePerPosition = 4; extern string EAName = "Volatily Scalp"; extern string Typical = "Sideway, counter trend system"; extern string Creator = "Ch1qho"; extern string Distribution = "Donation"; extern string Version = "VS_EURCHF D_01"; extern string email_YM = "ch1qho@yahoo.com"; int g_count_220 = 0; bool gi_unused_224 = TRUE; double gd_unused_228 = 0.0; bool gi_236 = TRUE; bool gi_240 = TRUE; double g_pips_244 = 0.0; double gd_252 = 0.0; double g_point_260 = 0.01; int g_bars_268 = 0; int init() { if (Digits == 3) { g_point_260 = 0.01; gd_252 = MarketInfo(Symbol(), MODE_SPREAD) / 10.0; } else { if (Digits == 5) { g_point_260 = 0.0001; gd_252 = MarketInfo(Symbol(), MODE_SPREAD) / 10.0; } else { g_point_260 = Point; gd_252 = MarketInfo(Symbol(), MODE_SPREAD); } } return (0); } int start() { if (GetLastError() > 1/* NO_RESULT */) Sleep(1000); if (SecureMyEquityTarget && EquityTarget > 0.0 && AccountEquity() >= EquityTarget) { ForceCloseAll(514, OP_BUY); ForceCloseAll(514, OP_SELL); gi_236 = FALSE; gi_240 = FALSE; } double l_icustom_0 = iCustom(Symbol(), 0, "CK_Speed", 20, 50, 2, 0); double l_icustom_8 = iCustom(Symbol(), 0, "CK_Speed", 20, 25, 2, 1); double l_icustom_16 = iCustom(Symbol(), 0, "CK_Speed", 5, 50, 0, 1); double l_icustom_24 = iCustom(Symbol(), 0, "CK_Speed", 5, 50, 1, 1); double l_icustom_32 = iCustom(Symbol(), 0, "Keltner Channels", 20, 2, 0, 0); double l_icustom_40 = iCustom(Symbol(), 0, "Keltner Channels", 20, 2, 2, 0); double l_icustom_48 = iCustom(Symbol(), 0, "Keltner Channels", 20, 2, 3, 0); double l_icustom_56 = iCustom(Symbol(), 0, "Keltner Channels", 20, 2, 4, 0); double l_ibands_64 = iBands(Symbol(), 0, 20, 2, 0, PRICE_MEDIAN, MODE_UPPER, 1); double l_ibands_72 = iBands(Symbol(), 0, 20, 2, 0, PRICE_MEDIAN, MODE_LOWER, 1); double l_iwpr_80 = iWPR(Symbol(), PERIOD_M1, 20, 0); double l_ima_88 = iMA(Symbol(), 0, 20, 0, MODE_SMA, PRICE_MEDIAN, 0); double ld_96 = 2.0 * gd_252; double ld_104 = iATR(Symbol(), 0, 20, 1) / g_point_260; g_pips_244 = MathMax(ld_104, 2.0 * gd_252); if (g_bars_268 != Bars) { g_count_220 = 0; g_bars_268 = Bars; } if (TotalOrder(514, OP_BUY) == MaxTradePerPosition) gi_236 = FALSE; if (TotalOrder(514, OP_SELL) == MaxTradePerPosition) gi_240 = FALSE; if (l_icustom_8 == 1.0 && l_icustom_0 == 1.0) { } if (l_iwpr_80 > -20.0) { if (TotalProfit(514, OP_BUY) >= g_pips_244) { ForceCloseAll(514, OP_BUY); if (Close[0] < l_ima_88) gi_236 = FALSE; } } if (l_iwpr_80 < -80.0) { if (TotalProfit(514, OP_SELL) >= g_pips_244) { ForceCloseAll(514, OP_SELL); if (Close[0] > l_ima_88) gi_240 = FALSE; } } if (l_icustom_0 == 1.0) { if (Close[0] > l_ima_88) ForceCloseAll(514, OP_BUY); if (Close[0] < l_ima_88) ForceCloseAll(514, OP_SELL); } if (Close[0] > l_icustom_32 && l_icustom_24 == 2.0) { ForceCloseAll(514, OP_BUY); ForceCloseAll(513, OP_BUY); } if (Close[0] < l_icustom_40 && l_icustom_24 == 2.0) { ForceCloseAll(514, OP_SELL); ForceCloseAll(513, OP_SELL); } if (Close[0] > l_icustom_48) { ForceCloseAll(514, OP_BUY); ForceCloseAll(513, OP_BUY); } if (Close[0] < l_icustom_56) { ForceCloseAll(514, OP_SELL); ForceCloseAll(513, OP_SELL); } if (Tradetime() == 0) { gi_236 = TRUE; gi_240 = TRUE; if (TotalProfit(514, OP_BUY) >= 1) ForceCloseAll(514, OP_BUY); if (TotalProfit(514, OP_SELL) >= 1) ForceCloseAll(514, OP_SELL); } int l_count_112 = 0; int l_count_116 = 0; int l_count_120 = 0; int l_ticket_124 = -1; int l_pos_128 = 0; double l_ord_open_price_132 = 0; double l_ord_open_price_140 = 0; for (l_pos_128 = 0; l_pos_128 < OrdersTotal(); l_pos_128++) { OrderSelect(l_pos_128, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == 514 && OrderCloseTime() == 0) { l_count_120++; if (OrderType() == OP_BUY) { l_count_112++; l_ord_open_price_132 = OrderOpenPrice(); } if (OrderType() == OP_SELL) { l_count_116++; l_ord_open_price_140 = OrderOpenPrice(); } } } if (Tradetime() == 1) { if (AccountFreeMarginCheck(Symbol(), OP_BUY, GetLots()) <= 0.0 || GetLastError() == 134/* NOT_ENOUGH_MONEY */) { Print("Not Enough Money "); return (0); } RefreshRates(); if (gi_240 && l_count_116 < MaxTradePerPosition && g_count_220 < MaxTradePerBar && Ask - l_ord_open_price_140 >= g_pips_244 * g_point_260 || l_count_116 < 1 && GetSignal(1) == 1) { l_ticket_124 = OrderSend(Symbol(), OP_SELL, GetLots(), Bid, Slippage, Bid + StopLoss * g_point_260, 0, "Volatily Scalp" + Symbol(), 514, 0, Red); if (l_ticket_124 > 0) g_count_220++; } if (gi_236 && l_count_112 < MaxTradePerPosition && g_count_220 < MaxTradePerBar && l_ord_open_price_132 - Bid >= g_pips_244 * g_point_260 || l_count_112 < 1 && GetSignal(0) == 1) { l_ticket_124 = OrderSend(Symbol(), OP_BUY, GetLots(), Ask, Slippage, Ask - StopLoss * g_point_260, 0, "Volatily Scalp" + Symbol(), 514, 0, Blue); if (l_ticket_124 > 0) g_count_220++; } } return (0); } int GetSignal(int ai_0) { int li_4 = GetSignal3(); if (li_4 == 0) return (0); double l_ibands_8 = iBands(Symbol(), 0, 20, 2, 0, PRICE_MEDIAN, MODE_UPPER, 0); double l_ibands_16 = iBands(Symbol(), 0, 20, 2, 0, PRICE_MEDIAN, MODE_LOWER, 0); double l_ienvelopes_24 = iEnvelopes(Symbol(), 0, 20, MODE_SMA, 0, PRICE_MEDIAN, 0.2, MODE_UPPER, 0); double l_ienvelopes_32 = iEnvelopes(Symbol(), 0, 20, MODE_SMA, 0, PRICE_MEDIAN, 0.2, MODE_LOWER, 0); double l_iwpr_40 = iWPR(Symbol(), 0, 20, 0); double l_iwpr_48 = iWPR(Symbol(), PERIOD_M1, 20, 0); double l_ima_56 = iMA(Symbol(), 0, 20, 0, MODE_SMA, PRICE_MEDIAN, 0); double l_icustom_64 = iCustom(Symbol(), 0, "Keltner Channels", 20, 2, 3, 0); double l_icustom_72 = iCustom(Symbol(), 0, "Keltner Channels", 20, 2, 4, 0); if (ai_0 == 0) { if (l_iwpr_48 < -80.0 && Bid <= l_ima_56 - g_pips_244 * g_point_260 && Bid > l_ibands_16 || Bid > l_icustom_72) return (1); } else { if (ai_0 == 1) if (l_iwpr_48 > -20.0 && Bid >= l_ima_56 + g_pips_244 * g_point_260 && Bid < l_ibands_8 || Bid < l_icustom_64) return (1); } return (0); } int GetSignal3() { double l_ibands_0 = iBands(Symbol(), PERIOD_D1, 20, 2, 0, PRICE_MEDIAN, MODE_UPPER, 1); double l_ibands_8 = iBands(Symbol(), PERIOD_D1, 20, 2, 0, PRICE_MEDIAN, MODE_LOWER, 1); double ld_16 = iATR(Symbol(), PERIOD_D1, 5, 0) / g_point_260; double l_icustom_24 = iCustom(Symbol(), 0, "CK_Speed", 20, 50, 0, 0); double l_icustom_32 = iCustom(Symbol(), 0, "CK_Speed", 20, 50, 0, 1); double l_icustom_40 = iCustom(Symbol(), 0, "CK_Speed", 5, 50, 0, 0); double l_icustom_48 = iCustom(Symbol(), 0, "CK_Speed", 20, 50, 2, 1); double l_icustom_56 = iCustom(Symbol(), 0, "CK_Speed", 5, 50, 0, 0); double l_icustom_64 = iCustom(Symbol(), 0, "CK_Speed", 5, 50, 0, 1); double ld_72 = (iHigh(Symbol(), PERIOD_D1, 1) - iLow(Symbol(), PERIOD_D1, 1)) / g_point_260; if (g_pips_244 >= StopLoss) return (0); if (ld_16 >= MaxDayAtr) return (0); if (!TradeOutSideBand) if (iClose(Symbol(), PERIOD_D1, 1) > l_ibands_0 || iClose(Symbol(), PERIOD_D1, 1) < l_ibands_8) return (0); if (!TradeLowRangeDay) if (ld_72 < ld_16 / 2.0) return (0); if (l_icustom_24 == 0.0 && l_icustom_32 == 0.0 && l_icustom_56 == 0.0 && l_icustom_64 == 0.0) return (1); return (0); } void ForceCloseAll(int a_magic_0, int a_cmd_4) { for (int l_pos_8 = OrdersTotal() - 1; l_pos_8 >= 0; l_pos_8--) { OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_0 && OrderCloseTime() == 0) if (OrderType() == a_cmd_4) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, Blue); } } int Tradetime() { bool li_ret_0 = FALSE; if (OpenHour > CloseHour) if (Hour() <= CloseHour || Hour() >= OpenHour) li_ret_0 = TRUE; if (OpenHour < CloseHour) if (Hour() >= OpenHour && Hour() <= CloseHour) li_ret_0 = TRUE; if (OpenHour == CloseHour) if (Hour() == OpenHour) li_ret_0 = TRUE; if (DayOfWeek() == 5 && Hour() > 8) li_ret_0 = FALSE; if (DayOfWeek() == 1 && Hour() < 2) li_ret_0 = FALSE; if (DayOfYear() < 7) li_ret_0 = FALSE; if (Month() == 12 && Day() > 20) li_ret_0 = FALSE; return (li_ret_0); } double GetLots() { double l_lots_0; int li_48; double l_lotsize_40 = MarketInfo(Symbol(), MODE_LOTSIZE); double ld_8 = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSTEP), 2); double ld_16 = NormalizeDouble(MarketInfo(Symbol(), MODE_MARGINREQUIRED), 4); double ld_24 = 100.0 * (ld_16 + 5.0); if (LotsDigit == 0) { if (ld_8 == 0.01) li_48 = 2; else li_48 = 1; LotsDigit = li_48; } if (MM == TRUE) l_lots_0 = NormalizeDouble(AccountFreeMargin() * Risk / l_lotsize_40 / MaxTradePerPosition, LotsDigit); else l_lots_0 = Lots; double ld_32 = NormalizeDouble(MarketInfo(Symbol(), MODE_MINLOT), 2); double ld_52 = NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT), 2); if (l_lots_0 < ld_32) l_lots_0 = ld_32; if (l_lots_0 > ld_52) l_lots_0 = ld_52; return (l_lots_0); } int TotalProfit(int a_magic_0, int a_cmd_4) { bool li_ret_8 = FALSE; for (int l_pos_20 = OrdersTotal() - 1; l_pos_20 >= 0; l_pos_20--) { OrderSelect(l_pos_20, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_0) { if (a_cmd_4 == OP_BUY && a_cmd_4 == OrderType()) li_ret_8 = li_ret_8 + (OrderClosePrice() - OrderOpenPrice()) / g_point_260; if (a_cmd_4 == OP_SELL && a_cmd_4 == OrderType()) li_ret_8 = li_ret_8 + (OrderOpenPrice() - OrderClosePrice()) / g_point_260; } } return (li_ret_8); } int TotalOrder(int a_magic_0, int a_cmd_4) { int l_count_8 = 0; for (int l_pos_12 = OrdersTotal() - 1; l_pos_12 >= 0; l_pos_12--) { OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_0) if (a_cmd_4 == OrderType()) l_count_8++; } return (l_count_8); }