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

 
silhouette:

Good afternoon. The system provides three entry points for BUY and SELL. But when a signal comes in, positions are opened on every tick as long as the signal exists. There is an error somewhere with flags. Please help me to understand it.

OrdersTotal() gives the number of already opened positions, i.e., we can use it to check if there is already an open position or not.

 
Is there any way to find out the commissions for a 1 lot order without opening an order?
 
Reshetov:

OrdersTotal() gives the number of already opened positions, i.e., you can use it to check if there is already an open position or not.

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

  
static bool buy_1=true;
   
if(Stoch_Sig==4 && buy_l==true)
       { 
         sl=Ask-Stop_Loss*Point;
         Ans=OrderSend(Symb,OP_BUY,Lots,Ask,40,sl,0,"LSMA+Stoch",Magic);
         if(Ans==false)
           Alert("Неудачная попытка открыть ордер BUY. Ошибка: ", GetLastError());
         if(Ans==true)
            buy_l=false; // снимем флаг, запрещаем торговать по данному сигналу
       }


   
if(Stoch_Sig!=4 && buy_l==false) // поднимем флаг, сигнал сменился - торговать по нему можно опять
       buy_l=true;
 

Parny needs help What is it

2012.09.10 18:40:20 '6257743': order buy 5.00 EURUSD opening at 1.27816 sl: 1.27791 tp: 1.27876 failed [Invalid S/L or T/P]

Also why is the price and stop loss the same:

Price 1.25618 Stop Loss 1.25618 Take Profit 1.25698


Take Profit 60 pips

Stop Loss 20

 

Hello. I have a question about custom indicators. The iCustom description says:

double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)
Calculation of the specified custom indicator. The custom indicator must be compiled (file with EX4 extension) and placed interminal_directory\experts\indicators.
symbol - Symbol name of the symbol, on whose data the indicator will be calculated. NULL means current symbol.
timeframe - Period. Can be one of the periods of the chart. 0 means the period of the current chart.
name - Name of custom indicator.
... - List of parameters (if necessary). Transmitted parameters should correspond to the order of declaration and type of external (extern) variables of the custom indicator.
mode - Index of the indicator line. Can be from 0 to 7 and should correspond to the index, used by one of the SetIndexBuffer functions.
shift - Index of the value obtained from the indicator buffer (shift relative to the current bar by the specified number of periods back).

Question: how to get the value of "shift" (when calling the indicator with a shift, it uses the 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, uses 5 previous Close values, takes their average.

I will be grateful for your help.

 
paladin80:
You have set the deviation from the main line to 0 (zero). It should be more than zero.
Reshetov:
Would you set the deviation to negative as well?


Thank you, comrades! Exactly! I was too busy working and didn't have a clue. I wish I could have just clicked the thank you button, so as not to multiply. )

By the way, it would be useful to recommend newbies to pass parameters to indicators via variables with eloquent names. So far I have done so, this time I missed something.

 

Good evening all!

I wanted to ask the same question and took the function from here https://www.mql5.com/ru/forum/131859

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

I get errors--->

All variables in the function are defined inside it...what's wrong?

copied it, pasted it. --->

   if((High[2]==High[1])||(Close[2]==High[1])||(High[2]==Open[1]))
   {
   DeleteOrders()
   }
   
   
 //+----------------------------------------------------------------------------+
//| Автор    : Ким Игорь В. 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(), clDelete);
          }
        }
      }
    }
  }
}
 
DanLett:

There are no mistakes there:

//+----------------------------------------------------------------------------+
//| Автор    : Ким Игорь В. 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);
          }
        }
      }
    }
  }
}
But, you only need to specify a colour, for example -CLR_NONE.
 

And it looks like you have this 'hanging in the air':

  if((High[2]==High[1])||(Close[2]==High[1])||(High[2]==Open[1]))
   {
   DeleteOrders()
   }
Actually, such a condition (High[2]==High[1 ]) or such(Close[2]==High[1 ]) or such(High[2]==Open[1 ]) is rare. Look at the graph, how many of these coincidences will you find?

In terms of the logic of removing the order, ... - also suffers, in short.

 

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

Strangely, it still gives the same errors...