[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 379

 

DanLett:

Call the procedure like this, for example:

int start()
 {
 DeleteOrders(NULL, -1, -1);
 }

//+----------------------------------------------------------------------------+
//| Автор    : Ким Игорь В. 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);
         }
        }
      }
    }
  }
}


 
OK, I'll check again.
 
Once again, I want to repeat myself.
(Low[2]==Low[1])||(Close[2]==Low[1])||(Low[2]==Open[1])
You can't set conditions like that. These are unlikely events.
 
atguard:

Question: How do I get the "shift" value? (when I call the indicator with a shift, it uses the same values as without it, i.e.iCustom(NULL, 0, "name",pam1,0,1)= iCustom(NULL, 0, "name",pam1,0,100), but if I call the indicator 100 bars ago, it will have a different value from iCustom(NULL, 0, "name",pam1,0,100). The indicator is simple, it uses 5 previous Close values and takes their average.



double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)

shift is the number of the bar from which you take the indicator data, zero bar is the current bar which hasn't been closed yet. The parameter is named shift because it shows the offset of the received data from the zero bar in bars.

 
silhouette:

I use Terminal() function from the tutorial when closing positions, provided that Mas_Ord_New[0][0]!=0. But here we have another task: we need to make a flag prohibiting to trade on the current signal, if one order has already been opened on it. I am trying to use flags but I have made a mistake.

I think it would be better to put an appropriate magic number in the order and check if such a position is in the list. If there is = flag-true, no = flag-false. Then on condition of opening a position on your signal insert a flag, e.g:

bool flag_1=true;
int MagNum_1=555;

int start()
{
// ...

if (OrdersTotal()>0)
{  for (int i=OrdersTotal()-1; i>=0; i--)
   {  if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {  if (OrderMagicNumber()==MagNum_1)
              flag_1=true;
         else flag_1=false;
}  }  }

if (flag_1==false && /*данное условие открытия позиции*/)
{ OrderSend(..., MagNum_1, ...);
}
//...
}
 
paladin80:

I think it is better to put the appropriate magic number in the order and check if that position is on the list. If there is a flag-true, no flag-false. Then if a position is opened by your signal, insert a flag, e.g:


That is, if I understand correctly, you propose to use several magiks corresponding to each type of signal?
 
Can you tell me why the optimiser can count but not produce results? There are no errors in the log. The genetic algorithm is disabled. The interval of optimization is 5 days, the mode is all ticks, the period is any m1, m5, m15, m30. And only starting from the H1 period the results appear.
 
Desead:
Can you tell me why the optimiser can count but not produce results? There are no errors in the log. The genetic algorithm is disabled. The interval of optimization is 5 days, the mode is all ticks, the period is any m1, m5, m15, m30. The results appear only beginning with the period H1.

On periods shorter than H1 the algorithm fails.
 
Vinin:

On periods shorter than H1, the plummets.
Exactly! There is even a checkbox for that, how come I didn't know about it ). Thanks for that.
 
Desead:
Can you tell me why the optimiser can count but not produce results? There are no errors in the log. The genetic algorithm is disabled. The interval of optimization is 5 days, the mode is all ticks, the period is any m1, m5, m15, m30. And the results appear only starting from the H1 period.

If the earnings are negative with this combination of parameters, the results are not shown. Generally, 5 days is a very short period, set at least a month.