Navigation´╝ÜHome > Content >

Multi_currency_midas.mq4

Time: 2015-12-10 | Download file:Multi_currency_midas.mq4

#property copyright "11"
#property link      "11"

#import "m-midas.dll"
   int SData(double a0, double a1, double a2, double a3, double a4, double a5);
#import

bool Gi_76 = FALSE;
bool Gi_80 = TRUE;
extern string a = "Main options ";
extern string b = "Trailing Stop (pips) ";
extern int TrailingStop = 0;
extern string c = "MaxStopLoss (pips) ";
extern int MaxStopLoss = 60;
extern string d = "Trailing Step (pips) ";
extern int TrailingStep = 2;
extern string cc = "Currency 1 ";
extern string paira = "EURUSD";
extern string ee = "Currency 2 ";
extern string pairb = "USDJPY";
extern string rr = "the percentage of the deposit for the emergency return";
extern double EmergencyPersent = 60.0;
bool Gi_176 = FALSE;
string Gs_180 = "expert.wav";
int Gi_188 = 0;
double Gd_unused_192 = 0.0;
extern string e = "Trading lot size ";
extern double lot = 0.1;
double Gd_unused_216 = 1.0;
extern string f = "maximum number of orders ";
extern int maxo = 10;
int Gi_236 = 10;
int Gi_240 = 5;
int Gi_unused_244 = 20;
int Gi_unused_248 = 10;
double Gd_260;
double Gd_268;
int G_magic_276 = 777;
int G_pos_280;
int Gi_284;
int G_ticket_288;
int G_count_292;
double Gd_unused_296 = 1.0;
int Gi_304;
int Gi_308;
int Gi_312;
int Gi_316;
int G_count_320;
int G_count_324;
int G_order_total_328;
int G_pos_332;
int Gi_336;
bool Gi_340;
int Gi_344;
bool Gi_348;
int Gi_352 = 1000;

void init() {
   if (Digits == 3 || Digits == 5) {
      Gd_unused_296 = 10;
      return;
   }
   Gd_unused_296 = 1;
}

void deinit() {
   lot = 0.1;
}

int start() {
   trl();
   if (AccountEquity() <= AccountBalance() / 100.0 * EmergencyPersent) closeall();
   Gi_304 = MathRound(maxo / 2);
   Gi_308 = Gi_304;
   G_count_320 = 0;
   G_count_324 = 0;
   Gi_340 = FALSE;
   int Li_0 = MarketInfo(OrderSymbol(), MODE_DIGITS);
   Gd_260 = NormalizeDouble(Ask, Li_0);
   Gd_268 = NormalizeDouble(Bid, Li_0);
   Gi_348 = FALSE;
   G_count_292 = 0;
   int Li_4 = 34849;
   if (AccountNumber() != Li_4) {
   }
   G_order_total_328 = OrdersTotal();
   for (G_pos_332 = 0; G_pos_332 < G_order_total_328; G_pos_332++) {
      Gi_336 = 0;
      OrderSelect(G_pos_332, SELECT_BY_POS, MODE_TRADES);
      if (OrderOpenTime() > Gi_336 && OrderSymbol() == Symbol())
         if (Gi_344 < Gi_352) Gi_352 = Gi_344;
   }
   for (G_pos_332 = 0; G_pos_332 < G_order_total_328; G_pos_332++) {
      OrderSelect(G_pos_332, SELECT_BY_POS, MODE_TRADES);
      if (OrderOpenTime() == Gi_336) Gi_344 = MathAbs(100000.0 * Ask - 100000.0 * OrderOpenPrice());
   }
   if (Gi_352 > Gi_240) Gi_340 = TRUE;
   if (OrdersTotal() == 0) Gi_340 = TRUE;
   for (int pos_8 = 0; pos_8 < OrdersTotal(); pos_8++) {
      if (OrderSelect(pos_8, SELECT_BY_POS, MODE_TRADES))
         if (OrderSymbol() == Symbol() && OrderType() == OP_SELL) G_count_324++;
   }
   for (pos_8 = 0; pos_8 < OrdersTotal(); pos_8++) {
      if (OrderSelect(pos_8, SELECT_BY_POS, MODE_TRADES))
         if (OrderSymbol() == Symbol() && OrderType() == OP_BUY) G_count_320++;
   }
   Gi_316 = G_count_324;
   Gi_312 = G_count_320;
   if (AccountProfit() > Gi_236) closeall();
   if (rust() == 1) lot = 0.1;
   if (rust() == 0) lot = 0.1;
   for (G_pos_280 = 0; G_pos_280 < Gi_284; G_pos_280++) {
      OrderSelect(G_pos_280, SELECT_BY_POS, MODE_TRADES);
      if (OrderMagicNumber() == G_magic_276) {
         Gi_348 = TRUE;
         G_count_292++;
      }
   }
   Sleep(10000);
   int Li_12 = SData(Close[0], Open[0], Close[1], Open[1], iRSI(NULL, 0, 14, PRICE_CLOSE, 0), iRSI(NULL, 0, 21, PRICE_CLOSE, 0));
   if (Gi_348 == FALSE && Gi_188 == 1 && G_count_292 <= 1) Gi_188 = 0;
   if (Gi_348 == FALSE && Gi_188 == 2 && G_count_292 <= 1) Gi_188 = 0;
   if (Gi_348 == FALSE && Li_12 == 2 && Gi_308 > Gi_316 && OrdersTotal() < maxo && Gi_340 == TRUE) {
      RefreshRates();
      G_ticket_288 = OrderSend(pairb, OP_BUY, lot, MarketInfo(pairb, MODE_ASK), 3, 0, 0, "", 0, 0, Red);
      G_ticket_288 = OrderSend(paira, OP_SELL, lot, MarketInfo(paira, MODE_BID), 3, 0, 0, "", 0, 0, Blue);
      if (G_ticket_288 < 0) Print("Error opening sell order : ", GetLastError() + G_ticket_288);
      Gi_188 = 1;
   }
   if (Gi_348 == FALSE && Li_12 == 1 && Gi_304 > Gi_312 && OrdersTotal() < maxo && Gi_340 == TRUE) {
      RefreshRates();
      G_ticket_288 = OrderSend(paira, OP_BUY, lot, MarketInfo(paira, MODE_ASK), 3, 0, 0, "", 0, 0, Red);
      G_ticket_288 = OrderSend(pairb, OP_SELL, lot, MarketInfo(pairb, MODE_BID), 3, 0, 0, "", 0, 0, Blue);
      if (G_ticket_288 < 0) Print("Error opening BUY order : ", GetLastError() + G_ticket_288);
      Gi_188 = 2;
   }
   return (0);
}

int rust() {
   int datetime_0 = 0;
   double order_profit_4 = 0;
   for (int hist_total_12 = OrdersHistoryTotal(); hist_total_12 >= 0; hist_total_12--) {
      if (OrderSelect(hist_total_12, SELECT_BY_POS, MODE_HISTORY)) {
         if (OrderSymbol() == Symbol()) {
            if (datetime_0 < OrderCloseTime()) {
               datetime_0 = OrderCloseTime();
               order_profit_4 = OrderProfit();
            }
         }
      }
   }
   if (order_profit_4 == 0.0 && datetime_0 == 0) {
   }
   if (order_profit_4 >= 0.0) return (1);
   if (order_profit_4 < 0.0) return (0);
   return (0);
}

int closeall() {
   int cmd_8;
   bool Li_12;
   int order_total_0 = OrdersTotal();
   for (int pos_4 = order_total_0 - 1; pos_4 >= 0; pos_4--) {
      OrderSelect(pos_4, SELECT_BY_POS);
      cmd_8 = OrderType();
      Li_12 = FALSE;
      switch (cmd_8) {
      case OP_BUY:
         Li_12 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red);
         break;
      case OP_SELL:
         Li_12 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red);
         break;
      case OP_BUYLIMIT:
      case OP_BUYSTOP:
      case OP_SELLLIMIT:
      case OP_SELLSTOP:
         Li_12 = OrderDelete(OrderTicket());
      }
      if (Li_12 == FALSE) Sleep(500);
   }
   return (0);
}

void trl() {
   for (int pos_0 = 0; pos_0 < OrdersTotal(); pos_0++) {
      if (OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES))
         if (Gi_76 || OrderSymbol() == Symbol()) TrailingPositions();
   }
}

void TrailingPositions() {
   double bid_0;
   double ask_8;
   double point_16 = MarketInfo(OrderSymbol(), MODE_POINT);
   if (OrderType() == OP_BUY) {
      bid_0 = MarketInfo(OrderSymbol(), MODE_BID);
      if (OrderStopLoss() == 0.0) ModifyStopLoss(bid_0 - MaxStopLoss * point_16);
      if (OrderOpenPrice() == bid_0 - 2.0 * point_16) ModifyStopLoss(bid_0);
      if ((!Gi_80) || bid_0 - OrderOpenPrice() > TrailingStop * point_16) {
         if (OrderStopLoss() < bid_0 - (TrailingStop + TrailingStep - 1) * point_16) {
            ModifyStopLoss(bid_0 - TrailingStop * point_16);
            return;
         }
      }
   }
   if (OrderType() == OP_SELL) {
      ask_8 = MarketInfo(OrderSymbol(), MODE_ASK);
      if (OrderStopLoss() == 0.0) ModifyStopLoss(ask_8 + MaxStopLoss * point_16);
      if (OrderOpenPrice() == ask_8 - 2.0 * point_16) ModifyStopLoss(ask_8);
      if ((!Gi_80) || OrderOpenPrice() - ask_8 > TrailingStop * point_16)
         if (OrderStopLoss() > ask_8 + (TrailingStop + TrailingStep - 1) * point_16 || OrderStopLoss() == 0.0) ModifyStopLoss(ask_8 + TrailingStop * point_16);
   }
}

void ModifyStopLoss(double A_price_0) {
   bool bool_8 = OrderModify(OrderTicket(), OrderOpenPrice(), A_price_0, OrderTakeProfit(), 0, CLR_NONE);
   if (bool_8 && Gi_176) PlaySound(Gs_180);
}

Recommend