scalping-pro.ex4 · version 1

Download :
https://mega.nz/#!Gx8CxbhK!WAhnpr9o_p-F-Tb2S_0qDofbSd9cErqXke_lurev6Rs
https://mega.nz/#!6gMxhJBA!3b73vXMdFa9GqeDsJkTyPis_pXHNYFc2Q5I6mpSbeqc

//real account
extern string _EA = "________EA MA________";
extern int Magic = 20110402;
extern string TypeOfCalculation = "Percentage";
extern double Value = 10.0;
extern int TakeProfit1 = 5;
extern int TakeProfit2 = 5;
extern int StopLoss = 250;
int Gi_116 = 0;
extern string _MOVING_AVERAGES1 = "_______MA INDICATOR 1______";
extern int MA_Period1 = 100;
extern int MA_Method1 = 0;
extern string MA_MethoD1 = "0=simple 1=exponential 2=smoothed 3=linear weighted";
extern int aplied_price1 = 0;
extern string aplied_pricE1 = "0=CLOSE 1=OPEN 2=HIGH 3=LOW 4=MEDIAN 5=TYPICAL 6=WEIGHTED";
extern string _MOVING_AVERAGES2 = "_______MA INDICATOR 2______";
extern int MA_Period2 = 100;
extern int MA_Method2 = 0;
extern string MA_MethoD2 = "0=simple 1=exponential 2=smoothed 3=linear weighted";
extern int aplied_price2 = 0;
extern string aplied_pricE2 = "0=CLOSE 1=OPEN 2=HIGH 3=LOW 4=MEDIAN 5=TYPICAL 6=WEIGHTED";
extern string _TIMEFILTER = "_______ TIME FILTER BROKER TIME _______";
extern bool Use_TimeFilter = TRUE;
extern int StartHour = 3;
extern int EndHour = 12;
int Gi_212;
int Gi_216;
int Gi_220;
string Gs_unused_224;
double Gd_232;
double Gd_240;
double G_minlot_248;
int Gi_256;
int Gi_260;
int G_slippage_264 = 10;
int Gi_268;
int Gi_272;
double G_order_lots_276;
double G_order_open_price_284;
double G_order_lots_292;
double G_order_open_price_300;
double G_order_open_price_308;
double G_order_lots_316;
int G_cmd_324;
int G_count_328;
int G_count_332;
int G_pos_336;
int G_count_340;
int G_count_344;
int G_datetime_348;
int G_datetime_352;
double G_ima_356;
double G_ima_364;
int Gi_372 = 50;
int Gi_376 = 70;
int Gi_380;
int Gi_384;
int G_acc_number_388 = 288819;
string Gs_392 = "2030.12.28 00:00";

int init() {
   if (!IsExpertEnabled()) Alert("Robot belum aktif, klik Expert Advisors");
   if (!IsTradeAllowed()) Alert("Robot belum aktif, klik Tool->option->Expert Advisors->centang Allow live trading->Ok");
   Gi_380 = Magic - 1832;
   Gi_384 = Magic - 364;
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   double Ld_0 = ManualRisk(TypeOfCalculation, Value);
   G_minlot_248 = MarketInfo(Symbol(), MODE_MINLOT);
   if (G_minlot_248 / 0.01 == 1.0) Gi_256 = 2;
   else Gi_256 = 1;
   if (10.0 * MarketInfo(Symbol(), MODE_LOTSTEP) < 1.0) Gi_256 = 2;
   else Gi_256 = 1;
   if (Digits == 5 || Digits == 3 || Symbol() == "GOLD" || Symbol() == "GOLD." || Symbol() == "GOLDm") {
      Gi_260 = 10;
      G_slippage_264 = 100;
   } else Gi_260 = 1;
   Gd_232 = NormalizeDouble(MarketInfo(Symbol(), MODE_MINLOT), Gi_256);
   Gd_240 = NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT), Gi_256);
   if (Ld_0 < Gd_232) Ld_0 = Gd_232;
   if (Ld_0 > Gd_240) Ld_0 = Gd_240;
   Ld_0 = NormalizeDouble(Ld_0, Gi_256);
   Gi_272 = NormalizeDouble(MarketInfo(Symbol(), MODE_STOPLEVEL), 2);
   Gi_268 = NormalizeDouble(MarketInfo(Symbol(), MODE_SPREAD), 2);
   if (Gi_116 * Gi_260 < Gi_272 + Gi_268 && Gi_116 != 0) Gi_116 = (Gi_272 + Gi_268) / Gi_260;
   getOpenOrders(Gi_380, TakeProfit1, StopLoss, Gi_116);
   getOpenOrders(Gi_384, TakeProfit2, StopLoss, Gi_116);
   G_ima_356 = iMA(NULL, 0, MA_Period1, 0, MA_Method1, aplied_price1, 0);
   G_ima_364 = iMA(NULL, 0, MA_Period2, 0, MA_Method2, aplied_price2, 0);
   openord(Gi_380);
   if (TimeFilter() && G_datetime_348 != iTime(Symbol(), 0, 0) && kadaluarsa() && LoginNumber()) {
      if (buy_MA1())
         if (OPEN(Symbol(), OP_BUY, Blue, Ld_0, G_slippage_264, Ask, 0, StopLoss, TakeProfit1, "Rubi_sniper", Gi_380)) G_datetime_348 = iTime(Symbol(), 0, 0);
      if (sell_MA1())
         if (OPEN(Symbol(), OP_SELL, Red, Ld_0, G_slippage_264, Bid, 0, StopLoss, TakeProfit1, "Rubi_sniper", Gi_380)) G_datetime_348 = iTime(Symbol(), 0, 0);
   }
   openord(Gi_384);
   if (TimeFilter() && G_datetime_352 != iTime(Symbol(), 0, 0) && kadaluarsa() && LoginNumber()) {
      if (buy_MA2())
         if (OPEN(Symbol(), OP_BUY, Blue, Ld_0, G_slippage_264, Ask, 0, StopLoss, TakeProfit2, "Rubi_sniper", Gi_384)) G_datetime_352 = iTime(Symbol(), 0, 0);
      if (sell_MA2())
         if (OPEN(Symbol(), OP_SELL, Red, Ld_0, G_slippage_264, Bid, 0, StopLoss, TakeProfit2, "Rubi_sniper", Gi_384)) G_datetime_352 = iTime(Symbol(), 0, 0);
   }
   komentar(1, "NAMA", AccountName());
   komentar(2, "NO. ACCOUNT", AccountNumber());
   komentar(3, "BROKER", AccountCompany());
   komentar(4, "LEVERAGE", "1:" + DoubleToStr(AccountLeverage(), 0));
   komentar(5, "TOTAL ORDER", DoubleToStr(OrdersHistoryTotal(), 0));
   komentar(6, "EQUITY", DoubleToStr(AccountEquity(), 2));
   komentar(7, "PROFIT", DoubleToStr(AccountProfit(), 2));
   return (0);
}

int sell_MA1() {
   if (iClose(Symbol(), PERIOD_M1, 1) < G_ima_356 + Gi_372 * Gi_260 * Point && iClose(Symbol(), PERIOD_M1, 0) >= G_ima_356 + Gi_372 * Gi_260 * Point) return (1);
   return (0);
}

int buy_MA1() {
   if (iClose(Symbol(), PERIOD_M1, 1) > G_ima_356 - Gi_372 * Gi_260 * Point && iClose(Symbol(), PERIOD_M1, 0) <= G_ima_356 - Gi_372 * Gi_260 * Point) return (1);
   return (0);
}

int sell_MA2() {
   if (iClose(Symbol(), PERIOD_M1, 1) < G_ima_364 + Gi_376 * Gi_260 * Point && iClose(Symbol(), PERIOD_M1, 0) >= G_ima_364 + Gi_376 * Gi_260 * Point) return (1);
   return (0);
}

int buy_MA2() {
   if (iClose(Symbol(), PERIOD_M1, 1) > G_ima_364 - Gi_376 * Gi_260 * Point && iClose(Symbol(), PERIOD_M1, 0) <= G_ima_364 - Gi_376 * Gi_260 * Point) return (1);
   return (0);
}

void komentar(int Ai_0, string As_4, string As_12) {
   int Li_20;
   int Li_24;
   if ((!IsTradeAllowed()) || (!IsExpertEnabled())) {
      ObjectDelete("baris0");
      return;
   }
   switch (Ai_0) {
   case 1:
      Li_20 = 40;
      Li_24 = 60;
      break;
   case 2:
      Li_20 = 40;
      Li_24 = 75;
      break;
   case 3:
      Li_20 = 40;
      Li_24 = 90;
      break;
   case 4:
      Li_20 = 40;
      Li_24 = 105;
      break;
   case 5:
      Li_20 = 40;
      Li_24 = 120;
      break;
   case 6:
      Li_20 = 40;
      Li_24 = 135;
      break;
   case 7:
      Li_20 = 40;
      Li_24 = 150;
      break;
   case 8:
      Li_20 = 40;
      Li_24 = 165;
      break;
   case 9:
      Li_20 = 40;
      Li_24 = 180;
      break;
   case 10:
      Li_20 = 40;
      Li_24 = 195;
      break;
   case 11:
      Li_20 = 40;
      Li_24 = 210;
      break;
   case 12:
      Li_20 = 40;
      Li_24 = 225;
      break;
   case 13:
      Li_20 = 40;
      Li_24 = 240;
      break;
   case 14:
      Li_20 = 40;
      Li_24 = 255;
      break;
   case 15:
      Li_20 = 40;
      Li_24 = 270;
      break;
   case 16:
      Li_20 = 40;
      Li_24 = 285;
      break;
   case 17:
      Li_20 = 40;
      Li_24 = 300;
   }
   Monitor("baris0", WindowExpertName() + " Sedang berjalan ....", 10, 40, 20, FireBrick, 0);
   Monitor("baris00", "Sabar dan disiplin kunci kesuksesan  -> by Rubianto", 8, 40, 10, RoyalBlue, 2);
   Monitor("baris" + Ai_0, As_4, 8, Li_20, Li_24, RoyalBlue, 0);
   Monitor("baris_" + Ai_0, ":", 8, Li_20 + 150, Li_24, RoyalBlue, 0);
   Monitor("baris-" + Ai_0, As_12, 8, Li_20 + 160, Li_24, RoyalBlue, 0);
}

double ManualRisk(string As_0 = "%", double Ad_8 = 0.0, double Ad_16 = 0.0) {
   double Ld_24 = 0;
   if (Ad_16 <= 0.0) Ad_16 = AccountEquity();
   if (As_0 == "Percentage" || As_0 == "%") Ld_24 = Ad_16 * Ad_8 / 100000.0;
   if (As_0 == "Lot" || As_0 == "Lots") Ld_24 = Ad_8;
   if (As_0 == "Percentage" || As_0 == "%" || As_0 == "Lot" || As_0 == "Lots") {
      if (Ld_24 < MarketInfo(Symbol(), MODE_MINLOT)) return (MarketInfo(Symbol(), MODE_MINLOT));
      if (MarketInfo(Symbol(), MODE_LOTSTEP) == 0.01) return (NormalizeDouble(Ld_24, 2));
      if (MarketInfo(Symbol(), MODE_LOTSTEP) == 0.1) return (NormalizeDouble(Ld_24, 1));
   }
   return (0);
}

void Monitor(string A_name_0, string A_text_8, int A_fontsize_16, int A_x_20, int A_y_24, color A_color_28, int A_corner_32) {
   if (ObjectFind(A_name_0) < 0) ObjectCreate(A_name_0, OBJ_LABEL, 0, 0, 0, 0, 0);
   ObjectSet(A_name_0, OBJPROP_CORNER, A_corner_32);
   ObjectSet(A_name_0, OBJPROP_XDISTANCE, A_x_20);
   ObjectSet(A_name_0, OBJPROP_YDISTANCE, A_y_24);
   ObjectSetText(A_name_0, A_text_8, A_fontsize_16, "Tahoma", A_color_28);
}

int OPEN(string A_symbol_0, int A_cmd_8, color A_color_12, double A_lots_16, double A_slippage_24, double A_price_32, int Ai_40, double Ad_44, double Ad_52, string A_comment_60, int A_magic_68) {
   double price_72;
   double price_80;
   int ticket_88 = 0;
   while (ticket_88 <= 0) {
      RefreshRates();
      Gi_272 = NormalizeDouble(MarketInfo(Symbol(), MODE_STOPLEVEL), 0);
      Gi_268 = NormalizeDouble(MarketInfo(Symbol(), MODE_SPREAD), 0);
      if (A_cmd_8 == OP_BUY || A_cmd_8 == OP_BUYLIMIT || A_cmd_8 == OP_BUYSTOP) {
         if (Ad_52 * Gi_260 >= Gi_272 && (!Ai_40)) price_72 = A_price_32 + Ad_52 * Gi_260 * Point;
         else price_72 = 0;
         if (Ad_44 * Gi_260 >= Gi_272 + Gi_268 && (!Ai_40)) price_80 = A_price_32 - Ad_44 * Gi_260 * Point;
         else price_80 = 0;
      }
      if (A_cmd_8 == OP_SELL || A_cmd_8 == OP_SELLLIMIT || A_cmd_8 == OP_SELLSTOP) {
         if (Ad_52 * Gi_260 >= Gi_272 && (!Ai_40)) price_72 = A_price_32 - Ad_52 * Gi_260 * Point;
         else price_72 = 0;
         if (Ad_44 * Gi_260 >= Gi_272 + Gi_268 && (!Ai_40)) price_80 = A_price_32 + Ad_44 * Gi_260 * Point;
         else price_80 = 0;
      }
      ticket_88 = OrderSend(A_symbol_0, A_cmd_8, A_lots_16, A_price_32, A_slippage_24, price_80, price_72, A_comment_60, A_magic_68, 0, A_color_12);
      if (ticket_88 <= 0) Sleep(1000);
      else return (1);
   }
   return (0);
}

int TimeFilter() {
   Gi_212 = EndHour + Gi_220;
   Gi_216 = StartHour + Gi_220;
   if (StartHour + Gi_220 < 0) Gi_216 = StartHour + Gi_220 + 24;
   if (EndHour + Gi_220 < 0) Gi_212 = EndHour + Gi_220 + 24;
   if (StartHour + Gi_220 > 24) Gi_216 = StartHour + Gi_220 - 24;
   if (EndHour + Gi_220 > 24) Gi_212 = EndHour + Gi_220 - 24;
   if (Use_TimeFilter == FALSE) {
      Gs_unused_224 = "";
      return (1);
   }
   if (Gi_216 < Gi_212) {
      if (Hour() >= Gi_216 && Hour() < Gi_212) {
         Gs_unused_224 = "";
         return (1);
      }
      Gs_unused_224 = "Peringatan: Diluar jam trading, Robot istirahat\n";
      return (0);
   }
   if (Gi_216 > Gi_212) {
      if (Hour() >= Gi_216 || Hour() < Gi_212) {
         Gs_unused_224 = "";
         return (1);
      }
      Gs_unused_224 = "Peringatan: Diluar jam trading, Robot istirahat\n";
      return (0);
   }
   return (0);
}

double getPipValue(double Ad_0, int Ai_8) {
   double Ld_ret_12;
   RefreshRates();
   if (Ai_8 == 1) Ld_ret_12 = NormalizeDouble(Ad_0, Digits) - NormalizeDouble(Ask, Digits);
   else Ld_ret_12 = NormalizeDouble(Bid, Digits) - NormalizeDouble(Ad_0, Digits);
   Ld_ret_12 /= Point;
   return (Ld_ret_12);
}

void getOpenOrders(int A_magic_0, double Ad_4, double Ad_12, double Ad_20) {
   double Ld_28;
   int order_total_36 = OrdersTotal();
   for (int pos_40 = 0; pos_40 < order_total_36; pos_40++) {
      OrderSelect(pos_40, SELECT_BY_POS, MODE_TRADES);
      if (OrderType() == OP_BUY || OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == A_magic_0) {
         Ld_28 = getPipValue(OrderOpenPrice(), OrderType());
         if (Ad_4 != 0.0) takeProfit(Ad_4, Ld_28, OrderTicket());
         if (Ad_12 != 0.0) killTrade(Ad_12, Ld_28, OrderTicket());
         if (Ad_20 != 0.0) TrailingPositions(Ad_20, 1, OrderTicket());
      }
   }
}

void takeProfit(double Ad_0, int Ai_8, int A_ticket_12) {
   int Li_unused_16;
   if (OrderSelect(A_ticket_12, SELECT_BY_TICKET) == TRUE) {
      Li_unused_16 = MarketInfo(Symbol(), MODE_SPREAD);
      if (Ai_8 >= Ad_0 * Gi_260) {
         if (OrderType() == OP_SELL) OrderClose(A_ticket_12, OrderLots(), Ask, G_slippage_264, Red);
         if (OrderType() == OP_BUY) OrderClose(A_ticket_12, OrderLots(), Bid, G_slippage_264, Blue);
      }
   }
}

void killTrade(double Ad_0, int Ai_8, int A_ticket_12) {
   if (OrderSelect(A_ticket_12, SELECT_BY_TICKET) == TRUE) {
      if (Ai_8 <= (-Ad_0) * Gi_260) {
         if (OrderType() == OP_SELL) OrderClose(A_ticket_12, OrderLots(), Ask, G_slippage_264, Red);
         if (OrderType() == OP_BUY) OrderClose(A_ticket_12, OrderLots(), Bid, G_slippage_264, Blue);
      }
   }
}

void TrailingPositions(double Ad_0, double Ad_8, int A_ticket_16) {
   if (OrderType() == OP_BUY) {
      if (NormalizeDouble(Bid, Digits) - NormalizeDouble(OrderOpenPrice(), Digits) >= NormalizeDouble(Ad_0 * Gi_260 * Point, Digits)) {
         if (NormalizeDouble(OrderStopLoss(), Digits) < NormalizeDouble(Bid - (Ad_0 + Ad_8 - 1.0) * Gi_260 * Point, Digits) || NormalizeDouble(OrderStopLoss(), Digits) == 0.0) {
            OrderModify(A_ticket_16, OrderOpenPrice(), NormalizeDouble(Bid - Ad_0 * Gi_260 * Point, Digits), OrderTakeProfit(), 0, CLR_NONE);
            return;
         }
      }
   }
   if (OrderType() == OP_SELL) {
      if (NormalizeDouble(OrderOpenPrice(), Digits) - NormalizeDouble(Ask, Digits) >= NormalizeDouble(Ad_0 * Gi_260 * Point, Digits)) {
         if (NormalizeDouble(OrderStopLoss(), Digits) > NormalizeDouble(Ask + (Ad_0 + Ad_8 - 1.0) * Gi_260 * Point, Digits) || NormalizeDouble(OrderStopLoss(), Digits) == 0.0) {
            OrderModify(A_ticket_16, OrderOpenPrice(), NormalizeDouble(Ask + Ad_0 * Gi_260 * Point, Digits), OrderTakeProfit(), 0, CLR_NONE);
            return;
         }
      }
   }
}

void openord(int A_magic_0) {
   G_count_332 = 0;
   G_count_340 = 0;
   G_count_344 = 0;
   G_count_328 = 0;
   for (G_pos_336 = 0; G_pos_336 < OrdersTotal(); G_pos_336++) {
      OrderSelect(G_pos_336, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == A_magic_0 && OrderType() == OP_BUY || OrderType() == OP_SELL) {
         G_count_332++;
         G_order_open_price_308 = OrderOpenPrice();
         G_order_lots_316 = OrderLots();
         G_cmd_324 = OrderType();
      }
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP || OrderType() == OP_SELLLIMIT) G_count_328++;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_BUY) {
         G_count_340++;
         G_order_open_price_300 = OrderOpenPrice();
         G_order_lots_292 = OrderLots();
      }
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL) {
         G_count_344++;
         G_order_open_price_284 = OrderOpenPrice();
         G_order_lots_276 = OrderLots();
      }
   }
}

int kadaluarsa() {
   int str2time_0 = StrToTime(Gs_392);
   if (TimeCurrent() > str2time_0) {
      Alert("Robot sudah kedaluarsa, silahkan kontak kami di rubianto.md@gmail.com");
      return (0);
   }
   return (1);                                                          //IsDemo() == false; // if (IsDemo() == true)
}

int LoginNumber() {
   //if (AccountNumber() == G_acc_number_388 || G_acc_number_388 == 0 ||  if (IsDemo() == false))  // || IsTesting()) return (1);
   bool bool_8 = IsDemo() == false; // if (IsDemo() == true)
   //Alert("Robot ini bukan untuk akun real ini, silahkan kontak kami di rubianto.md@gmail.com ");
   return (0);
}