[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 378

 
DanLett:

copied the code from here and created a new project (EA) pasted the code -> compiled

Strangely enough, it still gives the same errors...

Try to remove everything except this function and compile. Will there be any errors? Just save it before you delete it.
 

I have been trading manually, eurusd 5 min, check it if you have time....

i want to build an EA based on this strategy, i just need to close trades with condition _2 :),i can't figure it out, i even have a close function and i get errors all the time.....

 
DanLett:
So does this function alone without everything else produce errors or not?
 

created again, deleted everything, but left the function and saved it - but no errors

but as soon as I add int start there are errors... What could be the problem?

 
int start()
  {
void DeleteOrders(string sy="", int op=-1, int mn=-1) {
  int i, k=OrdersTotal(), ot;
  
 
  if (sy=="" || sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      ot=OrderType();
      if (ot==OP_BUYLIMIT || ot==OP_BUYSTOP || ot==OP_SELLLIMIT || ot==OP_SELLSTOP) {
        if (OrderSymbol()==sy && (op<0 || ot==op)) {
          if (mn<0 || OrderMagicNumber()==mn) {
            OrderDelete(OrderTicket(), CLR_NONE);
          }
        }
      }
    }
  }
}

  }
 
Unbalanced brackets.
 
int start()
 {
 }
   
 //+----------------------------------------------------------------------------+
//| Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                    |
//+----------------------------------------------------------------------------+
//| Версия   : 13.06.2007                                                      |
//| Описание : Удаление ордеров. Версия функции для тестов на истории.         |
//+----------------------------------------------------------------------------+
//| Параметры:                                                                 |
//| sy - наименование инструмента   (NULL - текущий символ)                    |
//| op - операция                   ( -1  - любой ордер)                       |
//| mn - MagicNumber                ( -1  - любой магик)                       |
//+----------------------------------------------------------------------------+
void DeleteOrders(string sy="", int op=-1, int mn=-1) {
  int i, k=OrdersTotal(), ot;
  
 
  if (sy=="" || sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      ot=OrderType();
      if (ot==OP_BUYLIMIT || ot==OP_BUYSTOP || ot==OP_SELLLIMIT || ot==OP_SELLSTOP) {
        if (OrderSymbol()==sy && (op<0 || ot==op)) {
          if (mn<0 || OrderMagicNumber()==mn) {
            OrderDelete(OrderTicket(), CLR_NONE);
         }
        }
      }
    }
  }
}
 
There are no internal functions in MQL4, only external ones.
 
I'll check now.
 

does not work...

how then to close an order with this function under condition_2 close an order

if((High[2]==High[1])||(Close[2]==High[1])||(High[2]==Open[1]))

here is the condition to open a trade in condition_1

   if (Close[2]<Open[2])
 {
   if(Close[1]>Open[1])
   {
       if(OrdersTotal()<=0)
      {
         if((Low[2]==Low[1])||(Close[2]==Low[1])||(Low[2]==Open[1]))
          {
         OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0,0,"DLSexp",12345,0,Green);
          }
      }
   }
 }