Results 1 to 1 of 1
 0 Attachment(s)    

Thread: Simple grid EA need to modify to work with other EA

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    11

    Default Simple grid EA need to modify to work with other EA

    Code:
    #import "C:\\MQ4Check.dll"
       int getKey1();
    #import
    
    extern int Step = 200;
    extern double FirstLot = 0.1;
    extern double IncLot = 0.0;
    extern double MinProfit = 18.0;
    extern int Magic = 2010;
    double g_ord_lots_108 = 0.0;
    double g_ord_lots_116 = 0.0;
    double gd_124;
    double gd_132;
    int gi_140 = 1635190;
    
    int init() {
       if (idCheck() != 1) {
          Comment("try me");
          GlobalVariableSet("OldBalance", AccountBalance());
          return (0);
       }
    }
    
    int deinit() {
       if (idCheck() != 1) {
          Comment("");
          return (0);
       }
    }
    
    int start() {
       if (idCheck() != 1) {
          if (AccountEquity() >= GlobalVariableGet("OldBalance") + MinProfit) {
             DeletePendingOrders(Magic);
             CloseOrders(Magic);
             GlobalVariableSet("OldBalance", 0);
          }
          GlobalVariableSet("OldBalance", AccountBalance());
          if (MyOrdersTotal(Magic) == 0) {
             OrderSend(Symbol(), OP_BUYLIMIT, FirstLot, Ask - Step * Point, 3, 0, 0, "", Magic, 0, Green);
             OrderSend(Symbol(), OP_SELLLIMIT, FirstLot, Bid + Step * Point, 3, 0, 0, "", Magic, 0, Red);
          }
          gd_124 = GetLastSellPrice(Magic);
          gd_132 = GetLastBuyPrice(Magic);
          if (gd_124 - Bid <= 5.0 * Point) OrderSend(Symbol(), OP_SELLLIMIT, g_ord_lots_108 + IncLot, gd_124 + Step * Point, 3, 0, 0, "", Magic, 0, Red);
          if (Ask - gd_132 <= 5.0 * Point) OrderSend(Symbol(), OP_BUYLIMIT, g_ord_lots_116 + IncLot, gd_132 - Step * Point, 3, 0, 0, "", Magic, 0, Red);
       }
       return (0);
    }
    
    int DeletePendingOrders(int a_magic_0) {
       int l_ord_total_4;
       if (idCheck() != 1) {
          l_ord_total_4 = OrdersTotal();
          for (int l_pos_8 = l_ord_total_4 - 1; l_pos_8 >= 0; l_pos_8--) {
             OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
             if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol() && OrderType() != OP_BUY || OrderType() != OP_SELL) OrderDelete(OrderTicket());
          }
       }
       return (0);
    }
    
    int CloseOrders(int a_magic_0) {
       int l_ord_total_4;
       if (idCheck() != 1) {
          l_ord_total_4 = OrdersTotal();
          for (int l_pos_8 = l_ord_total_4 - 1; l_pos_8 >= 0; l_pos_8--) {
             OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
             if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol()) {
                if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, 3);
                if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, 3);
             }
          }
       }
       return (0);
    }
    
    int MyOrdersTotal(int a_magic_0) {
       int l_count_4;
       int l_ord_total_8;
       if (idCheck() != 1) {
          l_count_4 = 0;
          l_ord_total_8 = OrdersTotal();
          for (int l_pos_12 = 0; l_pos_12 < l_ord_total_8; l_pos_12++) {
             OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
             if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol()) l_count_4++;
          }
       }
       return (l_count_4);
    }
    
    double GetLastBuyPrice(int a_magic_0) {
       int li_4;
       if (idCheck() != 1) {
          li_4 = OrdersTotal() - 1;
          for (int l_pos_8 = li_4; l_pos_8 >= 0; l_pos_8--) {
             if (idCheck() == 1) return;
             OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
             if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol() && OrderType() == OP_BUYLIMIT || OrderType() == OP_BUY) {
                g_ord_lots_116 = OrderLots();
                return (OrderOpenPrice());
             }
          }
       }
       return (0);
    }
    
    double GetLastSellPrice(int a_magic_0) {
       int li_4;
       if (idCheck() != 1) {
          li_4 = OrdersTotal() - 1;
          for (int l_pos_8 = li_4; l_pos_8 >= 0; l_pos_8--) {
             if (idCheck() == 1) return;
             OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
             if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol() && OrderType() == OP_SELLLIMIT || OrderType() == OP_SELL) {
                g_ord_lots_108 = OrderLots();
                return (OrderOpenPrice());
             }
          }
       }
       return (100000);
    }
    
    int idCheck() {
       if (gi_140 == gi_140) return (0);
       return (1);
    }
    any tf,any curuncy,big trend will blow your account.
    Modify it to work with other EA
    Thanks
    Last edited by sunyc1982; 10-07-2010 at 09:45.

Similar Threads

  1. EA - work manually
    By oGladiatore in forum Ideas for expert advisors
    Replies: 0
    Last Post: 10-12-2015, 00:15
  2. Do the elite section EA's still work?
    By supernoob in forum General discussion
    Replies: 0
    Last Post: 03-18-2014, 04:24
  3. Simple martingale EA modify request
    By xxxxx11 in forum Expert advisors backtesting
    Replies: 0
    Last Post: 02-22-2012, 13:48
  4. I want the amount of programmer work.
    By Mr.DO$LLAR in forum Ideas for expert advisors
    Replies: 1
    Last Post: 12-15-2009, 18:07

Tags for this Thread

100, grid, grid ea, magic, profit, simple, trend

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •